Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
“xxq250” | c94811a8cd | |
“xxq250” | e1b432839d |
|
@ -10,7 +10,7 @@
|
|||
|
||||
# Ignore lock config file
|
||||
*.log
|
||||
.env
|
||||
|
||||
# mac
|
||||
*.DS_Store
|
||||
.bashrc
|
||||
|
@ -84,5 +84,4 @@ redis_data/
|
|||
dump.rdb
|
||||
.tags*
|
||||
ceshi_user.xlsx
|
||||
public/trace_task_results
|
||||
public/项目活跃度排行.xls
|
||||
public/trace_task_results
|
62
Dockerfile
62
Dockerfile
|
@ -1,59 +1,33 @@
|
|||
FROM ubuntu:20.04
|
||||
RUN apt-get update
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata
|
||||
# basics
|
||||
RUN apt-get install -y libssl-dev curl libmysqlclient-dev imagemagick nodejs mysql-server redis-server
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
# confirm openssl version
|
||||
RUN openssl version
|
||||
RUN which openssl
|
||||
# install RVM, Ruby, and Bundler
|
||||
RUN \curl -L https://get.rvm.io | bash -s stable
|
||||
# rvm environment variable
|
||||
RUN /bin/bash -l -c "source /etc/profile.d/rvm.sh"
|
||||
RUN /bin/bash -l -c "rvm requirements"
|
||||
# replace ruby mirror url, accelerate install ruby
|
||||
RUN sed -i 's/rvm_remote_server_url2/#rvm_remote_server_url2/g' /usr/local/rvm/config/db
|
||||
RUN sed -i 's/cache.ruby-lang.org/cache.ruby-china.com/g' /usr/local/rvm/config/db
|
||||
# install ruby
|
||||
RUN /bin/bash -l -c "rvm install 2.4.5"
|
||||
# confirm ruby version
|
||||
RUN /bin/bash -l -c "rvm list"
|
||||
RUN /bin/bash -l -c "ruby -v"
|
||||
RUN apt update
|
||||
|
||||
#RUN apt-get install -y nodejs
|
||||
RUN apt install -y openssl libssl-dev imagemagick git ruby-dev nodejs libmariadb-dev libmysqlclient-dev shared-mime-info libpq-dev libxml2-dev libxslt-dev
|
||||
RUN DEBIAN_FRONTEND="noninteractive" apt -y install tzdata
|
||||
RUN ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
WORKDIR /home/app/gitlink
|
||||
|
||||
ADD ./ /home/app/gitlink
|
||||
|
||||
RUN cd /home/app/gitlink
|
||||
RUN gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
|
||||
|
||||
RUN /bin/bash -l -c 'gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/'
|
||||
RUN gem update --system
|
||||
|
||||
RUN /bin/bash -l -c 'gem update --system'
|
||||
|
||||
RUN /bin/bash -l -c 'gem install bundler -v 2.3.26'
|
||||
RUN /bin/bash -l -c 'gem install rake'
|
||||
RUN /bin/bash -l -c 'gem install puma -v 5.6.5'
|
||||
RUN gem install bundler
|
||||
RUN gem install rake
|
||||
|
||||
RUN rm -rf Gemfile.lock
|
||||
|
||||
RUN cp config/configuration.yml.example config/configuration.yml
|
||||
RUN cp config/database-docker.yml.example config/database.yml
|
||||
RUN touch config/redis.yml
|
||||
RUN touch config/elasticsearch.yml
|
||||
#RUN cp config/configuration.yml.example config/configuration.yml
|
||||
#RUN cp config/database.yml.example config/database.yml
|
||||
#RUN touch config/redis.yml
|
||||
#RUN touch config/elasticsearch.yml
|
||||
|
||||
RUN /bin/bash -l -c 'bundle install'
|
||||
|
||||
RUN redis-server &
|
||||
|
||||
RUN /bin/bash -l -c 'bundle exec rake sync_table_structure:import_csv'
|
||||
|
||||
RUN /bin/bash -l -c 'rails db:migrate RAILS_ENV=development'
|
||||
|
||||
RUN /bin/bash -l -c 'bundle exec sidekiq -C config/sidekiq.yml -e production -d'
|
||||
RUN bundle install
|
||||
|
||||
EXPOSE 4000
|
||||
RUN /bin/bash -l -c 'RAILS_ENV=production puma -C config/puma.rb'
|
||||
RUN rails s -p 4000 -b '0.0.0.0'
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
FROM ubuntu:20.04
|
||||
RUN apt-get update
|
||||
# basics
|
||||
RUN apt-get install -y libssl-dev curl libmysqlclient-dev imagemagick nodejs mysql-server redis-server tzdata
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
# confirm openssl version
|
||||
RUN openssl version
|
||||
RUN which openssl
|
||||
# install RVM, Ruby, and Bundler
|
||||
RUN \curl -L https://get.rvm.io | bash -s stable
|
||||
RUN /bin/bash -l -c "rvm requirements"
|
||||
# replace ruby mirror url, accelerate install ruby
|
||||
RUN sed -i 's/rvm_remote_server_url2/#rvm_remote_server_url2/g' /usr/local/rvm/config/db
|
||||
RUN sed -i 's/cache.ruby-lang.org/cache.ruby-china.com/g' /usr/local/rvm/config/db
|
||||
# install ruby
|
||||
RUN /bin/bash -l -c "rvm install 2.4.5"
|
||||
# confirm ruby version
|
||||
RUN /bin/bash -l -c "rvm list"
|
||||
RUN /bin/bash -l -c "ruby -v"
|
40
Gemfile
40
Gemfile
|
@ -1,12 +1,12 @@
|
|||
#source 'https://gems.ruby-china.com'
|
||||
source 'https://mirrors.cloud.tencent.com/rubygems/'
|
||||
source 'https://gems.ruby-china.com'
|
||||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||
|
||||
gem 'rails', '~> 5.2.0'
|
||||
gem 'rails', '~> 6.1.0'
|
||||
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
|
||||
gem 'puma', '~> 5.6.5'
|
||||
gem 'sass-rails', '~> 5.0'
|
||||
gem 'uglifier', '>= 1.3.0'
|
||||
gem "nokogiri", "~> 1.13.0"
|
||||
|
||||
# gem 'coffee-rails', '~> 4.2'
|
||||
gem 'turbolinks', '~> 5'
|
||||
|
@ -23,9 +23,10 @@ gem 'chinese_pinyin'
|
|||
gem 'rack-cors'
|
||||
gem 'redis-rails'
|
||||
gem 'roo-xls'
|
||||
gem 'simple_xlsx_reader', '~>1.0.4'
|
||||
gem 'roo', '2.8.3'
|
||||
gem 'simple_xlsx_reader'
|
||||
|
||||
gem 'rubyzip'
|
||||
gem 'rubyzip', '~> 1.3.0'
|
||||
|
||||
gem 'spreadsheet'
|
||||
gem 'ruby-ole'
|
||||
|
@ -45,7 +46,7 @@ gem 'redcarpet', '~> 3.4'
|
|||
gem 'rqrcode', '~> 0.10.1'
|
||||
gem 'rqrcode_png'
|
||||
|
||||
gem 'acts-as-taggable-on', '~> 6.0'
|
||||
gem 'acts-as-taggable-on', '~> 9.0'
|
||||
|
||||
# a tree structure
|
||||
gem 'ancestry'
|
||||
|
@ -53,19 +54,19 @@ gem 'acts_as_list'
|
|||
gem 'omniauth-cas'
|
||||
|
||||
# profiler Middleware
|
||||
# gem 'rack-mini-profiler'
|
||||
gem 'rack-mini-profiler'
|
||||
|
||||
# object-based searching
|
||||
gem 'ransack'
|
||||
gem 'ransack','~> 3.0.1'
|
||||
|
||||
group :development, :test do
|
||||
gem 'rspec-rails', '~> 3.8'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'prettier'
|
||||
gem 'rubocop', '~> 0.52.0'
|
||||
gem 'solargraph', '~> 0.38.0'
|
||||
gem 'prettier', '2.1.0'
|
||||
gem 'rubocop', '~> 1.38.0'
|
||||
gem 'solargraph', '~> 0.47.2'
|
||||
gem 'awesome_print'
|
||||
gem 'web-console', '>= 3.3.0'
|
||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||
|
@ -75,8 +76,8 @@ group :development do
|
|||
end
|
||||
|
||||
group :test do
|
||||
gem 'capybara', '>= 2.15', '< 4.0'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'capybara', '3.35.3'
|
||||
gem 'selenium-webdriver', '3.142.7'
|
||||
gem 'chromedriver-helper'
|
||||
end
|
||||
|
||||
|
@ -96,13 +97,12 @@ gem 'simple_form'
|
|||
gem 'font-awesome-sass', '4.7.0'
|
||||
|
||||
# i18n
|
||||
gem 'rails-i18n', '~> 5.1'
|
||||
gem 'rails-i18n', '~> 7.0.6'
|
||||
|
||||
# job
|
||||
gem 'sidekiq',"5.2.8"
|
||||
gem 'sinatra'
|
||||
gem "sidekiq-cron", "1.2.0"
|
||||
gem 'sidekiq-failures'
|
||||
gem "sidekiq-cron", "~>1.8.0"
|
||||
|
||||
# batch insert
|
||||
gem 'bulk_insert'
|
||||
|
@ -118,12 +118,8 @@ gem 'diffy'
|
|||
gem 'deep_cloneable', '~> 3.0.0'
|
||||
|
||||
# oauth2
|
||||
gem 'omniauth', '~> 1.9.0'
|
||||
gem 'omniauth', '~> 1.9.2'
|
||||
gem 'omniauth-oauth2', '~> 1.6.0'
|
||||
gem "omniauth-github"
|
||||
gem "omniauth-rails_csrf_protection"
|
||||
gem 'omniauth-gitee', '~> 1.0.0'
|
||||
gem "omniauth-wechat-oauth2"
|
||||
|
||||
# global var
|
||||
gem 'request_store'
|
||||
|
@ -141,4 +137,4 @@ gem 'doorkeeper'
|
|||
|
||||
gem 'doorkeeper-jwt'
|
||||
|
||||
gem 'gitea-client', '~> 1.5.8'
|
||||
gem 'gitea-client', '~> 0.10.5'
|
512
Gemfile.lock
512
Gemfile.lock
|
@ -1,69 +1,86 @@
|
|||
GEM
|
||||
remote: https://mirrors.cloud.tencent.com/rubygems/
|
||||
remote: https://gems.ruby-china.com/
|
||||
specs:
|
||||
aasm (5.0.6)
|
||||
aasm (5.4.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
actioncable (5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
actioncable (6.1.7)
|
||||
actionpack (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
actionview (= 5.2.4.1)
|
||||
activejob (= 5.2.4.1)
|
||||
actionmailbox (6.1.7)
|
||||
actionpack (= 6.1.7)
|
||||
activejob (= 6.1.7)
|
||||
activerecord (= 6.1.7)
|
||||
activestorage (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.1.7)
|
||||
actionpack (= 6.1.7)
|
||||
actionview (= 6.1.7)
|
||||
activejob (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.4.1)
|
||||
actionview (= 5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
actionpack (6.1.7)
|
||||
actionview (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
rack (~> 2.0, >= 2.0.9)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.1.7)
|
||||
actionpack (= 6.1.7)
|
||||
activerecord (= 6.1.7)
|
||||
activestorage (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
active_decorator (1.3.2)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
active_decorator (1.4.0)
|
||||
activesupport
|
||||
activejob (5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
activejob (6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
activerecord (5.2.4.1)
|
||||
activemodel (= 5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
activerecord (= 5.2.4.1)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.4.1)
|
||||
activemodel (6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
activerecord (6.1.7)
|
||||
activemodel (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
activestorage (6.1.7)
|
||||
actionpack (= 6.1.7)
|
||||
activejob (= 6.1.7)
|
||||
activerecord (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
marcel (~> 1.0)
|
||||
mini_mime (>= 1.1.0)
|
||||
activesupport (6.1.7)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
acts-as-taggable-on (6.5.0)
|
||||
activerecord (>= 5.0, < 6.1)
|
||||
acts_as_list (0.9.19)
|
||||
activerecord (>= 3.0)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
ancestry (3.0.7)
|
||||
activerecord (>= 3.2.0)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
zeitwerk (~> 2.3)
|
||||
acts-as-taggable-on (9.0.1)
|
||||
activerecord (>= 6.0, < 7.1)
|
||||
acts_as_list (1.0.4)
|
||||
activerecord (>= 4.2)
|
||||
addressable (2.8.1)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
ancestry (4.2.0)
|
||||
activerecord (>= 5.2.6)
|
||||
annotate (2.6.5)
|
||||
activerecord (>= 2.3.0)
|
||||
rake (>= 0.8.7)
|
||||
archive-zip (0.12.0)
|
||||
io-like (~> 0.3.0)
|
||||
arel (9.0.0)
|
||||
ast (2.4.0)
|
||||
autoprefixer-rails (9.7.4)
|
||||
execjs
|
||||
awesome_print (1.8.0)
|
||||
ast (2.4.2)
|
||||
autoprefixer-rails (10.4.7.0)
|
||||
execjs (~> 2)
|
||||
awesome_print (1.9.2)
|
||||
axlsx (3.0.0.pre)
|
||||
htmlentities (~> 4.3, >= 4.3.4)
|
||||
mimemagic (~> 0.3)
|
||||
|
@ -72,255 +89,242 @@ GEM
|
|||
axlsx_rails (0.5.2)
|
||||
actionpack (>= 3.1)
|
||||
axlsx (>= 2.0.1)
|
||||
backport (1.1.2)
|
||||
benchmark (0.1.0)
|
||||
backport (1.2.0)
|
||||
benchmark (0.2.0)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.4.6)
|
||||
msgpack (~> 1.0)
|
||||
bootsnap (1.13.0)
|
||||
msgpack (~> 1.2)
|
||||
bootstrap (4.3.1)
|
||||
autoprefixer-rails (>= 9.1.0)
|
||||
popper_js (>= 1.14.3, < 2)
|
||||
sassc-rails (>= 2.0.0)
|
||||
builder (3.2.4)
|
||||
bulk_insert (1.7.0)
|
||||
bulk_insert (1.9.0)
|
||||
activerecord (>= 3.2.0)
|
||||
capybara (3.15.1)
|
||||
capybara (3.35.3)
|
||||
addressable
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (~> 1.8)
|
||||
rack (>= 1.6.0)
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (~> 1.2)
|
||||
regexp_parser (>= 1.5, < 3.0)
|
||||
xpath (~> 3.2)
|
||||
chartkick (3.3.1)
|
||||
chartkick (4.2.1)
|
||||
childprocess (3.0.0)
|
||||
chinese_pinyin (1.0.2)
|
||||
chinese_pinyin (1.1.0)
|
||||
chromedriver-helper (2.1.1)
|
||||
archive-zip (~> 0.10)
|
||||
nokogiri (~> 1.8)
|
||||
chunky_png (1.3.11)
|
||||
concurrent-ruby (1.1.6)
|
||||
connection_pool (2.2.2)
|
||||
chunky_png (1.4.0)
|
||||
concurrent-ruby (1.1.10)
|
||||
connection_pool (2.3.0)
|
||||
crass (1.0.6)
|
||||
deep_cloneable (3.0.0)
|
||||
activerecord (>= 3.1.0, < 7)
|
||||
diff-lcs (1.3)
|
||||
diffy (3.3.0)
|
||||
diff-lcs (1.5.0)
|
||||
diffy (3.4.2)
|
||||
domain_name (0.5.20190701)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
doorkeeper (5.5.1)
|
||||
doorkeeper (5.6.0)
|
||||
railties (>= 5)
|
||||
doorkeeper-jwt (0.4.1)
|
||||
jwt (>= 2.1)
|
||||
e2mmap (0.1.0)
|
||||
elasticsearch (7.5.0)
|
||||
elasticsearch-api (= 7.5.0)
|
||||
elasticsearch-transport (= 7.5.0)
|
||||
elasticsearch-api (7.5.0)
|
||||
multi_json
|
||||
elasticsearch-transport (7.5.0)
|
||||
faraday (>= 0.14, < 1)
|
||||
multi_json
|
||||
enumerize (2.3.1)
|
||||
enumerize (2.5.0)
|
||||
activesupport (>= 3.2)
|
||||
erubi (1.9.0)
|
||||
et-orbi (1.2.4)
|
||||
erubi (1.11.0)
|
||||
et-orbi (1.2.7)
|
||||
tzinfo
|
||||
execjs (2.7.0)
|
||||
execjs (2.8.1)
|
||||
faraday (0.15.4)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.12.2)
|
||||
ffi (1.15.5)
|
||||
font-awesome-sass (4.7.0)
|
||||
sass (>= 3.2)
|
||||
fugit (1.4.1)
|
||||
et-orbi (~> 1.1, >= 1.1.8)
|
||||
fugit (1.7.2)
|
||||
et-orbi (~> 1, >= 1.2.7)
|
||||
raabro (~> 1.4)
|
||||
gitea-client (1.4.2)
|
||||
gitea-client (0.10.5)
|
||||
rest-client (~> 2.1.0)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
globalid (1.0.0)
|
||||
activesupport (>= 5.0)
|
||||
grape-entity (0.7.1)
|
||||
activesupport (>= 4.0)
|
||||
multi_json (>= 1.3.2)
|
||||
groupdate (4.1.2)
|
||||
activesupport (>= 4.2)
|
||||
harmonious_dictionary (0.0.1)
|
||||
hashie (3.6.0)
|
||||
hashie (5.0.0)
|
||||
htmlentities (4.3.4)
|
||||
http-accept (1.7.0)
|
||||
http-cookie (1.0.5)
|
||||
domain_name (~> 0.5)
|
||||
i18n (1.8.2)
|
||||
i18n (1.12.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
io-like (0.3.1)
|
||||
jaro_winkler (1.5.4)
|
||||
jbuilder (2.10.0)
|
||||
jbuilder (2.11.5)
|
||||
actionview (>= 5.0.0)
|
||||
activesupport (>= 5.0.0)
|
||||
jquery-rails (4.3.5)
|
||||
jquery-rails (4.5.0)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
jwt (2.2.1)
|
||||
kaminari (1.2.0)
|
||||
json (2.6.2)
|
||||
jwt (2.5.0)
|
||||
kaminari (1.2.2)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.2.0)
|
||||
kaminari-activerecord (= 1.2.0)
|
||||
kaminari-core (= 1.2.0)
|
||||
kaminari-actionview (1.2.0)
|
||||
kaminari-actionview (= 1.2.2)
|
||||
kaminari-activerecord (= 1.2.2)
|
||||
kaminari-core (= 1.2.2)
|
||||
kaminari-actionview (1.2.2)
|
||||
actionview
|
||||
kaminari-core (= 1.2.0)
|
||||
kaminari-activerecord (1.2.0)
|
||||
kaminari-core (= 1.2.2)
|
||||
kaminari-activerecord (1.2.2)
|
||||
activerecord
|
||||
kaminari-core (= 1.2.0)
|
||||
kaminari-core (1.2.0)
|
||||
letter_avatar (0.3.8)
|
||||
kaminari-core (= 1.2.2)
|
||||
kaminari-core (1.2.2)
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
letter_avatar (0.3.9)
|
||||
listen (3.1.5)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
ruby_dep (~> 1.2)
|
||||
loofah (2.4.0)
|
||||
loofah (2.19.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
maruku (0.7.3)
|
||||
method_source (0.9.2)
|
||||
marcel (1.0.2)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.4.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2023.0218.1)
|
||||
mimemagic (0.3.10)
|
||||
mime-types-data (3.2022.0105)
|
||||
mimemagic (0.4.3)
|
||||
nokogiri (~> 1)
|
||||
rake
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.0)
|
||||
msgpack (1.3.3)
|
||||
multi_json (1.14.1)
|
||||
mini_mime (1.1.2)
|
||||
mini_portile2 (2.8.0)
|
||||
minitest (5.16.3)
|
||||
msgpack (1.6.0)
|
||||
multi_json (1.15.0)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
mustermann (1.1.1)
|
||||
multipart-post (2.2.3)
|
||||
mustermann (1.1.2)
|
||||
ruby2_keywords (~> 0.0.1)
|
||||
mysql2 (0.5.3)
|
||||
mysql2 (0.5.4)
|
||||
netrc (0.11.0)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.8)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.13.9)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
racc (~> 1.4)
|
||||
oauth2 (1.4.8)
|
||||
faraday (>= 0.8, < 3.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.0)
|
||||
hashie (>= 3.4.6, < 3.7.0)
|
||||
omniauth (1.9.2)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-cas (1.1.1)
|
||||
omniauth-cas (2.0.0)
|
||||
addressable (~> 2.3)
|
||||
nokogiri (~> 1.5)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-gitee (1.0.0)
|
||||
omniauth (>= 1.5, < 3.0)
|
||||
omniauth-oauth2 (>= 1.4.0, < 2.0)
|
||||
omniauth-github (1.4.0)
|
||||
omniauth (~> 1.5)
|
||||
omniauth-oauth2 (>= 1.4.0, < 2.0)
|
||||
omniauth-oauth2 (1.6.0)
|
||||
oauth2 (~> 1.1)
|
||||
omniauth (~> 1.9)
|
||||
omniauth-rails_csrf_protection (0.1.2)
|
||||
actionpack (>= 4.2)
|
||||
omniauth (>= 1.3.1)
|
||||
omniauth-wechat-oauth2 (0.2.2)
|
||||
omniauth (>= 1.3.2)
|
||||
omniauth-oauth2 (>= 1.1.1)
|
||||
parallel (1.19.1)
|
||||
parser (2.7.1.1)
|
||||
ast (~> 2.4.0)
|
||||
pdfkit (0.8.4.1)
|
||||
polyamorous (2.3.2)
|
||||
activerecord (>= 5.2.1)
|
||||
popper_js (1.16.0)
|
||||
powerpack (0.1.2)
|
||||
prettier (0.18.2)
|
||||
public_suffix (4.0.3)
|
||||
parallel (1.22.1)
|
||||
parser (3.1.2.1)
|
||||
ast (~> 2.4.1)
|
||||
pdfkit (0.8.7.2)
|
||||
popper_js (1.16.1)
|
||||
prettier (2.1.0)
|
||||
public_suffix (5.0.0)
|
||||
puma (5.6.5)
|
||||
nio4r (~> 2.0)
|
||||
raabro (1.4.0)
|
||||
rack (2.0.9)
|
||||
racc (1.6.0)
|
||||
rack (2.0.9.1)
|
||||
rack-cors (1.1.1)
|
||||
rack (>= 2.0.0)
|
||||
rack-mini-profiler (3.0.0)
|
||||
rack (>= 1.2.0)
|
||||
rack-protection (2.0.8.1)
|
||||
rack
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.4.1)
|
||||
actioncable (= 5.2.4.1)
|
||||
actionmailer (= 5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
actionview (= 5.2.4.1)
|
||||
activejob (= 5.2.4.1)
|
||||
activemodel (= 5.2.4.1)
|
||||
activerecord (= 5.2.4.1)
|
||||
activestorage (= 5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.4.1)
|
||||
rack-test (2.0.2)
|
||||
rack (>= 1.3)
|
||||
rails (6.1.7)
|
||||
actioncable (= 6.1.7)
|
||||
actionmailbox (= 6.1.7)
|
||||
actionmailer (= 6.1.7)
|
||||
actionpack (= 6.1.7)
|
||||
actiontext (= 6.1.7)
|
||||
actionview (= 6.1.7)
|
||||
activejob (= 6.1.7)
|
||||
activemodel (= 6.1.7)
|
||||
activerecord (= 6.1.7)
|
||||
activestorage (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
bundler (>= 1.15.0)
|
||||
railties (= 6.1.7)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
rails-html-sanitizer (1.4.3)
|
||||
loofah (~> 2.3)
|
||||
rails-i18n (5.1.3)
|
||||
rails-i18n (7.0.6)
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 5.0, < 6)
|
||||
railties (5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
railties (>= 6.0.0, < 8)
|
||||
railties (6.1.7)
|
||||
actionpack (= 6.1.7)
|
||||
activesupport (= 6.1.7)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
rake (13.0.1)
|
||||
ransack (2.3.2)
|
||||
activerecord (>= 5.2.1)
|
||||
activesupport (>= 5.2.1)
|
||||
rake (>= 12.2)
|
||||
thor (~> 1.0)
|
||||
rainbow (3.1.1)
|
||||
rake (13.0.6)
|
||||
ransack (3.0.1)
|
||||
activerecord (>= 6.0.4)
|
||||
activesupport (>= 6.0.4)
|
||||
i18n
|
||||
polyamorous (= 2.3.2)
|
||||
rb-fsevent (0.10.3)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rchardet (1.8.0)
|
||||
redcarpet (3.5.0)
|
||||
redis (4.1.3)
|
||||
redis-actionpack (5.2.0)
|
||||
actionpack (>= 5, < 7)
|
||||
redcarpet (3.5.1)
|
||||
redis (4.8.0)
|
||||
redis-actionpack (5.3.0)
|
||||
actionpack (>= 5, < 8)
|
||||
redis-rack (>= 2.1.0, < 3)
|
||||
redis-store (>= 1.1.0, < 2)
|
||||
redis-activesupport (5.2.0)
|
||||
activesupport (>= 3, < 7)
|
||||
redis-activesupport (5.3.0)
|
||||
activesupport (>= 3, < 8)
|
||||
redis-store (>= 1.3, < 2)
|
||||
redis-rack (2.1.2)
|
||||
redis-rack (2.1.4)
|
||||
rack (>= 2.0.8, < 3)
|
||||
redis-store (>= 1.2, < 2)
|
||||
redis-rails (5.0.2)
|
||||
redis-actionpack (>= 5.0, < 6)
|
||||
redis-activesupport (>= 5.0, < 6)
|
||||
redis-store (>= 1.2, < 2)
|
||||
redis-store (1.8.2)
|
||||
redis-store (1.9.1)
|
||||
redis (>= 4, < 5)
|
||||
regexp_parser (1.7.0)
|
||||
request_store (1.5.0)
|
||||
regexp_parser (2.6.0)
|
||||
request_store (1.5.1)
|
||||
rack (>= 1.4)
|
||||
rest-client (2.1.0)
|
||||
http-accept (>= 1.7.0, < 2.0)
|
||||
http-cookie (>= 1.0.2, < 2.0)
|
||||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
reverse_markdown (1.4.0)
|
||||
reverse_markdown (2.1.1)
|
||||
nokogiri
|
||||
rexml (3.2.5)
|
||||
roo (2.8.3)
|
||||
nokogiri (~> 1)
|
||||
rubyzip (>= 1.3.0, < 3.0.0)
|
||||
|
@ -333,15 +337,15 @@ GEM
|
|||
rqrcode_png (0.1.5)
|
||||
chunky_png
|
||||
rqrcode
|
||||
rspec-core (3.9.1)
|
||||
rspec-support (~> 3.9.1)
|
||||
rspec-expectations (3.9.0)
|
||||
rspec-core (3.9.3)
|
||||
rspec-support (~> 3.9.3)
|
||||
rspec-expectations (3.9.4)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-mocks (3.9.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-rails (3.9.0)
|
||||
rspec-rails (3.9.1)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
|
@ -349,17 +353,22 @@ GEM
|
|||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-support (3.9.2)
|
||||
rubocop (0.52.1)
|
||||
rspec-support (3.9.4)
|
||||
rubocop (1.38.0)
|
||||
json (~> 2.3)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.4.0.2, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
parser (>= 3.1.2.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.23.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.23.0)
|
||||
parser (>= 3.1.1.0)
|
||||
ruby-ole (1.2.12.2)
|
||||
ruby-progressbar (1.10.1)
|
||||
ruby2_keywords (0.0.2)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
ruby_dep (1.5.0)
|
||||
rubyzip (1.3.0)
|
||||
sass (3.7.4)
|
||||
|
@ -367,13 +376,13 @@ GEM
|
|||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sass-rails (5.0.7)
|
||||
railties (>= 4.0.0, < 6)
|
||||
sass-rails (5.1.0)
|
||||
railties (>= 5.2.0)
|
||||
sass (~> 3.1)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
sassc (2.2.1)
|
||||
sassc (2.4.0)
|
||||
ffi (~> 1.9)
|
||||
sassc-rails (2.1.2)
|
||||
railties (>= 4.0.0)
|
||||
|
@ -381,9 +390,8 @@ GEM
|
|||
sprockets (> 3.0)
|
||||
sprockets-rails
|
||||
tilt
|
||||
searchkick (3.1.3)
|
||||
activemodel (>= 4.2)
|
||||
elasticsearch (>= 5)
|
||||
searchkick (5.1.0)
|
||||
activemodel (>= 5.2)
|
||||
hashie
|
||||
selenium-webdriver (3.142.7)
|
||||
childprocess (>= 0.5, < 4.0)
|
||||
|
@ -393,15 +401,13 @@ GEM
|
|||
rack (< 2.1.0)
|
||||
rack-protection (>= 1.5.0)
|
||||
redis (>= 3.3.5, < 5)
|
||||
sidekiq-cron (1.2.0)
|
||||
fugit (~> 1.1)
|
||||
sidekiq-cron (1.8.0)
|
||||
fugit (~> 1)
|
||||
sidekiq (>= 4.2.1)
|
||||
sidekiq-failures (1.0.4)
|
||||
sidekiq (>= 4.0.0)
|
||||
simple_form (5.0.2)
|
||||
actionpack (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
simple_xlsx_reader (1.0.4)
|
||||
simple_form (5.1.0)
|
||||
actionpack (>= 5.2)
|
||||
activemodel (>= 5.2)
|
||||
simple_xlsx_reader (2.0.0)
|
||||
nokogiri
|
||||
rubyzip
|
||||
sinatra (2.0.8.1)
|
||||
|
@ -409,60 +415,62 @@ GEM
|
|||
rack (~> 2.0)
|
||||
rack-protection (= 2.0.8.1)
|
||||
tilt (~> 2.0)
|
||||
solargraph (0.38.6)
|
||||
backport (~> 1.1)
|
||||
solargraph (0.47.2)
|
||||
backport (~> 1.2)
|
||||
benchmark
|
||||
bundler (>= 1.17.2)
|
||||
diff-lcs (~> 1.4)
|
||||
e2mmap
|
||||
jaro_winkler (~> 1.5)
|
||||
maruku (~> 0.7, >= 0.7.3)
|
||||
nokogiri (~> 1.9, >= 1.9.1)
|
||||
parser (~> 2.3)
|
||||
reverse_markdown (~> 1.0, >= 1.0.5)
|
||||
rubocop (~> 0.52)
|
||||
kramdown (~> 2.3)
|
||||
kramdown-parser-gfm (~> 1.1)
|
||||
parser (~> 3.0)
|
||||
reverse_markdown (>= 1.0.5, < 3)
|
||||
rubocop (>= 0.52)
|
||||
thor (~> 1.0)
|
||||
tilt (~> 2.0)
|
||||
yard (~> 0.9)
|
||||
spreadsheet (1.2.6)
|
||||
ruby-ole (>= 1.0)
|
||||
spring (2.0.2)
|
||||
activesupport (>= 4.2)
|
||||
yard (~> 0.9, >= 0.9.24)
|
||||
spreadsheet (1.3.0)
|
||||
ruby-ole
|
||||
spring (2.1.1)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets-rails (3.4.2)
|
||||
actionpack (>= 5.2)
|
||||
activesupport (>= 5.2)
|
||||
sprockets (>= 3.0.0)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.10)
|
||||
thor (1.2.1)
|
||||
tilt (2.0.11)
|
||||
turbolinks (5.2.1)
|
||||
turbolinks-source (~> 5.2)
|
||||
turbolinks-source (5.2.0)
|
||||
tzinfo (1.2.6)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (2.0.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.8.2)
|
||||
unicode-display_width (1.6.1)
|
||||
web-console (3.7.0)
|
||||
actionview (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
unicode-display_width (2.3.0)
|
||||
web-console (4.2.0)
|
||||
actionview (>= 6.0.0)
|
||||
activemodel (>= 6.0.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 5.0)
|
||||
websocket-driver (0.7.1)
|
||||
railties (>= 6.0.0)
|
||||
webrick (1.7.0)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.4)
|
||||
wkhtmltopdf-binary (0.12.5.4)
|
||||
websocket-extensions (0.1.5)
|
||||
wkhtmltopdf-binary (0.12.6.5)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
yard (0.9.24)
|
||||
yard (0.9.28)
|
||||
webrick (~> 1.7.0)
|
||||
zeitwerk (2.6.6)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -470,7 +478,7 @@ PLATFORMS
|
|||
DEPENDENCIES
|
||||
aasm
|
||||
active_decorator
|
||||
acts-as-taggable-on (~> 6.0)
|
||||
acts-as-taggable-on (~> 9.0)
|
||||
acts_as_list
|
||||
ancestry
|
||||
annotate (~> 2.6.0)
|
||||
|
@ -480,7 +488,7 @@ DEPENDENCIES
|
|||
bootsnap (>= 1.1.0)
|
||||
bootstrap (~> 4.3.1)
|
||||
bulk_insert
|
||||
capybara (>= 2.15, < 4.0)
|
||||
capybara (= 3.35.3)
|
||||
chartkick
|
||||
chinese_pinyin
|
||||
chromedriver-helper
|
||||
|
@ -491,7 +499,7 @@ DEPENDENCIES
|
|||
enumerize
|
||||
faraday (~> 0.15.4)
|
||||
font-awesome-sass (= 4.7.0)
|
||||
gitea-client (~> 1.4.2)
|
||||
gitea-client (~> 0.10.5)
|
||||
grape-entity (~> 0.7.1)
|
||||
groupdate (~> 4.1.0)
|
||||
harmonious_dictionary (~> 0.0.1)
|
||||
|
@ -502,43 +510,41 @@ DEPENDENCIES
|
|||
letter_avatar
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
mysql2 (>= 0.4.4, < 0.6.0)
|
||||
nokogiri (~> 1.13.0)
|
||||
oauth2
|
||||
omniauth (~> 1.9.0)
|
||||
omniauth (~> 1.9.2)
|
||||
omniauth-cas
|
||||
omniauth-gitee (~> 1.0.0)
|
||||
omniauth-github
|
||||
omniauth-oauth2 (~> 1.6.0)
|
||||
omniauth-rails_csrf_protection
|
||||
omniauth-wechat-oauth2
|
||||
parallel (~> 1.19, >= 1.19.1)
|
||||
pdfkit
|
||||
prettier
|
||||
prettier (= 2.1.0)
|
||||
puma (~> 5.6.5)
|
||||
rack-cors
|
||||
rails (~> 5.2.0)
|
||||
rails-i18n (~> 5.1)
|
||||
ransack
|
||||
rack-mini-profiler
|
||||
rails (~> 6.1.0)
|
||||
rails-i18n (~> 7.0.6)
|
||||
ransack (~> 3.0.1)
|
||||
rchardet (~> 1.8)
|
||||
redcarpet (~> 3.4)
|
||||
redis-rails
|
||||
request_store
|
||||
roo (= 2.8.3)
|
||||
roo-xls
|
||||
rqrcode (~> 0.10.1)
|
||||
rqrcode_png
|
||||
rspec-rails (~> 3.8)
|
||||
rubocop (~> 0.52.0)
|
||||
rubocop (~> 1.38.0)
|
||||
ruby-ole
|
||||
rubyzip
|
||||
rubyzip (~> 1.3.0)
|
||||
sass-rails (~> 5.0)
|
||||
searchkick
|
||||
selenium-webdriver
|
||||
selenium-webdriver (= 3.142.7)
|
||||
sidekiq (= 5.2.8)
|
||||
sidekiq-cron (= 1.2.0)
|
||||
sidekiq-failures
|
||||
sidekiq-cron (~> 1.8.0)
|
||||
simple_form
|
||||
simple_xlsx_reader (~> 1.0.4)
|
||||
simple_xlsx_reader
|
||||
sinatra
|
||||
solargraph (~> 0.38.0)
|
||||
solargraph (~> 0.47.2)
|
||||
spreadsheet
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
|
|
14
README.md
14
README.md
|
@ -3,8 +3,7 @@
|
|||
GitLink(确实开源)是中国计算机学会(CCF)官方指定的开源创新服务平台,旨在以“为开源创新服务”为使命,以“成为开源创新的汇聚地”为愿景,秉承“创新、开放、协作、共享”的价值观,致力于为大规模开源开放协同创新助力赋能,打造创新成果孵化和新工科人才培养的开源创新生态!
|
||||
|
||||
<center>
|
||||
<img src="docs/figs/gitlink.png" width=80% /></center>
|
||||
|
||||
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/gitlink.png?raw=true" width=80% /></center>
|
||||
|
||||
## 特色功能
|
||||
|
||||
|
@ -112,7 +111,6 @@ gitea:
|
|||
access_key_secret: 'password'
|
||||
domain: 'http://www.gitea.example.com'
|
||||
base_url: '/api/v1'
|
||||
hat_base_url: '/api/hat'
|
||||
```
|
||||
|
||||
(8)配置/config/database.yml文件(安装redis环境:请自行搜索各平台如何安装部署redis环境)
|
||||
|
@ -175,31 +173,31 @@ http://localhost:3000/
|
|||
- 项目列表
|
||||
|
||||
<center>
|
||||
<img src="docs/figs/project_list.png" width=80% />
|
||||
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/project_list.png?raw=true" width=50% />
|
||||
</center>
|
||||
|
||||
- 代码仓库
|
||||
|
||||
<center>
|
||||
<img src="docs/figs/repo.png" width=80% />
|
||||
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/repo.png?raw=true" width=50% />
|
||||
</center>
|
||||
|
||||
- 任务管理
|
||||
|
||||
<center>
|
||||
<img src="docs/figs/issues.png" width=80% />
|
||||
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/issues.png?raw=true" width=50% />
|
||||
</center>
|
||||
|
||||
- 合并请求
|
||||
|
||||
<center>
|
||||
<img src="docs/figs/PR.png" width=80% />
|
||||
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/PR.png?raw=true" width=50% />
|
||||
</center>
|
||||
|
||||
- 引擎配置
|
||||
|
||||
<center>
|
||||
<img src="docs/figs/engine.png" width=80% />
|
||||
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/engine.png?raw=true" width=50% />
|
||||
</center>
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -63,7 +63,7 @@ $(document).on('turbolinks:load', function() {
|
|||
|
||||
if(!valid) return;
|
||||
$.ajax({
|
||||
method: 'PUT',
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
url: $form.attr('action'),
|
||||
data: new FormData($form[0]),
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -1,65 +0,0 @@
|
|||
$(document).on('turbolinks:load', function(){
|
||||
if ($('body.admins-organizations-index-page').length > 0) {
|
||||
var showSuccessNotify = function() {
|
||||
$.notify({
|
||||
message: '操作成功'
|
||||
},{
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
|
||||
// organizations open cla
|
||||
$('.organizations-list-container').on('click', '.open-cla-action', function(){
|
||||
var $openClaAction = $(this);
|
||||
var $closeClaAction = $openClaAction.siblings('.close-cla-action');
|
||||
|
||||
var userId = $openClaAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认开通吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/organizations/' + userId + '/open_cla',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeClaAction.show();
|
||||
$openClaAction.hide();
|
||||
},
|
||||
error: function(res){
|
||||
$.notify({ message: res.responseJSON.message }, { type: 'danger' });
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// organizations close cla
|
||||
$('.organizations-list-container').on('click', '.close-cla-action', function(){
|
||||
var $closeClaAction = $(this);
|
||||
var $openClaAction= $closeClaAction.siblings('.open-cla-action');
|
||||
|
||||
var userId = $openClaAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认关闭吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/organizations/' + userId + '/close_cla',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$openClaAction.show();
|
||||
$closeClaAction.hide();
|
||||
},
|
||||
error: function(res){
|
||||
$.notify({ message: res.responseJSON.message }, { type: 'danger' });
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -94,20 +94,6 @@ $(document).on('turbolinks:load', function(){
|
|||
}
|
||||
});
|
||||
});
|
||||
// reset user login times
|
||||
$('.users-list-container').on('click', '.fresh-gitea-token-action', function(){
|
||||
var $action = $(this);
|
||||
|
||||
var userId = $action.data('id');
|
||||
$.ajax({
|
||||
url: '/admins/users/' + userId + '/fresh_gitea_token',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ***************** reward grade modal *****************
|
||||
var $rewardGradeModal = $('.admin-users-reward-grade-modal');
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the admins/glcc_pr_check controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the admins/identity_verifications controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the admins/organizations controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the admins/page_themes controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the admins/site_pages controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the identity_verifications controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the organizations/clas controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the pages controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the users/clas controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -4,16 +4,15 @@ class AccountsController < ApplicationController
|
|||
|
||||
#skip_before_action :check_account, :only => [:logout]
|
||||
|
||||
def simple_update
|
||||
def simple_update
|
||||
simple_update_params.merge!(username: params[:username]&.gsub(/\s+/, ""))
|
||||
simple_update_params.merge!(email: params[:email]&.gsub(/\s+/, ""))
|
||||
simple_update_params.merge!(platform: (params[:platform] || 'forge')&.gsub(/\s+/, ""))
|
||||
Register::RemoteForm.new(simple_update_params.merge(user_id: current_user.id)).validate!
|
||||
Register::RemoteForm.new(simple_update_params).validate!
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
result = auto_update(current_user, simple_update_params)
|
||||
if result[:message].blank?
|
||||
UserAction.create(:action_id => current_user.id, :action_type => "sync_educoder_user", :user_id => current_user.id, :ip => request.remote_ip) if params[:platform] == "educoder"
|
||||
render_ok
|
||||
else
|
||||
render_error(result[:message])
|
||||
|
@ -142,7 +141,6 @@ class AccountsController < ApplicationController
|
|||
Register::Form.new(register_params).validate!
|
||||
|
||||
user = Users::RegisterService.call(register_params)
|
||||
user.mail = "#{user.login}@example.org" if user.mail.blank?
|
||||
password = register_params[:password].strip
|
||||
|
||||
# gitea用户注册, email, username, password
|
||||
|
@ -154,18 +152,11 @@ class AccountsController < ApplicationController
|
|||
user.gitea_uid = gitea_user[:body]['id']
|
||||
if user.save!
|
||||
UserExtension.create!(user_id: user.id)
|
||||
# 绑定授权账号
|
||||
if ["qq", "wechat", "gitee", "github", "educoder"].include?(params[:type].to_s) && session[:unionid].present?
|
||||
"OpenUsers::#{params[:type].to_s.capitalize}".constantize.create!(user: user, uid: session[:unionid])
|
||||
end
|
||||
successful_authentication(user)
|
||||
render_ok
|
||||
end
|
||||
elsif interactor.result[:message].to_s.include?("user already exists")
|
||||
UserAction.create(:action_id => 2, :action_type => "register_error", :user_id => user.try(:id).to_i, :ip => "code: #{register_params[:code]}; login: #{register_params[:login]}; namespace: #{register_params[:namespace]}; password: #{password};")
|
||||
normal_status(-1, "用户已注册,请勿连续操作。")
|
||||
else
|
||||
tip_exception(-1, interactor.result[:message])
|
||||
tip_exception(-1, interactor.error)
|
||||
end
|
||||
rescue Register::BaseForm::EmailError => e
|
||||
render_result(-2, e.message)
|
||||
|
@ -180,14 +171,9 @@ class AccountsController < ApplicationController
|
|||
rescue Register::BaseForm::VerifiCodeError => e
|
||||
render_result(-6, e.message)
|
||||
rescue Exception => e
|
||||
if user.present? && !e.message.to_s.include?("user already exists")
|
||||
# Gitea::User::DeleteService.call(user.login)
|
||||
# user.destroy
|
||||
end
|
||||
Rails.logger.error("##:register error--#{user.try(:id)},message:#{e.message}")
|
||||
UserAction.create(:action_id => 1, :action_type => "register_error", :user_id => user.try(:id).to_i, :ip => "code: #{register_params[:code]}; login: #{register_params[:login]}; namespace: #{register_params[:namespace]}; password: #{password};")
|
||||
logger_error(e)
|
||||
tip_exception(-1, "注册失败")
|
||||
Gitea::User::DeleteService.call(user.login) unless user.nil?
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(-1, e.message)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -201,12 +187,12 @@ class AccountsController < ApplicationController
|
|||
return normal_status(-2, "违反平台使用规范,账号已被锁定") if @user.locked?
|
||||
|
||||
login_control = LimitForbidControl::UserLogin.new(@user)
|
||||
return normal_status(-2, "登录密码出错已达上限,账号已被锁定,请#{login_control.forbid_expires/60}分钟后重新登录或找回密码") if login_control.forbid?
|
||||
return normal_status(-2, "登录密码出错已达上限,账号已被锁定, 请#{login_control.forbid_expires/60}分钟后重新登录或找回密码") if login_control.forbid?
|
||||
|
||||
password_ok = @user.check_password?(params[:password].to_s)
|
||||
unless password_ok
|
||||
if login_control.remain_times-1 == 0
|
||||
normal_status(-2, "登录密码出错已达上限,账号已被锁定,请#{login_control.forbid_expires/60}分钟后重新登录或找回密码")
|
||||
normal_status(-2, "登录密码出错已达上限,账号已被锁定, 请#{login_control.forbid_expires/60}分钟后重新登录或找回密码")
|
||||
else
|
||||
normal_status(-2, "你已经输错密码#{login_control.error_times+1}次,还剩余#{login_control.remain_times-1}次机会")
|
||||
end
|
||||
|
@ -214,17 +200,14 @@ class AccountsController < ApplicationController
|
|||
return
|
||||
end
|
||||
|
||||
LimitForbidControl::UserLogin.new(@user).clear
|
||||
successful_authentication(@user)
|
||||
sync_pwd_to_gitea!(@user, {password: params[:password].to_s}) # TODO用户密码未同步
|
||||
|
||||
|
||||
# session[:user_id] = @user.id
|
||||
end
|
||||
|
||||
def change_password
|
||||
return render_error("两次输入的密码不一致") if params[:password].to_s != params[:new_password_repeat].to_s
|
||||
@user = User.find_by(login: params[:login])
|
||||
return render_error("此用户禁止修改密码!") if @user.id.to_i === 104691
|
||||
return render_error("未找到相关用户!") if @user.blank?
|
||||
return render_error("旧密码不正确") unless @user.check_password?(params[:old_password])
|
||||
|
||||
|
@ -335,8 +318,6 @@ class AccountsController < ApplicationController
|
|||
send_type = verify_type(login_type, type)
|
||||
verification_code = code.sample(6).join
|
||||
|
||||
status, message = InfoRiskControlService.call(value, request.remote_ip)
|
||||
tip_exception(420, message) if status == 0
|
||||
sign = Digest::MD5.hexdigest("#{OPENKEY}#{value}")
|
||||
tip_exception(501, "请求不合理") if sign != params[:smscode]
|
||||
|
||||
|
@ -360,17 +341,6 @@ class AccountsController < ApplicationController
|
|||
Register::LoginCheckColumnsForm.new(check_params.merge(user: current_user)).validate!
|
||||
render_ok
|
||||
end
|
||||
|
||||
def check_keywords
|
||||
text = params[:text].to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||
data = ! ReversedKeyword.check_exists?(text)
|
||||
result = {
|
||||
status: 0,
|
||||
data: data,
|
||||
message: data ? "" : "无法使用以下关键词:#{text},请重新命名"
|
||||
}
|
||||
render_ok(result)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
@ -423,7 +393,7 @@ class AccountsController < ApplicationController
|
|||
end
|
||||
|
||||
def register_params
|
||||
params.permit(:login, :namespace, :password, :password_confirmation, :code, :type)
|
||||
params.permit(:login, :namespace, :password, :password_confirmation, :code)
|
||||
end
|
||||
|
||||
def reset_password_params
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
class Action::NodeInputsController < ApplicationController
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_action_node
|
||||
|
||||
def index
|
||||
@node_inputs = @node.action_node_inputs
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@node_input = Action::NodeInput.new(node_input_params)
|
||||
@node_input.action_node = @node
|
||||
respond_to do |format|
|
||||
if @node_input.save
|
||||
format.html { redirect_to action_node_node_inputs_path(@node), notice: '创建成功.' }
|
||||
format.json { render_ok(data: @node_input.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @node_input.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@node_input.update(node_input_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_node_node_inputs_path(@node), notice: '更新成功.' }
|
||||
format.json { render_ok(data: @node_input.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @node_input.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to "api/actions/nodes"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_action_node
|
||||
@node = Action::Node.find(params[:node_id])
|
||||
if params[:id].present?
|
||||
@node_input = @node.action_node_inputs.find(params[:id])
|
||||
else
|
||||
@node_input = Action::NodeInput.new
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def node_input_params
|
||||
if params.require(:action_node_input)
|
||||
params.require(:action_node_input).permit(:name, :input_type, :description, :is_required, :sort_no)
|
||||
else
|
||||
params.permit(:name, :input_type, :description, :is_required, :sort_no)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,76 +0,0 @@
|
|||
class Action::NodeSelectsController < ApplicationController
|
||||
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_action_node
|
||||
|
||||
def index
|
||||
@node_selects = @node.action_node_selects
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@node_select = Action::NodeSelect.new(node_select_params)
|
||||
@node_select.action_node = @node
|
||||
respond_to do |format|
|
||||
if @node_select.save
|
||||
format.html { redirect_to action_node_node_selects_path(@node), notice: '创建成功.' }
|
||||
format.json { render_ok(data: @node_select.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @node_select.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@node_select.update(node_select_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_node_node_selects_path(@node), notice: '更新成功.' }
|
||||
format.json { render_ok(data: @node_select.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @node_select.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to "api/actions/nodes"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_action_node
|
||||
@node = Action::Node.find(params[:node_id])
|
||||
if params[:id].present?
|
||||
@node_select = @node.action_node_selects.find(params[:id])
|
||||
else
|
||||
@node_select = Action::NodeSelect.new
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def node_select_params
|
||||
if params.require(:action_node_select)
|
||||
params.require(:action_node_select).permit(:name, :val, :val_ext, :description, :sort_no)
|
||||
else
|
||||
params.permit(:name, :val, :val_ext, :description, :sort_no)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,64 +0,0 @@
|
|||
class Action::NodeTypesController < ApplicationController
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_node_type, except: [:index, :create, :new]
|
||||
|
||||
def index
|
||||
@node_types = Action::NodeType.all
|
||||
end
|
||||
|
||||
def create
|
||||
@node_type = Action::NodeType.new(node_types_params)
|
||||
respond_to do |format|
|
||||
if @node_type.save
|
||||
format.html { redirect_to action_node_types_path, notice: '创建成功.' }
|
||||
format.json { render_ok(data: @node_type.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @node_type.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@node_type = Action::NodeType.new
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@node_type.update(node_types_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_node_types_path, notice: '更新成功.' }
|
||||
format.json { render_ok(data: @node_type.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @node_type.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to action_node_types_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_node_type
|
||||
@node_type = Action::NodeType.find(params[:id])
|
||||
end
|
||||
|
||||
def node_types_params
|
||||
if params.require(:action_node_type)
|
||||
params.require(:action_node_type).permit(:name, :description, :sort_no)
|
||||
else
|
||||
params.permit(:name, :description, :sort_no)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,69 +0,0 @@
|
|||
class Action::NodesController < ApplicationController
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_action_node, except: [:index, :create, :new]
|
||||
|
||||
def index
|
||||
@node_types = Action::NodeType.all
|
||||
@no_type_nodes = Action::Node.where(action_node_types_id: nil)
|
||||
respond_to do |format|
|
||||
format.html { @nodes = Action::Node.all }
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@node = Action::Node.new(node_params)
|
||||
respond_to do |format|
|
||||
if @node.save
|
||||
format.html { redirect_to action_nodes_path, notice: '创建成功.' }
|
||||
format.json { render_ok(data: @node.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @node.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@node = Action::Node.new
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@node.update(node_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_nodes_path, notice: '更新成功.' }
|
||||
format.json { render_ok(data: @node.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @node.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to action_nodes_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_action_node
|
||||
@node = Action::Node.find(params[:id])
|
||||
end
|
||||
|
||||
def node_params
|
||||
if params.require(:action_node)
|
||||
params.require(:action_node).permit(:name, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no)
|
||||
else
|
||||
params.permit(:name, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,68 +0,0 @@
|
|||
class Action::TemplatesController < ApplicationController
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_action_template, except: [:index, :create, :new]
|
||||
|
||||
def index
|
||||
@templates = Action::Template.all
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@template = Action::Template.new(templates_params)
|
||||
respond_to do |format|
|
||||
if @template.save
|
||||
format.html { redirect_to action_templates_path, notice: '创建成功.' }
|
||||
format.json { render_ok(data: @template.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @template.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@template = Action::Template.new
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@template.update(templates_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_templates_path, notice: '更新成功.' }
|
||||
format.json { render_ok(data: @template.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @template.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to action_templates_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_action_template
|
||||
@template = Action::Template.find(params[:id])
|
||||
end
|
||||
|
||||
def templates_params
|
||||
if params.require(:action_template)
|
||||
params.require(:action_template).permit(:name, :description, :img, :sort_no, :json, :yaml)
|
||||
else
|
||||
params.permit(:name, :description, :img, :sort_no, :json, :yaml)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -23,23 +23,10 @@ class Admins::BaseController < ApplicationController
|
|||
def require_admin!
|
||||
return if current_user.blank? || !current_user.logged?
|
||||
return if current_user.admin_or_business?
|
||||
return if current_user.admin_or_glcc_admin?
|
||||
|
||||
render_forbidden
|
||||
end
|
||||
|
||||
def require_admin
|
||||
render_forbidden unless User.current.admin?
|
||||
end
|
||||
|
||||
def require_business
|
||||
render_forbidden unless admin_or_business?
|
||||
end
|
||||
|
||||
def require_glcc_admin
|
||||
render_forbidden unless admin_or_glcc_admin?
|
||||
end
|
||||
|
||||
# 触发after ajax render partial hooks,执行一些因为局部刷新后失效的绑定事件
|
||||
def rebind_event_if_ajax_render_partial
|
||||
return if request.format.symbol != :js
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
class Admins::DashboardsController < Admins::BaseController
|
||||
def index
|
||||
# 查询优化
|
||||
week_greater_id = CommitLog.where(created_at: current_week).limit(1)[0]&.id
|
||||
#月份统计还需要优化
|
||||
month_greater_id = CommitLog.where(created_at: current_month).limit(1)[0]&.id
|
||||
# 用户活跃数
|
||||
day_user_ids = CommitLog.where(created_at: today).pluck(:user_id).uniq
|
||||
weekly_user_ids = CommitLog.where(created_at: current_week).where("id>= ?", week_greater_id).distinct.pluck(:user_id)
|
||||
month_user_ids = CommitLog.where(created_at: current_month).where("id>= ?", month_greater_id).distinct.pluck(:user_id)
|
||||
weekly_user_ids = CommitLog.where(created_at: current_week).pluck(:user_id).uniq
|
||||
month_user_ids = CommitLog.where(created_at: current_month).pluck(:user_id).uniq
|
||||
@active_user_count = User.where(last_login_on: today).or(User.where(id: day_user_ids)).count
|
||||
@weekly_active_user_count = User.where(last_login_on: current_week).or(User.where(id: weekly_user_ids)).count
|
||||
@month_active_user_count = User.where(last_login_on: current_month).or(User.where(id: month_user_ids)).count
|
||||
|
@ -22,78 +18,16 @@ class Admins::DashboardsController < Admins::BaseController
|
|||
|
||||
# 活跃项目数
|
||||
day_project_ids = (CommitLog.where(created_at: today).pluck(:project_id).uniq + Issue.where(created_on: today).pluck(:project_id).uniq).uniq
|
||||
weekly_project_ids = (CommitLog.where(created_at: current_week).where("id>= ?", week_greater_id).distinct.pluck(:project_id) + Issue.where(created_on: current_week).pluck(:project_id).uniq).uniq
|
||||
month_project_ids = (CommitLog.where(created_at: current_month).where("id>= ?", month_greater_id).distinct.pluck(:project_id) + Issue.where(created_on: current_month).pluck(:project_id).uniq).uniq
|
||||
weekly_project_ids = (CommitLog.where(created_at: current_week).pluck(:project_id).uniq + Issue.where(created_on: current_week).pluck(:project_id).uniq).uniq
|
||||
month_project_ids = (CommitLog.where(created_at: current_month).pluck(:project_id).uniq + Issue.where(created_on: current_month).pluck(:project_id).uniq).uniq
|
||||
@day_active_project_count = Project.where(updated_on: today).or(Project.where(id: day_project_ids)).count
|
||||
@weekly_active_project_count = Rails.cache.fetch("dashboardscontroller:weekly_active_project_count", expires_in: 10.minutes) do
|
||||
Project.where(updated_on: current_week).or(Project.where(id: weekly_project_ids)).count
|
||||
end
|
||||
@month_active_project_count = Rails.cache.fetch("dashboardscontroller:month_active_project_count", expires_in: 1.hours) do
|
||||
Project.where(updated_on: current_month).or(Project.where(id: month_project_ids)).count
|
||||
end
|
||||
@weekly_active_project_count = Project.where(updated_on: current_week).or(Project.where(id: weekly_project_ids)).count
|
||||
@month_active_project_count = Project.where(updated_on: current_month).or(Project.where(id: month_project_ids)).count
|
||||
|
||||
# 新增项目数
|
||||
@day_new_project_count = Rails.cache.fetch("dashboardscontroller:day_new_project_count", expires_in: 10.minutes) do
|
||||
Project.where(created_on: today).count
|
||||
end
|
||||
@weekly_new_project_count = Rails.cache.fetch("dashboardscontroller:weekly_new_project_count", expires_in: 10.minutes) do
|
||||
Project.where(created_on: current_week).count
|
||||
end
|
||||
@month_new_project_count = Rails.cache.fetch("dashboardscontroller:month_new_project_count", expires_in: 1.hours) do
|
||||
Project.where(created_on: current_month).count
|
||||
end
|
||||
|
||||
|
||||
# 总的平台用户数
|
||||
# 总的平台项目数
|
||||
# 总的平台组织数
|
||||
# 总的平台Issue数、评论数、PR数、Commit数
|
||||
@user_count = Rails.cache.fetch("dashboardscontroller:platform:user_count", expires_in: 1.days) do
|
||||
User.count
|
||||
end
|
||||
@project_count = Rails.cache.fetch("dashboardscontroller:platform:project_count", expires_in: 1.days) do
|
||||
Project.count
|
||||
end
|
||||
@organization_count = Rails.cache.fetch("dashboardscontroller:platform:organization_count", expires_in: 1.days) do
|
||||
Organization.count
|
||||
end
|
||||
@issue_count = Rails.cache.fetch("dashboardscontroller:platform:issue_count", expires_in: 1.days) do
|
||||
Issue.count
|
||||
end
|
||||
@comment_count = Rails.cache.fetch("dashboardscontroller:platform:comment_count", expires_in: 1.days) do
|
||||
Journal.count
|
||||
end
|
||||
@pr_count = Rails.cache.fetch("dashboardscontroller:platform:pr_count", expires_in: 1.days) do
|
||||
PullRequest.count
|
||||
end
|
||||
@commit_count = Rails.cache.fetch("dashboardscontroller:platform:commit_count", expires_in: 1.days) do
|
||||
CommitLog.count
|
||||
end
|
||||
|
||||
@subject_name = ["用户数", "项目数", "组织数", "Issue数", "Issue评论数", "PR数", "Commit数"]
|
||||
@subject_icon = ["fa-user","fa-git", "fa-sitemap", "fa-warning", "fa-comments", "fa-share-alt", "fa-upload"]
|
||||
@subject_data = [@user_count, @project_count, @organization_count, @issue_count, @comment_count, @pr_count, @commit_count]
|
||||
|
||||
|
||||
tongji_service = Baidu::TongjiService.new
|
||||
@access_token = tongji_service.access_token
|
||||
Rails.logger.info "baidu_tongji_auth access_token ===== #{@access_token}"
|
||||
# @overview_data = tongji_service.api_overview
|
||||
last_date = DailyPlatformStatistic.order(:date).last
|
||||
start_date = last_date.date
|
||||
end_date = Time.now
|
||||
if @access_token.present?
|
||||
@overview_data = Rails.cache.fetch("dashboardscontroller:baidu_tongji:overview_data", expires_in: 10.minutes) do
|
||||
tongji_service.source_from_batch_add(start_date, end_date)
|
||||
@overview_data = tongji_service.overview_batch_add(start_date, end_date)
|
||||
@overview_data
|
||||
end
|
||||
end
|
||||
|
||||
@current_week_statistic = DailyPlatformStatistic.where(date: current_week)
|
||||
@pre_week_statistic = DailyPlatformStatistic.where(date: pre_week)
|
||||
|
||||
|
||||
|
||||
@day_new_project_count = Project.where(created_on: today).count
|
||||
@weekly_new_project_count = Project.where(created_on: current_week).count
|
||||
@month_new_project_count = Project.where(created_on: current_month).count
|
||||
end
|
||||
|
||||
def month_active_user
|
||||
|
@ -108,19 +42,6 @@ class Admins::DashboardsController < Admins::BaseController
|
|||
render_ok(data: data)
|
||||
end
|
||||
|
||||
def baidu_tongji
|
||||
tongji_service = Baidu::TongjiService.new
|
||||
redirect_to tongji_service.code_url
|
||||
end
|
||||
|
||||
def baidu_tongji_auth
|
||||
if params[:code].present?
|
||||
tongji_service = Baidu::TongjiService.new
|
||||
tongji_service.get_access_token(params[:code])
|
||||
end
|
||||
redirect_to "/admins/"
|
||||
end
|
||||
|
||||
def evaluate
|
||||
names = []
|
||||
data = []
|
||||
|
@ -142,12 +63,8 @@ class Admins::DashboardsController < Admins::BaseController
|
|||
Time.now.beginning_of_day..Time.now.end_of_day
|
||||
end
|
||||
|
||||
def pre_7_days
|
||||
7.days.ago.end_of_day..Time.now.end_of_day
|
||||
end
|
||||
|
||||
def current_week
|
||||
Time.now.beginning_of_week..Time.now.end_of_day
|
||||
7.days.ago.end_of_day..Time.now.end_of_day
|
||||
end
|
||||
|
||||
def current_month
|
||||
|
@ -155,7 +72,6 @@ class Admins::DashboardsController < Admins::BaseController
|
|||
end
|
||||
|
||||
def pre_week
|
||||
# 14.days.ago.end_of_day..7.days.ago.end_of_day
|
||||
Time.now.prev_week..Time.now.prev_week.end_of_week
|
||||
14.days.ago.end_of_day..7.days.ago.end_of_day
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::EduSettingsController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :find_setting, only: [:edit,:update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::FaqsController < Admins::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_faq, only: [:edit,:update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
class Admins::FeedbacksController < Admins::BaseController
|
||||
before_action :require_business
|
||||
before_action :get_feedback, only: [:new_history, :create_history, :destroy]
|
||||
|
||||
def index
|
||||
sort_by = Feedback.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
|
||||
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
|
||||
feedbacks = Feedback.order("#{sort_by} #{sort_direction}")
|
||||
@feedbacks = paginate(feedbacks)
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @feedback.destroy
|
||||
redirect_to admins_feedbacks_path
|
||||
flash[:success] = "反馈意见删除成功"
|
||||
else
|
||||
redirect_to admins_feedbacks_path
|
||||
flash[:danger] = "反馈意见删除失败"
|
||||
end
|
||||
end
|
||||
|
||||
def new_history
|
||||
@feedback_message_history = FeedbackMessageHistory.new
|
||||
end
|
||||
|
||||
def create_history
|
||||
@feedback_message_history = @feedback.feedback_message_histories.new(feedback_message_history_params)
|
||||
@feedback_message_history.user = current_user
|
||||
if @feedback_message_history.save
|
||||
redirect_to admins_feedbacks_path
|
||||
flash[:success] = "发送通知成功"
|
||||
else
|
||||
redirect_to admins_feedbacks_path
|
||||
flash[:danger] = @feedback_message_history.errors.full_messages.join(", ")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def feedback_params
|
||||
params.require(:feedback).permit!
|
||||
end
|
||||
|
||||
def feedback_message_history_params
|
||||
params.require(:feedback_message_history).permit(:title, :content)
|
||||
end
|
||||
|
||||
def get_feedback
|
||||
@feedback = Feedback.find_by_id(params[:id])
|
||||
end
|
||||
end
|
|
@ -1,34 +0,0 @@
|
|||
class Admins::GlccPrCheckController < Admins::BaseController
|
||||
before_action :require_glcc_admin
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_on'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
examine_materials = Admins::GlccExamineMaterial.call(params)
|
||||
@examine_materials = paginate examine_materials.includes(:glcc_student)
|
||||
end
|
||||
|
||||
def send_mail
|
||||
year = if params[:date].present?
|
||||
params[:date][:year]
|
||||
end
|
||||
if year.nil?
|
||||
return redirect_to admins_glcc_pr_check_index_path
|
||||
flash[:error] = "时间不能为空"
|
||||
end
|
||||
if params[:term].blank?
|
||||
return redirect_to admins_glcc_pr_check_index_path
|
||||
flash[:error] = "考核选项不能为空"
|
||||
end
|
||||
|
||||
examine_materials = GlccMediumTermExamineMaterial.where(\
|
||||
term: params[:term],
|
||||
created_on: [Time.now.change(year:year).beginning_of_year .. Time.now.change(year:year).end_of_year]
|
||||
)
|
||||
examine_materials.map{ |e|
|
||||
e.send_mail
|
||||
}
|
||||
flash[:danger] = "#{year} 年 #{params[:term].to_i == 1 ? "中期考核": "结项考核"} PR 检测邮件已全部发送完毕,一共#{examine_materials.count}封邮件"
|
||||
redirect_to admins_glcc_pr_check_index_path
|
||||
end
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
class Admins::IdentityVerificationsController < Admins::BaseController
|
||||
before_action :require_business
|
||||
before_action :finder_identity_verification, except: [:index]
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
identity_verifications = Admins::IdentityVerificationQuery.call(params)
|
||||
@identity_verifications = paginate identity_verifications.preload(:user)
|
||||
end
|
||||
|
||||
def show
|
||||
render 'edit'
|
||||
end
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if update_params[:state] == "已拒绝" && update_params[:description].blank?
|
||||
flash[:danger] = '拒绝理由不能为空'
|
||||
render 'edit'
|
||||
else
|
||||
UserAction.create(action_id: @identity_verification.id, action_type: "UpdateIdentityVerifications", user_id: current_user.id, :ip => request.remote_ip, data_bank: @identity_verification.attributes.to_json)
|
||||
@identity_verification.update(update_params)
|
||||
redirect_to admins_identity_verifications_path
|
||||
flash[:success] = "更新成功"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def finder_identity_verification
|
||||
@identity_verification = IdentityVerification.find(params[:id])
|
||||
@user = @identity_verification.user
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:identity_verification).permit(:state, :description)
|
||||
end
|
||||
end
|
|
@ -1,30 +0,0 @@
|
|||
class Admins::IssuesRankController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
|
||||
def index
|
||||
@statistics = DailyProjectStatistic.where('date >= ? AND date <= ?', begin_date, end_date)
|
||||
@statistics = @statistics.group(:project_id).joins(:project).select("project_id,
|
||||
sum(issues) as issues,
|
||||
sum(closed_issues) as closed_issues,
|
||||
projects.issues_count as issues_count")
|
||||
@statistics = @statistics.order("#{sort_by} #{sort_direction}").limit(50)
|
||||
end
|
||||
|
||||
private
|
||||
def begin_date
|
||||
params.fetch(:begin_date, (Date.yesterday-7.days).to_s)
|
||||
end
|
||||
|
||||
def end_date
|
||||
params.fetch(:end_date, Date.yesterday.to_s)
|
||||
end
|
||||
|
||||
def sort_by
|
||||
DailyProjectStatistic.column_names.include?(params.fetch(:sort_by, "issues")) ? params.fetch(:sort_by, "issues") : "issues"
|
||||
end
|
||||
|
||||
def sort_direction
|
||||
%w(desc asc).include?(params.fetch(:sort_direction, "desc")) ? params.fetch(:sort_direction, "desc") : "desc"
|
||||
end
|
||||
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::LaboratoriesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
def index
|
||||
default_sort('id', 'desc')
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ class Admins::LaboratorySettingsController < Admins::BaseController
|
|||
params.permit(:identifier, :name,
|
||||
:nav_logo, :login_logo, :tab_logo, :oj_banner,
|
||||
:subject_banner, :course_banner, :competition_banner, :moop_cases_banner,
|
||||
:footer, navbar: %i[name link hidden index])
|
||||
:footer, navbar: %i[name link hidden])
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::MessageTemplatesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :get_template, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
@ -8,12 +7,12 @@ class Admins::MessageTemplatesController < Admins::BaseController
|
|||
end
|
||||
|
||||
def new
|
||||
@message_template = MessageTemplate::CustomTip.new
|
||||
@message_template = MessageTemplate.new
|
||||
end
|
||||
|
||||
def create
|
||||
@message_template = MessageTemplate::CustomTip.new
|
||||
@message_template.attributes = message_template_params
|
||||
def create
|
||||
@message_template = MessageTemplate::CustomTip.new(message_template_params)
|
||||
@message_template.type = "MessageTemplate::CustomTip"
|
||||
if @message_template.save!
|
||||
redirect_to admins_message_templates_path
|
||||
flash[:success] = "创建消息模板成功"
|
||||
|
@ -48,7 +47,9 @@ class Admins::MessageTemplatesController < Admins::BaseController
|
|||
|
||||
private
|
||||
def message_template_params
|
||||
params.require(@message_template.type.split("::").join("_").underscore.to_sym).permit!
|
||||
# type = @message_template.present? ? @message_template.type : "MessageTemplate::CustomTip"
|
||||
# params.require(type.split("::").join("_").underscore.to_sym).permit!
|
||||
params.require(:message_template).permit!
|
||||
end
|
||||
|
||||
def get_template
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::NpsController < Admins::BaseController
|
||||
before_action :require_business
|
||||
def index
|
||||
@on_off_switch = EduSetting.get("nps-on-off-switch").to_s == 'true'
|
||||
@user_nps = UserNp.joins(:user).order(created_at: :desc)
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
class Admins::OrganizationsController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :finder_org, except: [:index]
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_on'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
|
||||
orgs = Admins::OrganizationQuery.call(params)
|
||||
@orgs = paginate orgs
|
||||
end
|
||||
|
||||
|
||||
def open_cla
|
||||
@org.open_cla!
|
||||
render_ok
|
||||
end
|
||||
|
||||
def close_cla
|
||||
if @org.cla.nil?
|
||||
@org.close_cla!
|
||||
render_ok
|
||||
else
|
||||
render_error(' 该组织已创建CLA 不允许关闭')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def destroy
|
||||
@org.destroy!
|
||||
Admins::DeleteOrganizationService.call(@org.login)
|
||||
UserAction.create(action_id: @org.id, action_type: "DestroyOrganization", user_id: current_user.id, :ip => request.remote_ip, data_bank: @org.attributes.to_json)
|
||||
render_delete_success
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def finder_org
|
||||
@org = Organization.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
|
@ -1,80 +0,0 @@
|
|||
class Admins::PageThemesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :finder_page_theme, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
|
||||
page_themes = Admins::PageThemesQuery.call(params)
|
||||
|
||||
@page_themes = paginate page_themes
|
||||
end
|
||||
|
||||
def show
|
||||
render 'edit'
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@page_theme = PageTheme.new theme_params
|
||||
if @page_theme.save
|
||||
save_image_file(params[:image])
|
||||
redirect_to admins_page_themes_path
|
||||
flash[:success] = "新增主题成功"
|
||||
else
|
||||
redirect_to admins_page_themes_path
|
||||
flash[:danger] = "新增主题失败: #{@page_theme.errors.messages.values.flatten.join(',')}"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if PageTheme.where(language_frame: @page_theme.language_frame).count <= 1
|
||||
flash[:danger] = "删除主题失败,必须存在一个主题"
|
||||
return redirect_to admins_page_themes_path
|
||||
end
|
||||
|
||||
if @page_theme.destroy
|
||||
redirect_to admins_page_themes_path
|
||||
flash[:success] = "删除主题成功"
|
||||
else
|
||||
redirect_to admins_page_themes_path
|
||||
flash[:danger] = "删除主题失败"
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@page_theme = PageTheme.new
|
||||
end
|
||||
|
||||
def update
|
||||
@page_theme.attributes = theme_params
|
||||
if @page_theme.save
|
||||
save_image_file(params[:image])
|
||||
redirect_to admins_page_themes_path
|
||||
flash[:success] = "更新成功"
|
||||
else
|
||||
redirect_to admins_page_themes_path
|
||||
flash[:danger] = "更新失败"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def finder_page_theme
|
||||
@page_theme = PageTheme.find(params[:id])
|
||||
end
|
||||
|
||||
def theme_params
|
||||
params.require(:page_theme).permit(:language_frame, :name, :cate, :image_url, :clone_url, :order_index)
|
||||
end
|
||||
|
||||
def save_image_file(file)
|
||||
return unless file.present? && file.is_a?(ActionDispatch::Http::UploadedFile)
|
||||
file_path = Util::FileManage.source_disk_filename(@page_theme, "image")
|
||||
File.delete(file_path) if File.exist?(file_path) # 删除之前的文件
|
||||
Util.write_file(file, file_path)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::ProjectCategoriesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :get_category, only: [:edit,:update, :destroy]
|
||||
before_action :validate_names, only: [:create, :update]
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::ProjectIgnoresController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :set_ignore, only: [:edit,:update, :destroy,:show]
|
||||
# before_action :validate_params, only: [:create, :update]
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::ProjectLanguagesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :get_language, only: [:edit,:update, :destroy]
|
||||
before_action :validate_names, only: [:create, :update]
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::ProjectLicensesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :set_license, only: [:edit,:update, :destroy,:show]
|
||||
# before_action :validate_params, only: [:create, :update]
|
||||
|
||||
|
@ -7,7 +6,7 @@ class Admins::ProjectLicensesController < Admins::BaseController
|
|||
sort_by = License.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
|
||||
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
|
||||
q = License.ransack(name_cont: params[:search])
|
||||
project_licenses = q.result(distinct: true).reorder("#{sort_by} #{sort_direction}")
|
||||
project_licenses = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
|
||||
@project_licenses = paginate(project_licenses)
|
||||
end
|
||||
|
||||
|
@ -96,7 +95,7 @@ class Admins::ProjectLicensesController < Admins::BaseController
|
|||
end
|
||||
|
||||
def license_params
|
||||
params.require(:license).permit(:name,:content,:position)
|
||||
params.require(:license).permit(:name,:content)
|
||||
end
|
||||
|
||||
# def validate_params
|
||||
|
|
|
@ -1,22 +1,11 @@
|
|||
class Admins::ProjectsController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :find_project, only: [:edit, :update]
|
||||
|
||||
def index
|
||||
sort_by = Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_on'
|
||||
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
|
||||
search = params[:search].to_s.strip
|
||||
projects = Project.where("name like ? OR identifier LIKE ?", "%#{search}%", "%#{search}%").order("#{sort_by} #{sort_direction}")
|
||||
case params[:category]
|
||||
when 'public'
|
||||
projects = projects.where(is_public: true)
|
||||
when 'private'
|
||||
projects = projects.where(is_public: false)
|
||||
when 'fork'
|
||||
projects = projects.where.not(forked_from_project_id: nil)
|
||||
when 'original'
|
||||
projects = projects.where(forked_from_project_id: nil, project_type: 'common')
|
||||
end
|
||||
projects = Project.where("name like ?", "%#{search}%").order("#{sort_by} #{sort_direction}")
|
||||
@projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score)
|
||||
end
|
||||
|
||||
|
@ -43,14 +32,9 @@ class Admins::ProjectsController < Admins::BaseController
|
|||
def destroy
|
||||
project = Project.find_by!(id: params[:id])
|
||||
ActiveRecord::Base.transaction do
|
||||
close_fork_pull_requests_by(project)
|
||||
Gitea::Repository::DeleteService.new(project.owner, project.identifier, current_user.gitea_token).call
|
||||
Gitea::Repository::DeleteService.new(project.owner, project.identifier).call
|
||||
project.destroy!
|
||||
project.forked_projects.update_all(forked_from_project_id: nil)
|
||||
# 如果该项目有所属的项目分类以及为私有项目,需要更新对应数量
|
||||
project.project_category.decrement!(:private_projects_count, 1) if project.project_category.present? && !project.is_public
|
||||
# render_delete_success
|
||||
UserAction.create(action_id: project.id, action_type: "DestroyProject", user_id: current_user.id, :ip => request.remote_ip, data_bank: project.attributes.to_json)
|
||||
redirect_to admins_projects_path
|
||||
flash[:success] = "删除成功"
|
||||
end
|
||||
|
@ -67,19 +51,4 @@ class Admins::ProjectsController < Admins::BaseController
|
|||
def project_update_params
|
||||
params.require(:project).permit(:is_pinned, :recommend, :recommend_index)
|
||||
end
|
||||
|
||||
def close_fork_pull_requests_by(project)
|
||||
open_pull_requests = PullRequest.where(fork_project_id: project.id)
|
||||
if open_pull_requests.present?
|
||||
open_pull_requests.each do |pull_request|
|
||||
closed = PullRequests::CloseService.call(pull_request&.project.owner, pull_request&.project.repository, pull_request, current_user)
|
||||
if closed === true
|
||||
pull_request.project_trends.create!(user: current_user, project: pull_request&.project,action_type: ProjectTrend::CLOSE)
|
||||
# 合并请求下issue处理为关闭
|
||||
pull_request.issue&.update_attributes!({status_id:5})
|
||||
SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, pull_request.id) if Site.has_notice_menu?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,57 +0,0 @@
|
|||
class Admins::ProjectsRankController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
|
||||
def index
|
||||
@statistics = DailyProjectStatistic.where("date >= ? AND date <= ?", begin_date, end_date)
|
||||
@statistics = @statistics.group(:project_id).select("project_id,
|
||||
sum(score) as score,
|
||||
sum(visits) as visits,
|
||||
sum(watchers) as watchers,
|
||||
sum(praises) as praises,
|
||||
sum(forks) as forks,
|
||||
sum(issues) as issues,
|
||||
sum(pullrequests) as pullrequests,
|
||||
sum(commits) as commits").includes(:project)
|
||||
@statistics = paginate @statistics.order("#{sort_by} #{sort_direction}")
|
||||
export_excel(@statistics.limit(50))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def begin_date
|
||||
params.fetch(:begin_date, (Date.yesterday-7.days).to_s)
|
||||
end
|
||||
|
||||
def end_date
|
||||
params.fetch(:end_date, Date.yesterday.to_s)
|
||||
end
|
||||
|
||||
def sort_by
|
||||
DailyProjectStatistic.column_names.include?(params.fetch(:sort_by, "score")) ? params.fetch(:sort_by, "score") : "score"
|
||||
end
|
||||
|
||||
def sort_direction
|
||||
%w(desc asc).include?(params.fetch(:sort_direction, "desc")) ? params.fetch(:sort_direction, "desc") : "desc"
|
||||
end
|
||||
|
||||
def export_excel(data)
|
||||
book = Spreadsheet::Workbook.new
|
||||
sheet = book.create_worksheet :name => "项目活跃度排行"
|
||||
sheet.row(0).concat %w(排名 项目全称 项目地址 得分 访问数 关注数 点赞数 fork数 疑修数 合并请求数 提交数)
|
||||
data.each_with_index do |d, index|
|
||||
sheet[index+1,0] = index+1
|
||||
sheet[index+1,1] = "#{d&.project&.owner&.real_name}/#{d&.project&.name}"
|
||||
sheet[index+1,2] = "#{Rails.application.config_for(:configuration)['platform_url']}/#{d&.project&.owner&.login}/#{d&.project&.identifier}"
|
||||
sheet[index+1,3] = d.score
|
||||
sheet[index+1,4] = d.visits
|
||||
sheet[index+1,5] = d.watchers
|
||||
sheet[index+1,6] = d.praises
|
||||
sheet[index+1,7] = d.forks
|
||||
sheet[index+1,8] = d.issues
|
||||
sheet[index+1,9] = d.pullrequests
|
||||
sheet[index+1,10] = d.commits
|
||||
end
|
||||
book.write "#{Rails.root}/public/项目活跃度排行.xls"
|
||||
end
|
||||
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::ReversedKeywordsController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :get_keyword, only: [:edit,:update, :destroy]
|
||||
# before_action :validate_identifer, only: [:create, :update]
|
||||
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
class Admins::SitePagesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :finder_site_page, except: [:index]
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
|
||||
pages = Admins::SitePagesQuery.call(params)
|
||||
|
||||
@site_pages = paginate pages.preload(:user)
|
||||
end
|
||||
|
||||
def show
|
||||
render 'edit'
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
if @site_page.destroy
|
||||
redirect_to admins_site_pages_path
|
||||
flash[:success] = "删除站点成功"
|
||||
else
|
||||
redirect_to admins_site_pages_path
|
||||
flash[:danger] = "删除站点失败"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if update_params[:state] == "false" && update_params[:state_description].blank?
|
||||
flash[:danger] = '关闭站点理由不能为空'
|
||||
else
|
||||
@site_page.update(update_params)
|
||||
flash[:success] = '保存成功'
|
||||
end
|
||||
render 'edit'
|
||||
end
|
||||
|
||||
private
|
||||
def finder_site_page
|
||||
@site_page = Page.find(params[:id])
|
||||
@user = @site_page.user
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:page).permit(:state, :state_description)
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::SitesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :find_site, only: [:edit,:update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::SystemNotificationsController < Admins::BaseController
|
||||
before_action :require_business
|
||||
before_action :get_notification, only: [:history, :edit,:update, :destroy]
|
||||
# before_action :validate_identifer, only: [:create, :update]
|
||||
|
||||
|
@ -26,7 +25,7 @@ class Admins::SystemNotificationsController < Admins::BaseController
|
|||
@notification = SystemNotification.new(notification_params)
|
||||
if @notification.save
|
||||
redirect_to admins_system_notifications_path
|
||||
flash[:success] = '系统公告创建成功'
|
||||
flash[:success] = '系统消息创建成功'
|
||||
else
|
||||
redirect_to admins_system_notifications_path
|
||||
flash[:danger] = @notification.errors.full_messages.join(",")
|
||||
|
@ -38,7 +37,7 @@ class Admins::SystemNotificationsController < Admins::BaseController
|
|||
if @notification.update_attributes(notification_params)
|
||||
format.html do
|
||||
redirect_to admins_system_notifications_path
|
||||
flash[:success] = '系统公告更新成功'
|
||||
flash[:success] = '系统消息更新成功'
|
||||
end
|
||||
format.js {render_ok}
|
||||
else
|
||||
|
@ -54,10 +53,10 @@ class Admins::SystemNotificationsController < Admins::BaseController
|
|||
def destroy
|
||||
if @notification.destroy
|
||||
redirect_to admins_system_notifications_path
|
||||
flash[:success] = "系统公告删除成功"
|
||||
flash[:success] = "系统消息删除成功"
|
||||
else
|
||||
redirect_to admins_system_notifications_path
|
||||
flash[:danger] = "系统公告删除失败"
|
||||
flash[:danger] = "系统消息删除失败"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::Topic::ActivityForumsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_activity_forum, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::Topic::BannersController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_banner, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
@ -54,6 +53,6 @@ class Admins::Topic::BannersController < Admins::Topic::BaseController
|
|||
end
|
||||
|
||||
def banner_params
|
||||
params.require(:topic_banner).permit(:title, :order_index, :url)
|
||||
params.require(:topic_banner).permit(:title, :order_index)
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::Topic::CardsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_card, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::Topic::CooperatorsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_cooperator, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::Topic::ExcellentProjectsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_excellent_project, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::Topic::ExperienceForumsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_experience_forum, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::Topic::GlccNewsController < Admins::Topic::BaseController
|
||||
before_action :require_glcc_admin
|
||||
before_action :find_glcc, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Admins::Topic::PinnedForumsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_pinned_forum, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class Admins::UsersController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :finder_user, except: [:index]
|
||||
before_action :finder_user, except: [:index]
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_on'
|
||||
|
@ -26,16 +25,15 @@ class Admins::UsersController < Admins::BaseController
|
|||
end
|
||||
|
||||
def destroy
|
||||
UserAction.create(action_id: @user.id, action_type: "DestroyUser", user_id: current_user.id, :ip => request.remote_ip, data_bank: @user.attributes.to_json)
|
||||
@user.destroy!
|
||||
Gitea::User::DeleteService.call(@user.login)
|
||||
|
||||
|
||||
render_delete_success
|
||||
end
|
||||
|
||||
def lock
|
||||
@user.lock!
|
||||
UserAction.create(action_id: @user.id, action_type: "LockUser", user_id: current_user.id, :ip => request.remote_ip)
|
||||
|
||||
render_ok
|
||||
end
|
||||
|
||||
|
@ -59,12 +57,6 @@ class Admins::UsersController < Admins::BaseController
|
|||
render_ok
|
||||
end
|
||||
|
||||
|
||||
def fresh_gitea_token
|
||||
@user.fresh_gitea_token
|
||||
render_ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def finder_user
|
||||
|
@ -72,8 +64,8 @@ class Admins::UsersController < Admins::BaseController
|
|||
end
|
||||
|
||||
def update_params
|
||||
params.require(:user).permit(%i[lastname nickname gender technical_title is_shixun_marker
|
||||
mail phone location location_city school_id department_id admin
|
||||
password login website_permission business glcc_admin])
|
||||
params.require(:user).permit(%i[lastname nickname gender identity technical_title student_id is_shixun_marker
|
||||
mail phone location location_city school_id department_id admin business is_test
|
||||
password professional_certification authentication login])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
class Admins::UsersRankController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
|
||||
def index
|
||||
@rank_date = rank_date
|
||||
@date_rank = $redis_cache.zrevrange("v2-user-rank-#{rank_date}", 0, -1, withscores: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def rank_date
|
||||
params.fetch(:date, Date.today.to_s)
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -20,19 +20,10 @@ class Api::V1::BaseController < ApplicationController
|
|||
# User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
||||
# end
|
||||
# end
|
||||
|
||||
def kaminary_select_paginate(relation)
|
||||
limit = params[:limit] || params[:per_page]
|
||||
limit = (limit.to_i.zero? || limit.to_i > 200) ? 200 : limit.to_i
|
||||
page = params[:page].to_i.zero? ? 1 : params[:page].to_i
|
||||
|
||||
relation.page(page).per(limit)
|
||||
end
|
||||
|
||||
def limit
|
||||
params.fetch(:limit, 15)
|
||||
end
|
||||
|
||||
def page
|
||||
params.fetch(:page, 1)
|
||||
end
|
||||
|
@ -52,14 +43,10 @@ class Api::V1::BaseController < ApplicationController
|
|||
# 具有仓库的操作权限或者fork仓库的操作权限
|
||||
def require_operate_above_or_fork_project
|
||||
@project = load_project
|
||||
puts !current_user.admin? && !@project.operator?(current_user) && !(@project.fork_project.present? && @project.fork_project.operator?(current_user))
|
||||
return render_forbidden if !current_user.admin? && !@project.operator?(current_user) && !(@project.fork_project.present? && @project.fork_project.operator?(current_user))
|
||||
end
|
||||
|
||||
def require_member_above
|
||||
@project = load_project
|
||||
return render_forbidden if !current_user.admin? && !@project.member?(current_user)
|
||||
end
|
||||
|
||||
# 具有对仓库的访问权限
|
||||
def require_public_and_member_above
|
||||
@project = load_project
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
class Api::V1::GitlinkCompetitionAppliesController < Api::V1::BaseController
|
||||
|
||||
def create
|
||||
return render_error("请输入正确的竞赛ID") unless params[:competition_id].present?
|
||||
return render_error("请输入正确的队伍ID") unless params[:team_id].present?
|
||||
return render_error("请输入正确的队伍成员信息") unless params[:team_members].is_a?(Array)
|
||||
params[:team_members].each do |member|
|
||||
apply = GitlinkCompetitionApply.find_or_create_by(competition_id: params[:competition_id], team_id: params[:team_id], educoder_login: member[:login])
|
||||
apply.competition_identifier = params[:competition_identifier]
|
||||
apply.team_name = params[:team_name]
|
||||
apply.school_name = member[:school_name]
|
||||
apply.nickname = member[:nickname]
|
||||
apply.identity = member[:identity]
|
||||
apply.role = member[:role]
|
||||
apply.email = member[:email]
|
||||
user_info = get_user_info_by_educoder_login(member[:login])
|
||||
apply.phone = user_info["phone"]
|
||||
apply.save
|
||||
end
|
||||
render_ok
|
||||
end
|
||||
|
||||
def get_user_info_by_educoder_login(edu_login)
|
||||
req_params = { "login" => "#{edu_login}", "private_token" => "hriEn3UwXfJs3PmyXnqQ" }
|
||||
api_url= "https://data.educoder.net"
|
||||
client = Faraday.new(url: api_url)
|
||||
response = client.public_send("get", "/api/sources/get_user_info_by_login", req_params)
|
||||
result = JSON.parse(response.body)
|
||||
|
||||
return nil if result["status"].to_s != "0"
|
||||
|
||||
# login 邮箱 手机号 姓名 学校/单位
|
||||
user_info = result["data"]
|
||||
|
||||
return user_info
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
class Api::V1::Issues::AssignersController < Api::V1::BaseController
|
||||
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
|
||||
# 负责人列表
|
||||
def index
|
||||
@assigners = User.joins(assigned_issues: :project).where(projects: {id: @project&.id})
|
||||
@assigners = @assigners.order("users.id=#{current_user.id} desc").distinct
|
||||
@assigners = @assigners.ransack(login_or_nickname_cont: params[:keyword]).result if params[:keyword].present?
|
||||
@assigners = kaminary_select_paginate(@assigners)
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
class Api::V1::Issues::AuthorsController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
|
||||
# 发布人列表
|
||||
def index
|
||||
@authors = User.joins(issues: :project).where(projects: {id: @project&.id})
|
||||
@authors = @authors.order("users.id=#{current_user.id} desc").distinct
|
||||
@authors = @authors.ransack(login_or_nickname_cont: params[:keyword]).result if params[:keyword].present?
|
||||
@authors = kaminary_select_paginate(@authors)
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
class Api::V1::Issues::IssuePrioritiesController < Api::V1::BaseController
|
||||
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
|
||||
def index
|
||||
@priorities = IssuePriority.order(position: :asc)
|
||||
@priorities = @priorities.ransack(name_cont: params[:keyword]).result if params[:keyword]
|
||||
@priorities = kaminary_select_paginate(@priorities)
|
||||
end
|
||||
|
||||
def pm_index
|
||||
@priorities = IssuePriority.order(position: :asc)
|
||||
@priorities = @priorities.ransack(name_cont: params[:keyword]).result if params[:keyword]
|
||||
@priorities = kaminary_select_paginate(@priorities)
|
||||
render "index"
|
||||
end
|
||||
|
||||
end
|
|
@ -1,70 +0,0 @@
|
|||
class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
||||
before_action :require_login, except: [:index, :pm_index]
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
before_action :require_operate_above, only: [:create, :update, :destroy]
|
||||
|
||||
def index
|
||||
@issue_tags = @project.issue_tags.reorder("#{sort_by} #{sort_direction}")
|
||||
@issue_tags = @issue_tags.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
||||
if params[:only_name]
|
||||
@issue_tags = kaminary_select_paginate(@issue_tags.select(:id, :name, :color))
|
||||
else
|
||||
@issue_tags = kaminari_paginate(@issue_tags.includes(:project, :user, :issue_issues, :pull_request_issues))
|
||||
end
|
||||
end
|
||||
|
||||
def pm_index
|
||||
@issue_tags = IssueTag.init_mp_issues_tags
|
||||
render_ok(@issue_tags)
|
||||
end
|
||||
|
||||
def create
|
||||
@issue_tag = @project.issue_tags.new(issue_tag_params)
|
||||
if @issue_tag.save!
|
||||
render_ok
|
||||
else
|
||||
render_error("创建标记失败!")
|
||||
end
|
||||
end
|
||||
|
||||
before_action :load_issue_tag, only: [:update, :destroy]
|
||||
|
||||
def update
|
||||
@issue_tag.attributes = issue_tag_params
|
||||
if @issue_tag.save!
|
||||
render_ok
|
||||
else
|
||||
render_error("更新标记失败!")
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @issue_tag.destroy!
|
||||
render_ok
|
||||
else
|
||||
render_error("删除标记失败!")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def sort_by
|
||||
sort_by = params.fetch(:sort_by, "created_at")
|
||||
sort_by = IssueTag.column_names.include?(sort_by) ? sort_by : "created_at"
|
||||
sort_by
|
||||
end
|
||||
|
||||
def sort_direction
|
||||
sort_direction = params.fetch(:sort_direction, "desc").downcase
|
||||
sort_direction = %w(desc asc).include?(sort_direction) ? sort_direction : "desc"
|
||||
sort_direction
|
||||
end
|
||||
|
||||
def issue_tag_params
|
||||
params.permit(:name, :description, :color)
|
||||
end
|
||||
|
||||
def load_issue_tag
|
||||
@issue_tag = @project.issue_tags.find_by_id(params[:id])
|
||||
end
|
||||
end
|
|
@ -1,64 +0,0 @@
|
|||
class Api::V1::Issues::JournalsController < Api::V1::BaseController
|
||||
before_action :require_login, except: [:index, :children_journals]
|
||||
before_action :require_public_and_member_above
|
||||
before_action :load_issue
|
||||
before_action :load_journal, only: [:children_journals, :update, :destroy]
|
||||
before_action :check_journal_operate_permission, only: [:update, :destroy]
|
||||
|
||||
def index
|
||||
@object_result = Api::V1::Issues::Journals::ListService.call(@issue, query_params, current_user)
|
||||
@total_journals_count = @object_result[:total_journals_count]
|
||||
@total_operate_journals_count = @object_result[:total_operate_journals_count]
|
||||
@total_comment_journals_count = @object_result[:total_comment_journals_count]
|
||||
@journals = kaminary_select_paginate(@object_result[:data])
|
||||
end
|
||||
|
||||
def create
|
||||
@object_result = Api::V1::Issues::Journals::CreateService.call(@issue, journal_params, current_user)
|
||||
end
|
||||
|
||||
def children_journals
|
||||
@object_results = Api::V1::Issues::Journals::ChildrenListService.call(@issue, @journal, query_params, current_user)
|
||||
@journals = kaminari_paginate(@object_results)
|
||||
end
|
||||
|
||||
def update
|
||||
@object_result = Api::V1::Issues::Journals::UpdateService.call(@issue, @journal, journal_params, current_user)
|
||||
end
|
||||
|
||||
def destroy
|
||||
TouchWebhookJob.set(wait: 5.seconds).perform_later('IssueComment', @issue&.id, current_user.id, @journal.id, 'deleted', JSON.parse(@journal.to_builder.target!))
|
||||
if @journal.destroy!
|
||||
render_ok
|
||||
else
|
||||
render_error("删除评论失败!")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def query_params
|
||||
params.permit(:category, :keyword, :sort_by, :sort_direction)
|
||||
end
|
||||
|
||||
def journal_params
|
||||
params.permit(:notes, :parent_id, :reply_id, :attachment_ids => [], :receivers_login => [])
|
||||
end
|
||||
|
||||
def load_issue
|
||||
@issue = @project.issues.issue_issue.where(project_issues_index: params[:index]).where.not(id: params[:index]).take || Issue.find_by_id(params[:index])
|
||||
if @issue.blank?
|
||||
render_not_found("疑修不存在!")
|
||||
end
|
||||
end
|
||||
|
||||
def load_journal
|
||||
@journal = Journal.find_by_id(params[:id])
|
||||
return render_not_found("评论不存在!") unless @journal.present?
|
||||
end
|
||||
|
||||
def check_journal_operate_permission
|
||||
return render_forbidden("您没有操作权限!") unless @project.member?(current_user) || current_user.admin? || @issue.user == current_user || @journal.user == current_user || @journal.parent_journal&.user == current_user
|
||||
end
|
||||
|
||||
end
|
|
@ -1,87 +0,0 @@
|
|||
class Api::V1::Issues::MilestonesController < Api::V1::BaseController
|
||||
before_action :require_login, except: [:index, :show]
|
||||
before_action :require_public_and_member_above, only: [:index, :show]
|
||||
before_action :require_operate_above, only: [:create, :update, :destroy]
|
||||
before_action :load_milestone, only: [:show, :update, :destroy]
|
||||
|
||||
# 里程碑列表
|
||||
def index
|
||||
@milestones = @project.versions
|
||||
@milestones = @milestones.ransack(id_eq: params[:keyword]).result.or(@milestones.ransack(name_or_description_cont: params[:keyword]).result) if params[:keyword].present?
|
||||
@closed_milestone_count = @milestones.closed.size
|
||||
@opening_milestone_count = @milestones.opening.size
|
||||
@milestones = params[:category] == "closed" ? @milestones.closed : @milestones.opening
|
||||
@milestones = @milestones.reorder("versions.#{sort_by} #{sort_direction}")
|
||||
if params[:only_name]
|
||||
@milestones = @milestones.select(:id, :name)
|
||||
@milestones = kaminary_select_paginate(@milestones)
|
||||
else
|
||||
@milestones = @milestones.includes(:issues, :closed_issues, :opened_issues)
|
||||
@milestones = kaminari_paginate(@milestones)
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@milestone = @project.versions.new(milestone_params)
|
||||
if @milestone.save!
|
||||
render_ok
|
||||
else
|
||||
render_error(@milestone.errors.full_messages.join(","))
|
||||
end
|
||||
end
|
||||
|
||||
# 里程碑详情
|
||||
def show
|
||||
@object_result = Api::V1::Issues::Milestones::DetailIssuesService.call(@project, @milestone, query_params, current_user)
|
||||
@total_issues_count = @object_result[:total_issues_count]
|
||||
@opened_issues_count = @object_result[:opened_issues_count]
|
||||
@closed_issues_count = @object_result[:closed_issues_count]
|
||||
|
||||
@issues = kaminari_paginate(@object_result[:data])
|
||||
end
|
||||
|
||||
def update
|
||||
@milestone.attributes = milestone_params
|
||||
if @milestone.save!
|
||||
render_ok
|
||||
else
|
||||
render_error(@milestone.errors.full_messages.join(","))
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @milestone.destroy!
|
||||
render_ok
|
||||
else
|
||||
render_error("删除里程碑失败!")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def milestone_params
|
||||
params.permit(:name, :description, :effective_date)
|
||||
end
|
||||
|
||||
def query_params
|
||||
params.permit(:category, :author_id, :assigner_id, :sort_by, :sort_direction, :issue_tag_ids)
|
||||
end
|
||||
|
||||
def load_milestone
|
||||
@milestone = @project.versions.find_by_id(params[:id])
|
||||
return render_not_found('里程碑不存在!') unless @milestone.present?
|
||||
end
|
||||
|
||||
def sort_by
|
||||
sort_by = params.fetch(:sort_by, "created_on")
|
||||
sort_by = Version.column_names.include?(sort_by) ? sort_by : "created_on"
|
||||
|
||||
sort_by
|
||||
end
|
||||
|
||||
def sort_direction
|
||||
sort_direction = params.fetch(:sort_direction, "desc").downcase
|
||||
sort_direction = %w(desc asc).include?(sort_direction) ? sort_direction : "desc"
|
||||
sort_direction
|
||||
end
|
||||
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
class Api::V1::Issues::StatuesController < Api::V1::BaseController
|
||||
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
|
||||
# 状态列表
|
||||
def index
|
||||
@statues = IssueStatus.order("position asc")
|
||||
@statues = @statues.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
||||
@statues = kaminary_select_paginate(@statues)
|
||||
end
|
||||
|
||||
def pm_index
|
||||
@statues = IssueStatus.order("position asc")
|
||||
@statues = @statues.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
||||
@statues = kaminary_select_paginate(@statues)
|
||||
render "index"
|
||||
end
|
||||
end
|
|
@ -1,131 +0,0 @@
|
|||
class Api::V1::IssuesController < Api::V1::BaseController
|
||||
before_action :require_login, except: [:index, :show, :show_by_id]
|
||||
before_action :require_public_and_member_above, only: [:index, :show, :show_by_id, :create, :update, :destroy]
|
||||
before_action :require_operate_above, only: [:batch_update, :batch_destroy]
|
||||
|
||||
def index
|
||||
IssueTag.init_data(@project.id) unless $redis_cache.hget("project_init_issue_tags", @project.id)
|
||||
@object_result = Api::V1::Issues::ListService.call(@project, query_params, current_user)
|
||||
@total_issues_count = @object_result[:total_issues_count]
|
||||
@opened_issues_count = @object_result[:opened_issues_count]
|
||||
@closed_issues_count = @object_result[:closed_issues_count]
|
||||
if params[:only_name].present?
|
||||
@issues = kaminary_select_paginate(@object_result[:data].select(:id, :subject, :project_issues_index, :updated_on, :created_on))
|
||||
else
|
||||
@issues = kaminari_paginate(@object_result[:data])
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@object_result = Api::V1::Issues::CreateService.call(@project, issue_params, current_user)
|
||||
end
|
||||
|
||||
before_action :load_issue, only: [:show, :update, :destroy]
|
||||
before_action :check_issue_operate_permission, only: [:update, :destroy]
|
||||
before_action :load_issue_by_id, only: [:show_by_id]
|
||||
|
||||
def show_by_id
|
||||
@issue.associate_attachment_container
|
||||
@user_permission = current_user.present? && current_user.logged? && (@project.member?(current_user) || current_user.admin? || @issue.user == current_user)
|
||||
end
|
||||
|
||||
def show
|
||||
@issue.associate_attachment_container
|
||||
@user_permission = current_user.present? && current_user.logged? && (@project.member?(current_user) || current_user.admin? || @issue.user == current_user)
|
||||
end
|
||||
|
||||
def update
|
||||
@object_result = Api::V1::Issues::UpdateService.call(@project, @issue, issue_params, current_user)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@object_result = Api::V1::Issues::DeleteService.call(@project, @issue, current_user)
|
||||
if @object_result
|
||||
render_ok
|
||||
else
|
||||
render_error("删除疑修失败!")
|
||||
end
|
||||
end
|
||||
|
||||
before_action :load_issues, only: [:batch_update, :batch_destroy]
|
||||
|
||||
def batch_update
|
||||
@object_result = Api::V1::Issues::BatchUpdateService.call(@project, @issues, batch_issue_params, current_user)
|
||||
if @object_result
|
||||
render_ok
|
||||
else
|
||||
render_error("批量更新疑修失败!")
|
||||
end
|
||||
end
|
||||
|
||||
def batch_destroy
|
||||
@object_result = Api::V1::Issues::BatchDeleteService.call(@project, @issues, current_user)
|
||||
if @object_result
|
||||
render_ok
|
||||
else
|
||||
render_error("批量删除疑修失败!")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_issue
|
||||
@issue = @project.issues.issue_issue.where(project_issues_index: params[:index]).where.not(id: params[:index]).take || Issue.find_by_id(params[:index])
|
||||
if @issue.blank?
|
||||
render_not_found("疑修不存在!")
|
||||
end
|
||||
end
|
||||
|
||||
def load_issue_by_id
|
||||
@issue = Issue.find_by_id(params[:index])
|
||||
if @issue.blank?
|
||||
render_not_found("疑修不存在!")
|
||||
end
|
||||
end
|
||||
|
||||
def load_issues
|
||||
return render_error("请输入正确的ID数组!") unless params[:ids].is_a?(Array)
|
||||
params[:ids].each do |id|
|
||||
@issue = Issue.find_by_id(id)
|
||||
if @issue.blank?
|
||||
return render_not_found("ID为#{id}的疑修不存在!")
|
||||
end
|
||||
end
|
||||
@issues = Issue.where(id: params[:ids])
|
||||
end
|
||||
|
||||
def check_issue_operate_permission
|
||||
return render_forbidden("您没有操作权限!") unless @project.member?(current_user) || current_user.admin? || @issue.user == current_user
|
||||
end
|
||||
|
||||
def query_params
|
||||
params.permit(
|
||||
:only_name,
|
||||
:category,
|
||||
:participant_category,
|
||||
:keyword, :author_id,
|
||||
:milestone_id, :assigner_id,
|
||||
:status_id,
|
||||
:begin_date, :end_date,
|
||||
:sort_by, :sort_direction,
|
||||
:issue_tag_ids)
|
||||
end
|
||||
|
||||
def issue_params
|
||||
params.permit(
|
||||
:status_id, :priority_id, :milestone_id,
|
||||
:branch_name, :start_date, :due_date,
|
||||
:subject, :description, :blockchain_token_num,
|
||||
:issue_tag_ids => [],
|
||||
:assigner_ids => [],
|
||||
:attachment_ids => [],
|
||||
:receivers_login => [])
|
||||
end
|
||||
|
||||
def batch_issue_params
|
||||
params.permit(
|
||||
:status_id, :priority_id, :milestone_id,
|
||||
:issue_tag_ids => [],
|
||||
:assigner_ids => [])
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
class Api::V1::ProjectDatasetsController < Api::V1::BaseController
|
||||
|
||||
def index
|
||||
return render_error("请输入正确的项目id字符串") unless params[:ids].present?
|
||||
ids = params[:ids].split(",")
|
||||
@project_datasets = ProjectDataset.where(project_id: ids).includes(:license, :project)
|
||||
@project_datasets = kaminari_unlimit_paginate(@project_datasets)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,46 +0,0 @@
|
|||
class Api::V1::ProjectTopicsController < Api::V1::BaseController
|
||||
|
||||
def index
|
||||
@project_topics = ProjectTopic
|
||||
@project_topics = @project_topics.ransack(name_cont: params[:keyword]) if params[:keyword].present?
|
||||
# @project_topics = @project_topics.includes(:projects)
|
||||
@project_topics = kaminary_select_paginate(@project_topics)
|
||||
end
|
||||
|
||||
def create
|
||||
ActiveRecord::Base.transaction do
|
||||
@project = Project.find_by_id(create_params[:project_id])
|
||||
return render_not_found unless @project.present?
|
||||
return render_error("请输入项目搜索标签名称.") unless create_params[:name].present?
|
||||
|
||||
@project_topic = ProjectTopic.find_or_create_by!(name: create_params[:name].downcase)
|
||||
@project_topic_ralate = @project_topic.project_topic_ralates.find_or_create_by!(project_id: create_params[:project_id])
|
||||
|
||||
if @project_topic.present? && @project_topic_ralate.present?
|
||||
render_ok
|
||||
else
|
||||
render_error("项目关联搜索标签失败.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
ActiveRecord::Base.transaction do
|
||||
@project = Project.find_by_id(create_params[:project_id])
|
||||
return render_not_found unless @project.present?
|
||||
|
||||
@project_topic = ProjectTopic.find_by_id(params[:id])
|
||||
@project_topic_ralate = @project_topic.project_topic_ralates.find_by(project_id: @project.id)
|
||||
if @project_topic_ralate.destroy!
|
||||
render_ok
|
||||
else
|
||||
render_error("项目取消关联搜索标签失败.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def create_params
|
||||
params.permit(:project_id, :name)
|
||||
end
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions::BaseController
|
||||
|
||||
def index
|
||||
begin
|
||||
gitea_result = $gitea_hat_client.get_repos_actions_by_owner_repo(@project&.owner&.login, @project&.identifier)
|
||||
@data = gitea_result[:data]["Workflows"]
|
||||
rescue
|
||||
@data = []
|
||||
end
|
||||
end
|
||||
|
||||
def disable
|
||||
return render_error("请输入正确的流水线文件!") if params[:workflow].blank?
|
||||
gitea_result = $gitea_hat_client.post_repos_actions_disable(@project&.owner&.login, @project&.identifier, {query: {workflow: params[:workflow]}}) rescue nil
|
||||
if gitea_result
|
||||
render_ok
|
||||
else
|
||||
render_error("禁用流水线失败")
|
||||
end
|
||||
end
|
||||
|
||||
def enable
|
||||
return render_error("请输入正确的流水线文件!") if params[:workflow].blank?
|
||||
gitea_result = $gitea_hat_client.post_repos_actions_enable(@project&.owner&.login, @project&.identifier, {query: {workflow: params[:workflow]}}) rescue nil
|
||||
if gitea_result
|
||||
render_ok
|
||||
else
|
||||
render_error("取消禁用流水线失败")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
class Api::V1::Projects::Actions::BaseController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above
|
||||
|
||||
end
|
|
@ -1,57 +0,0 @@
|
|||
class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::BaseController
|
||||
|
||||
def index
|
||||
@result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token)
|
||||
puts @result_object
|
||||
end
|
||||
|
||||
def create
|
||||
return render_error("请输入正确的流水线文件!") if params[:workflow].blank?
|
||||
return render_error("请输入正确的分支!") if params[:ref].blank?
|
||||
gitea_result = $gitea_hat_client.post_repos_actions_runs_by_owner_repo(@project&.owner&.login, @project&.identifier, {query: {workflow: params[:workflow], ref: params[:ref]}})
|
||||
if gitea_result
|
||||
render_ok
|
||||
else
|
||||
ender_error("启动流水线任务失败")
|
||||
end
|
||||
end
|
||||
|
||||
def rerun
|
||||
return render_error("请输入正确的流水线记录ID!") if params[:run_id].blank?
|
||||
gitea_result = $gitea_hat_client.post_repos_actions_runs_rerun_by_owner_repo_run(@project&.owner&.login, @project&.identifier, params[:run_id]) rescue nil
|
||||
if gitea_result
|
||||
render_ok
|
||||
else
|
||||
render_error("重启所有流水线任务失败")
|
||||
end
|
||||
end
|
||||
|
||||
def job_rerun
|
||||
return render_error("请输入正确的流水线记录ID!") if params[:run_id].blank?
|
||||
return render_error("请输入正确的流水线任务ID") if params[:job].blank?
|
||||
gitea_result = $gitea_hat_client.post_repos_actions_runs_jobs_rerun_by_owner_repo_run_job(@project&.owner&.login, @project&.identifier, params[:run_id], params[:job]) rescue nil
|
||||
if gitea_result
|
||||
render_ok
|
||||
else
|
||||
render_error("重启流水线任务失败")
|
||||
end
|
||||
end
|
||||
|
||||
def job_show
|
||||
@result_object = Api::V1::Projects::Actions::Runs::JobShowService.call(@project, params[:run_id], params[:job], params[:log_cursors], current_user&.gitea_token)
|
||||
end
|
||||
|
||||
def job_logs
|
||||
return render_error("请输入正确的流水线记录ID!") if params[:run_id].blank?
|
||||
return render_error("请输入正确的流水线任务ID") if params[:job].blank?
|
||||
domain = GiteaService.gitea_config[:domain]
|
||||
api_url = GiteaService.gitea_config[:hat_base_url]
|
||||
|
||||
url = "/repos/#{@owner.login}/#{@repository.identifier}/actions/runs/#{CGI.escape(params[:run_id])}/jobs/#{CGI.escape(params[:job])}/logs"
|
||||
file_path = [domain, api_url, url].join
|
||||
file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("?")
|
||||
|
||||
redirect_to file_path
|
||||
end
|
||||
|
||||
end
|
|
@ -1,98 +1,18 @@
|
|||
class Api::V1::Projects::BranchesController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, only: [:index, :all]
|
||||
|
||||
def gitee
|
||||
url = URI("https://gitee.com/api/v5/repos/#{params[:owner]}/#{params[:repo]}/branches?access_token=#{params[:token]}&page=#{page}&per_page=#{limit}")
|
||||
https = Net::HTTP.new(url.host, url.port)
|
||||
https.use_ssl = true
|
||||
request = Net::HTTP::Get.new(url)
|
||||
response = https.request(request)
|
||||
render :json => response.read_body
|
||||
end
|
||||
|
||||
def github
|
||||
url = URI("https://api.github.com/repos/#{params[:owner]}/#{params[:repo]}/branches?page=#{page}&per_page=#{limit}")
|
||||
https = Net::HTTP.new(url.host, url.port)
|
||||
https.use_ssl = true
|
||||
|
||||
request = Net::HTTP::Get.new(url)
|
||||
request["Authorization"] = "Bearer #{params[:token]}"
|
||||
request["Accept"] = "application/vnd.github+json"
|
||||
request["X-GitHub-Api-Version"] = "2022-11-28"
|
||||
|
||||
response = https.request(request)
|
||||
render :json => response.read_body
|
||||
end
|
||||
|
||||
def index
|
||||
@result_object = Api::V1::Projects::Branches::ListService.call(@project, {name: params[:keyword], state: params[:state], page: page, limit: limit}, current_user&.gitea_token)
|
||||
end
|
||||
before_action :require_public_and_member_above, only: [:all]
|
||||
|
||||
def all
|
||||
@result_object = Api::V1::Projects::Branches::AllListService.call(@project, current_user&.gitea_token)
|
||||
end
|
||||
|
||||
before_action :require_operate_above, only: [:create, :destroy, :restore]
|
||||
before_action :require_operate_above, only: [:create]
|
||||
|
||||
def create
|
||||
@result_object = Api::V1::Projects::Branches::CreateService.call(@project, branch_params, current_user&.gitea_token)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@result_object = Api::V1::Projects::Branches::DeleteService.call(@project, params[:name], current_user&.gitea_token)
|
||||
if @result_object
|
||||
# 有开启的pr需要一同关闭
|
||||
# 1、删除本仓库中存在未关闭的pr,即本仓库分支1->分支2
|
||||
# 2、如果是fork仓库,考虑删除主仓库中存在未关闭的pr,即本仓库:分支1->主:分支2,同时分两种删除:1删除本仓库分支1,2删除主仓库分支2
|
||||
close_pull_requests_by(@project, params[:name])
|
||||
if @project.forked_from_project_id.present?
|
||||
# fork项目中删除分支
|
||||
close_pull_requests_by(@project.fork_project, params[:name])
|
||||
end
|
||||
|
||||
return render_ok
|
||||
else
|
||||
return render_error('删除分支失败!')
|
||||
end
|
||||
end
|
||||
|
||||
def restore
|
||||
@result_object = Api::V1::Projects::Branches::RestoreService.call(@project, params[:branch_id], params[:branch_name], current_user&.gitea_token)
|
||||
if @result_object
|
||||
return render_ok
|
||||
else
|
||||
return render_error('恢复分支失败!')
|
||||
end
|
||||
end
|
||||
|
||||
before_action :require_manager_above, only: [:update_default_branch]
|
||||
|
||||
def update_default_branch
|
||||
@result_object = Api::V1::Projects::Branches::UpdateDefaultBranchService.call(@project, params[:name], current_user&.gitea_token)
|
||||
if @result_object
|
||||
return render_ok
|
||||
else
|
||||
return render_error('更新默认分支失败!')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def branch_params
|
||||
params.require(:branch).permit(:new_branch_name, :old_branch_name)
|
||||
end
|
||||
|
||||
def close_pull_requests_by(project, branch_name)
|
||||
open_pull_requests = project.pull_requests.opening.where(head: branch_name).or(project.pull_requests.opening.where(base: branch_name))
|
||||
if open_pull_requests.present?
|
||||
open_pull_requests.each do |pull_request|
|
||||
closed = PullRequests::CloseService.call(project.owner, project.repository, pull_request, current_user)
|
||||
if closed === true
|
||||
pull_request.project_trends.create!(user: current_user, project: project,action_type: ProjectTrend::CLOSE)
|
||||
# 合并请求下issue处理为关闭
|
||||
pull_request.issue&.update_attributes!({status_id:5})
|
||||
SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, pull_request.id) if Site.has_notice_menu?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,8 +0,0 @@
|
|||
class Api::V1::Projects::CodeStatsController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
|
||||
def index
|
||||
@result_object = Api::V1::Projects::CodeStats::ListService.call(@project, {ref: params[:ref]}, current_user&.gitea_token)
|
||||
# puts @result_object
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
class Api::V1::Projects::CollaboratorsController < Api::V1::BaseController
|
||||
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
|
||||
def index
|
||||
@collaborators = @project.all_collaborators.like(params[:keyword])
|
||||
@collaborators = kaminary_select_paginate(@collaborators)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class Api::V1::Projects::CommitsController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, only: [:index, :diff, :recent]
|
||||
before_action :require_public_and_member_above, only: [:index, :diff]
|
||||
|
||||
def index
|
||||
@result_object = Api::V1::Projects::Commits::ListService.call(@project, {page: page, limit: limit, sha: params[:sha]}, current_user&.gitea_token)
|
||||
|
@ -9,11 +9,4 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController
|
|||
def diff
|
||||
@result_object = Api::V1::Projects::Commits::DiffService.call(@project, params[:sha], current_user&.gitea_token)
|
||||
end
|
||||
|
||||
def recent
|
||||
hash = Api::V1::Projects::Commits::RecentService.call(@project, {keyword: params[:keyword], page: page, limit: limit}, current_user&.gitea_token)
|
||||
@result_object = hash[:result]
|
||||
@object_detail = hash[:detail]
|
||||
puts @object_detail
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
class Api::V1::Projects::ContributorsController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, only: [:index, :stat]
|
||||
|
||||
# todo
|
||||
def index
|
||||
end
|
||||
|
||||
def stat
|
||||
@result_object = Api::V1::Projects::Contributors::StatService.call(@project, {branch: params[:branch], pass_year: params[:pass_year], page: page, limit: limit}, current_user&.gitea_token)
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
class Api::V1::Projects::DatasetsController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, only: [:show]
|
||||
before_action :require_member_above, only: [:create, :update]
|
||||
before_action :find_dataset, only: [:update, :show]
|
||||
before_action :check_menu_authorize
|
||||
|
||||
def create
|
||||
::Projects::Datasets::CreateForm.new(dataset_params).validate!
|
||||
return render_error('该项目下已存在数据集!') if @project.project_dataset.present?
|
||||
@project_dataset = ProjectDataset.new(dataset_params.merge!(project_id: @project.id))
|
||||
if @project_dataset.save!
|
||||
render_ok
|
||||
else
|
||||
render_error('创建数据集失败!')
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def update
|
||||
::Projects::Datasets::CreateForm.new(dataset_params).validate!
|
||||
@project_dataset.attributes = dataset_params
|
||||
if @project_dataset.save!
|
||||
render_ok
|
||||
else
|
||||
render_error("更新数据集失败!")
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def show
|
||||
@attachments = kaminari_paginate(@project_dataset.attachments.includes(:author))
|
||||
end
|
||||
|
||||
private
|
||||
def dataset_params
|
||||
params.permit(:title, :description, :license_id, :paper_content)
|
||||
end
|
||||
|
||||
def find_dataset
|
||||
@project_dataset = @project.project_dataset
|
||||
return render_not_found unless @project_dataset.present?
|
||||
end
|
||||
|
||||
def check_menu_authorize
|
||||
return render_not_found unless @project.has_menu_permission("dataset")
|
||||
end
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
class Api::V1::Projects::PortraitController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above
|
||||
|
||||
def index
|
||||
platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
|
||||
|
||||
# 社区影响力
|
||||
praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count
|
||||
watcher_count = Watcher.where(watchable_type:"Project", watchable_id: @project.id).count
|
||||
fork_count = ForkUser.where(project_id: @project.id).count
|
||||
community_impact_praise = platform_statistic['max-praise-count'].to_i == 0 ? 0 : 30*(praise_count.to_f/platform_statistic['max-praise-count'].to_i)
|
||||
community_impact_watcher = platform_statistic['max-watcher-count'].to_i == 0 ? 0 : 30*(watcher_count.to_f/platform_statistic['max-watcher-count'].to_i)
|
||||
community_impact_fork = platform_statistic['max-fork-count'].to_i == 0 ? 0 : 40*(fork_count.to_f/platform_statistic['max-fork-count'].to_i)
|
||||
community_impact = format("%.2f", community_impact_praise + community_impact_watcher + community_impact_fork)
|
||||
|
||||
# 项目成熟度
|
||||
pullrequest_count = PullRequest.where(project_id: @project.id).count
|
||||
issue_count = Issue.issue_issue.where(project_id: @project.id).count
|
||||
commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).count
|
||||
project_maturity_pullrequest = platform_statistic['max-pullrequest-count'].to_i == 0 ? 0 : 30*(pullrequest_count.to_f/platform_statistic['max-pullrequest-count'].to_i)
|
||||
project_maturity_issue = platform_statistic['max-issue-count'].to_i == 0 ? 0 : 30*(issue_count.to_f/platform_statistic['max-issue-count'].to_i)
|
||||
project_maturity_commit = platform_statistic['max-commit-count'].to_i == 0 ? 0 : 40*(commit_count.to_f/platform_statistic['max-commit-count'].to_i)
|
||||
project_maturity = format("%.2f", project_maturity_pullrequest + project_maturity_issue + project_maturity_commit)
|
||||
|
||||
# 项目健康度
|
||||
closed_pullrequest_count = PullRequest.where(project_id: @project.id).merged_and_closed.count
|
||||
closed_issue_count = Issue.issue_issue.where(project_id: @project.id).closed.count
|
||||
has_license = @project.license.present? ? 1 : 0
|
||||
project_health_issue = (issue_count < 10 || closed_issue_count < 10) ? 0 : 40*(closed_issue_count-10).to_f/(issue_count-10)
|
||||
project_health_pullrequest = (pullrequest_count < 5 || closed_pullrequest_count < 5) ? 0 : 30*(closed_pullrequest_count-5).to_f/(pullrequest_count-5)
|
||||
project_health_license = 20*has_license
|
||||
project_health = format("%.2f", project_health_issue + project_health_pullrequest + project_health_license)
|
||||
|
||||
# 团队影响度
|
||||
member_count = Member.where(project_id: @project.id).count
|
||||
recent_one_month_member_count = Member.where(project_id:@project.id).where("created_on > ?", Time.now - 30.days).count
|
||||
team_impact_member = platform_statistic['max-member-count'].to_i == 0 ? 0 : 40*(member_count.to_f/platform_statistic['max-member-count'].to_i)
|
||||
team_impact_recent_member = platform_statistic['max-recent-one-month-member-count'].to_i == 0 ? 0 : 60*(recent_one_month_member_count.to_f/platform_statistic['max-recent-one-month-member-count'].to_i)
|
||||
team_impact = format("%.2f", team_impact_member + team_impact_recent_member)
|
||||
|
||||
# 开发活跃度
|
||||
recent_one_month_pullrequest_count = PullRequest.where(project_id: @project.id).where("created_at > ?", Time.now - 30.days).count
|
||||
recent_one_month_issue_count = Issue.issue_issue.where(project_id: @project.id).where("created_on > ?", Time.now - 30.days).count
|
||||
recent_one_month_commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).where("created_at > ?", Time.now - 30.days).count
|
||||
develop_activity_pullrequest = platform_statistic['max-recent-one-month-pullrequest-count'].to_i == 0 ? 0 : 20*(recent_one_month_pullrequest_count.to_f/platform_statistic['max-recent-one-month-pullrequest-count'].to_i)
|
||||
develop_activity_issue = platform_statistic['max-recent-one-month-issue-count'].to_i == 0 ? 0 : 20*(recent_one_month_issue_count.to_f/platform_statistic['max-recent-one-month-issue-count'].to_i)
|
||||
develop_activity_commit = platform_statistic['max-recent-one-month-commit-count'].to_i == 0 ? 0 : 40*(recent_one_month_commit_count.to_f/platform_statistic['max-recent-one-month-commit-count'].to_i)
|
||||
develop_activity = format("%.2f", 20 + develop_activity_pullrequest + develop_activity_issue + develop_activity_commit)
|
||||
|
||||
render :json => {community_impact: community_impact, project_maturity: project_maturity, project_health: project_health, team_impact: team_impact, develop_activity: develop_activity}
|
||||
end
|
||||
end
|
|
@ -1,148 +0,0 @@
|
|||
class Api::V1::Projects::SyncRepositoriesController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, except: [:sync]
|
||||
before_action :load_project, only: [:sync]
|
||||
|
||||
def index
|
||||
@sync_repositories = @project.sync_repositories
|
||||
@group_sync_repository = @project.sync_repositories.group(:type, :external_repo_address, :sync_granularity, :external_token).count
|
||||
end
|
||||
|
||||
def create
|
||||
@sync_repository1, @sync_repository2, @sync_repository_branch1, @sync_repository_branch2 = Api::V1::Projects::SyncRepositories::CreateService.call(@project, sync_repository_params)
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def update_info
|
||||
return render_error("请输入正确的同步仓库ID") unless params[:sync_repository_ids].present?
|
||||
Api::V1::Projects::SyncRepositories::UpdateService.call(@project, params[:sync_repository_ids], sync_repository_update_params)
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def sync
|
||||
return render_error("请输入正确的同步方向!") if params[:sync_direction].blank?
|
||||
if params[:repo_type].present?
|
||||
@sync_repositories = SyncRepository.where(project: @project, type: params[:repo_type], sync_direction: params[:sync_direction])
|
||||
else
|
||||
@sync_repositories = SyncRepository.where(project: @project, sync_direction: params[:sync_direction])
|
||||
end
|
||||
branch = params[:payload].present? ? JSON.parse(params[:payload])["ref"].split("/")[-1] : params[:ref].split("/")[-1] rescue nil
|
||||
if params[:sync_direction].to_i == 1
|
||||
@sync_repository_branches = SyncRepositoryBranch.where(sync_repository_id: @sync_repositories, gitlink_branch_name: branch, enable: true)
|
||||
else
|
||||
@sync_repository_branches = SyncRepositoryBranch.where(sync_repository_id: @sync_repositories, external_branch_name: branch, enable: true)
|
||||
end
|
||||
# 全部分支同步暂时不做
|
||||
# @sync_repositories.each do |item|
|
||||
# TouchSyncJob.perform_later(item)
|
||||
# end
|
||||
@sync_repository_branches.each do |item|
|
||||
TouchSyncJob.set(wait: 5.seconds).perform_later(item)
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def unbind
|
||||
return render_error("请输入正确的同步仓库ID") unless params[:sync_repository_ids].present?
|
||||
@sync_repositories = SyncRepository.where(id: params[:sync_repository_ids].split(","))
|
||||
@sync_repositories.each do |repo|
|
||||
# Reposync::DeleteRepoService.call(repo.repo_name) # 解绑操作放在回调里
|
||||
Api::V1::Projects::Webhooks::DeleteService.call(@project, repo.webhook_gid)
|
||||
repo.destroy
|
||||
end
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def change_enable
|
||||
return render_error("请输入正确的仓库类型") if params[:repo_type].blank?
|
||||
return render_error("请输入正确的分支名称") if params[:gitlink_branch_name].blank? || params[:external_branch_name].blank?
|
||||
# return render_error("请输入正确的状态") if params[:enable].blank?
|
||||
@sync_repository_branches = SyncRepositoryBranch.joins(:sync_repository).where(sync_repositories: {project_id: @project.id, type: params[:repo_type]}, gitlink_branch_name: params[:gitlink_branch_name], external_branch_name: params[:external_branch_name])
|
||||
if @sync_repository_branches.update_all({enable: params[:enable]})
|
||||
@sync_repository_branches.each do |branch|
|
||||
branch_sync_direction = branch&.sync_repository&.sync_direction.to_i
|
||||
if branch_sync_direction == 1
|
||||
Reposync::UpdateBranchStatusService.call(branch&.sync_repository&.repo_name, branch.gitlink_branch_name, params[:enable])
|
||||
else
|
||||
Reposync::UpdateBranchStatusService.call(branch&.sync_repository&.repo_name, branch.external_branch_name, params[:enable])
|
||||
end
|
||||
TouchSyncJob.perform_later(branch) if params[:enable] && branch_sync_direction == params[:first_sync_direction].to_i
|
||||
end
|
||||
render_ok
|
||||
else
|
||||
render_error("更新失败!")
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def create_branch
|
||||
return render_error("请输入正确的同步仓库ID") unless params[:sync_repository_ids].present?
|
||||
return render_error("请输入正确的Gitlink分支名称") unless params[:gitlink_branch_name].present?
|
||||
return render_error("请输入正确的外部仓库分支名称") unless params[:external_branch_name].present?
|
||||
return render_error("请输入正确的首次同步方向") unless params[:first_sync_direction].present?
|
||||
|
||||
params[:sync_repository_ids].split(",").each do |id|
|
||||
repo = SyncRepository.find_by_id id
|
||||
branch = Reposync::CreateSyncBranchService.call(repo.repo_name, params[:gitlink_branch_name], params[:external_branch_name])
|
||||
return render_error(branch[2]) if branch[0].to_i !=0
|
||||
sync_branch = SyncRepositoryBranch.create!(sync_repository_id: id, gitlink_branch_name: params[:gitlink_branch_name], external_branch_name: params[:external_branch_name], reposync_branch_id: branch[1]['id'])
|
||||
TouchSyncJob.perform_later(sync_branch) if params[:first_sync_direction].to_i == repo.sync_direction
|
||||
end
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def branches
|
||||
return render_error("请输入正确的同步仓库ID") unless params[:sync_repository_ids].present?
|
||||
@sync_repository_branches = SyncRepositoryBranch.where(sync_repository_id: params[:sync_repository_ids].split(","))
|
||||
@sync_repository_branches = @sync_repository_branches.ransack(gitlink_branch_name_or_external_branch_name_cont: params[:branch_name]).result if params[:branch_name].present?
|
||||
@group_sync_repository_branch = @sync_repository_branches.joins(:sync_repository).group("sync_repositories.type, sync_repository_branches.gitlink_branch_name, sync_repository_branches.external_branch_name").select("sync_repositories.type as type,max(sync_repository_branches.updated_at) as updated_at, sync_repository_branches.gitlink_branch_name, sync_repository_branches.external_branch_name").sort_by{|i|i.updated_at}
|
||||
@each_json = []
|
||||
@group_sync_repository_branch.each do |item|
|
||||
branches = @sync_repository_branches.joins(:sync_repository).where(sync_repositories: {type: item.type}, gitlink_branch_name: item.gitlink_branch_name, external_branch_name: item.external_branch_name).order(sync_time: :desc)
|
||||
branch = branches.first
|
||||
@each_json << {
|
||||
gitlink_branch_name: item.gitlink_branch_name,
|
||||
external_branch_name: item.external_branch_name,
|
||||
type: branch&.sync_repository&.type,
|
||||
sync_time: branch.sync_time.present? ? branch.sync_time.strftime("%Y-%m-%d %H:%M:%S") : nil,
|
||||
sync_status: branch.sync_status,
|
||||
enable: branch.enable,
|
||||
enable_num: branch.enable ? 1 : 0,
|
||||
created_at: branch.created_at.to_i,
|
||||
reposync_branch_ids: branches.pluck(:reposync_branch_id)
|
||||
}
|
||||
end
|
||||
@each_json = @each_json.sort_by{|h| [-h[:enable_num], h[:created_at]]}
|
||||
render :json => {total_count: @group_sync_repository_branch.count, sync_repository_branches: @each_json}
|
||||
end
|
||||
|
||||
def history
|
||||
return render_error("请输入正确的同步分支ID") unless params[:reposync_branch_ids]
|
||||
@branch = SyncRepositoryBranch.find_by(reposync_branch_id: params[:reposync_branch_ids].split(",")[0])
|
||||
_, @reposync_branch_logs, @total_count, _ = Reposync::GetLogsService.call(nil, params[:reposync_branch_ids], page, limit)
|
||||
end
|
||||
|
||||
private
|
||||
def sync_repository_params
|
||||
params.permit(:type, :external_token, :external_repo_address, :sync_granularity, :external_branch_name, :gitlink_branch_name, :first_sync_direction)
|
||||
end
|
||||
|
||||
def sync_repository_update_params
|
||||
params.permit(:external_token, :external_repo_address)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
class Api::V1::Projects::TagsController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, only: [:index, :show]
|
||||
|
||||
def index
|
||||
@release_tags = @repository.version_releases.pluck(:tag_name)
|
||||
@result_object = Api::V1::Projects::Tags::ListService.call(@project, {page: page, limit: limit}, current_user&.gitea_token)
|
||||
end
|
||||
|
||||
def show
|
||||
@result_object = Api::V1::Projects::Tags::GetService.call(@project, params[:name], current_user&.gitea_token)
|
||||
end
|
||||
|
||||
before_action :require_operate_above, only: [:destroy]
|
||||
|
||||
def destroy
|
||||
@result_object = Api::V1::Projects::Tags::DeleteService.call(@project, params[:name], current_user&.gitea_token)
|
||||
if @result_object
|
||||
return render_ok
|
||||
else
|
||||
return render_error('删除标签失败!')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
class Api::V1::Users::FeedbacksController < Api::V1::BaseController
|
||||
|
||||
before_action :load_observe_user
|
||||
before_action :check_auth_for_observe_user
|
||||
|
||||
def create
|
||||
@result = Api::V1::Users::Feedbacks::CreateService.call(@observe_user, feedback_params)
|
||||
return render_error("反馈意见创建失败.") if @result.nil?
|
||||
return render_ok
|
||||
end
|
||||
|
||||
private
|
||||
def feedback_params
|
||||
params.permit(:content)
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
class Api::V1::Users::HomeTopSettingsController < Api::V1::BaseController
|
||||
|
||||
before_action :load_observe_user
|
||||
before_action :check_auth_for_observe_user
|
||||
|
||||
def create
|
||||
@result = Api::V1::Users::HomeTopSettings::CreateService.call(@observe_user, home_top_setting_params)
|
||||
return render_error("置顶失败.") if @result.nil?
|
||||
return render_ok
|
||||
end
|
||||
|
||||
def cancel
|
||||
@result = Api::V1::Users::HomeTopSettings::DeleteService.call(@observe_user, home_top_setting_params)
|
||||
return render_error("取消置顶失败.") if @result.nil?
|
||||
return render_ok
|
||||
end
|
||||
|
||||
private
|
||||
def home_top_setting_params
|
||||
params.permit(:top_type, :top_id)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
class Api::V1::Users::OpenkylinSignController < Api::V1::BaseController
|
||||
|
||||
before_action :load_observe_user
|
||||
|
||||
def competitions
|
||||
@competition_ids = EduSetting.get("openkylin_sign_competitions").split(",") rescue []
|
||||
render :json => {data: @competition_ids}
|
||||
end
|
||||
|
||||
def create
|
||||
@object_result = Api::V1::Users::OpenkylinSign::CreateService.call(@observe_user, create_params)
|
||||
Rails.logger.info "OpenkylinSignController=====#{@object_result}"
|
||||
if @object_result
|
||||
return render_ok
|
||||
else
|
||||
return render_error('签署失败!')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def create_params
|
||||
params.permit(:login, :email, :nickname, :phone, :address)
|
||||
end
|
||||
end
|
|
@ -1,17 +1,7 @@
|
|||
class Api::V1::UsersController < Api::V1::BaseController
|
||||
|
||||
before_action :load_observe_user, except: [:check_user_id, :check_user_login]
|
||||
before_action :check_auth_for_observe_user, except: [:check_user_id, :check_user_login]
|
||||
|
||||
def check_user_id
|
||||
return tip_exception(-1, "用户ID不存在") unless params[:user_id].present? && User.exists?(id: params[:user_id])
|
||||
render_ok
|
||||
end
|
||||
|
||||
def check_user_login
|
||||
return tip_exception(-1, "用户标识不存在") unless params[:login].present? && User.exists?(login: params[:login])
|
||||
render_ok
|
||||
end
|
||||
before_action :load_observe_user
|
||||
before_action :check_auth_for_observe_user
|
||||
|
||||
def send_email_vefify_code
|
||||
code = %W(0 1 2 3 4 5 6 7 8 9)
|
||||
|
@ -19,24 +9,21 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
mail = params[:email]
|
||||
code_type = params[:code_type]
|
||||
|
||||
status, message = InfoRiskControlService.call(mail, request.remote_ip)
|
||||
tip_exception(420, message) if status == 0
|
||||
|
||||
sign = Digest::MD5.hexdigest("#{OPENKEY}#{mail}")
|
||||
Rails.logger.info sign
|
||||
|
||||
tip_exception(501, "请求不合理") if sign != params[:smscode]
|
||||
|
||||
# 60s内不能重复发送
|
||||
# send_email_limit_cache_key = "send_email_60_second_limit:#{mail}"
|
||||
# tip_exception(-2, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
|
||||
# send_email_control = LimitForbidControl::SendEmailCode.new(mail)
|
||||
# tip_exception(-2, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
|
||||
send_email_limit_cache_key = "send_email_60_second_limit:#{mail}"
|
||||
tip_exception(-2, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
|
||||
send_email_control = LimitForbidControl::SendEmailCode.new(mail)
|
||||
tip_exception(-2, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
|
||||
begin
|
||||
UserMailer.update_email(mail, verification_code).deliver_now
|
||||
|
||||
# Rails.cache.write(send_email_limit_cache_key, 1, expires_in: 1.minute)
|
||||
# send_email_control.increment!
|
||||
Rails.cache.write(send_email_limit_cache_key, 1, expires_in: 1.minute)
|
||||
send_email_control.increment!
|
||||
rescue Exception => e
|
||||
logger_error(e)
|
||||
tip_exception(-2,"邮件发送失败,请稍后重试")
|
||||
|
@ -83,21 +70,6 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
render_ok
|
||||
end
|
||||
|
||||
def check_phone_verify_code
|
||||
code = strip(params[:code])
|
||||
phone = strip(params[:phone])
|
||||
code_type = params[:code_type]
|
||||
|
||||
return tip_exception(-2, "手机号格式有误") unless phone =~ CustomRegexp::PHONE
|
||||
|
||||
verifi_code = VerificationCode.where(phone: phone, code: code, code_type: code_type).last
|
||||
return render_ok if code == "123123" && EduSetting.get("code_debug") # 万能验证码,用于测试 # TODO 万能验证码,用于测试
|
||||
|
||||
return tip_exception(-6, "验证码不正确") if verifi_code&.code != code
|
||||
return tip_exception(-6, "验证码已失效") if !verifi_code&.effective?
|
||||
render_ok
|
||||
end
|
||||
|
||||
def update_email
|
||||
@result_object = Api::V1::Users::UpdateEmailService.call(@observe_user, params, current_user.gitea_token)
|
||||
if @result_object
|
||||
|
@ -106,13 +78,4 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
return render_error('更改邮箱失败!')
|
||||
end
|
||||
end
|
||||
|
||||
def update_phone
|
||||
@result_object = Api::V1::Users::UpdatePhoneService.call(@observe_user, params)
|
||||
if @result_object
|
||||
return render_ok
|
||||
else
|
||||
return render_error('更改手机号失败!')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,4 @@
|
|||
require 'oauth2'
|
||||
# require 'openssl'
|
||||
# require 'jwt'
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
include CodeExample
|
||||
|
@ -75,17 +73,14 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
|
||||
def admin_or_business?
|
||||
User.current.admin? || User.current.business?
|
||||
end
|
||||
|
||||
def admin_or_glcc_admin?
|
||||
User.current.admin? || User.current.glcc_admin?
|
||||
User.current.admin? || User.current.business?
|
||||
end
|
||||
|
||||
# 判断用户的邮箱或者手机是否可用
|
||||
# params[:type] 1: 注册;2:忘记密码;3:绑定
|
||||
def check_mail_and_phone_valid login, type
|
||||
unless login =~ /\A[a-zA-Z0-9]+([._\-\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+\z/ || login =~ /^1\d{10}$/
|
||||
unless login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/ || login =~ /^1\d{10}$/ ||
|
||||
login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])$/
|
||||
tip_exception(-2, "请输入正确的手机号或邮箱")
|
||||
end
|
||||
|
||||
|
@ -108,30 +103,23 @@ class ApplicationController < ActionController::Base
|
|||
when 1, 2, 4, 9
|
||||
# 手机类型的发送
|
||||
sigle_para = {phone: value}
|
||||
# status = Gitlink::Sms.send(mobile: value, code: code)
|
||||
# tip_exception(-2, code_msg(status)) if status != 0
|
||||
status = Sms::UcloudService.call(value, code, send_type)
|
||||
tip_exception(-2, ucloud_code_msg(status)) if status != 0
|
||||
status = Gitlink::Sms.send(mobile: value, code: code)
|
||||
tip_exception(-2, code_msg(status)) if status != 0
|
||||
when 8, 3, 5
|
||||
# 邮箱类型的发送
|
||||
sigle_para = {email: value}
|
||||
# 60s内不能重复发送
|
||||
# send_email_limit_cache_key = "send_email_60_second_limit:#{value}"
|
||||
# tip_exception(-1, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
|
||||
send_email_limit_cache_key = "send_email_60_second_limit:#{value}"
|
||||
tip_exception(-1, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
|
||||
|
||||
# # 短时间内不能大量发送
|
||||
# send_email_control = LimitForbidControl::SendEmailCode.new(value)
|
||||
# tip_exception(-1, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
|
||||
# 短时间内不能大量发送
|
||||
send_email_control = LimitForbidControl::SendEmailCode.new(value)
|
||||
tip_exception(-1, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
|
||||
begin
|
||||
if send_type == 3
|
||||
UserMailer.find_password(value, code).deliver_now
|
||||
elsif send_type == 5
|
||||
UserMailer.bind_email(value, code).deliver_now
|
||||
else
|
||||
UserMailer.register_email(value, code).deliver_now
|
||||
end
|
||||
# Rails.cache.write(send_email_limit_cache_key, 1, expires_in: 1.minute)
|
||||
# send_email_control.increment!
|
||||
UserMailer.register_email(value, code).deliver_now
|
||||
|
||||
Rails.cache.write(send_email_limit_cache_key, 1, expires_in: 1.minute)
|
||||
send_email_control.increment!
|
||||
# Mailer.run.email_register(code, value)
|
||||
rescue Exception => e
|
||||
logger_error(e)
|
||||
|
@ -161,27 +149,6 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def ucloud_code_msg status
|
||||
case status
|
||||
when 0
|
||||
"验证码已经发送到您的手机,请注意查收"
|
||||
when 171
|
||||
"API签名错误"
|
||||
when 18014
|
||||
"无效手机号码"
|
||||
when 18017
|
||||
"无效模板"
|
||||
when 18018
|
||||
"短信模板参数与短信模板不匹配"
|
||||
when 18023
|
||||
"短信内容中含有运营商拦截的关键词"
|
||||
when 18033
|
||||
"变量内容不符合规范"
|
||||
else
|
||||
"错误码#{status}"
|
||||
end
|
||||
end
|
||||
|
||||
def validate_type(object_type)
|
||||
normal_status(2, "参数") if params.has_key?(:sort_type) && !SORT_TYPE.include?(params[:sort_type].strip)
|
||||
end
|
||||
|
@ -199,10 +166,6 @@ class ApplicationController < ActionController::Base
|
|||
normal_status(403, "") unless admin_or_business?
|
||||
end
|
||||
|
||||
def require_glcc_admin
|
||||
normal_status(403, "") unless admin_or_glcc_admin?
|
||||
end
|
||||
|
||||
# 前端会捕捉401,弹登录弹框
|
||||
# 未授权的捕捉407,弹试用申请弹框
|
||||
def require_login
|
||||
|
@ -305,24 +268,17 @@ class ApplicationController < ActionController::Base
|
|||
# Find the current user
|
||||
#Rails.logger.info("current_laboratory is #{current_laboratory} domain is #{request.subdomain}")
|
||||
if request.headers["Authorization"].present? && request.headers["Authorization"].start_with?('Bearer')
|
||||
if !valid_doorkeeper_token?
|
||||
header = request.authorization
|
||||
pattern = /^Bearer /i
|
||||
token = header.gsub(pattern, "")
|
||||
User.current, message = Bot.decode_jwt_token(token)
|
||||
tip_exception(401, message) if message.present?
|
||||
else
|
||||
if @doorkeeper_token.present?
|
||||
# client方法对接,需要一直带着用户标识uid
|
||||
if @doorkeeper_token.resource_owner_id.blank?
|
||||
tip_exception(-1, "缺少用户标识!") if params[:uid].nil?
|
||||
User.current = User.find(params[:uid])
|
||||
else
|
||||
User.current = User.find_by(id: @doorkeeper_token.resource_owner_id)
|
||||
end
|
||||
tip_exception(401, "请登录后再操作!") unless valid_doorkeeper_token?
|
||||
if @doorkeeper_token.present?
|
||||
# client方法对接,需要一直带着用户标识uid
|
||||
if @doorkeeper_token.resource_owner_id.blank?
|
||||
tip_exception(-1, "缺少用户标识!") if params[:uid].nil?
|
||||
User.current = User.find(params[:uid])
|
||||
else
|
||||
User.current = User.find_by(id: @doorkeeper_token.resource_owner_id)
|
||||
end
|
||||
end
|
||||
else
|
||||
else
|
||||
User.current = find_current_user
|
||||
uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous"))
|
||||
|
||||
|
@ -682,15 +638,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def kaminari_paginate(relation)
|
||||
limit = params[:limit] || params[:per_page]
|
||||
limit = (limit.to_i.zero? || limit.to_i > 50) ? 50 : limit.to_i
|
||||
page = params[:page].to_i.zero? ? 1 : params[:page].to_i
|
||||
|
||||
relation.page(page).per(limit)
|
||||
end
|
||||
|
||||
def kaminari_unlimit_paginate(relation)
|
||||
limit = params[:limit] || params[:per_page]
|
||||
limit = (limit.to_i.zero? || limit.to_i > 9999) ? 9999 : limit.to_i
|
||||
limit = (limit.to_i.zero? || limit.to_i > 25) ? 25 : limit.to_i
|
||||
page = params[:page].to_i.zero? ? 1 : params[:page].to_i
|
||||
|
||||
relation.page(page).per(limit)
|
||||
|
@ -723,7 +671,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def find_user_with_id
|
||||
@user = User.find_by(type: 'User', id: params[:user_id])
|
||||
@user = User.find_by_id params[:user_id]
|
||||
# render_not_found("未找到’#{params[:login]}’相关的用户") unless @user
|
||||
render_error("未找到相关的用户") unless @user
|
||||
end
|
||||
|
@ -848,340 +796,8 @@ class ApplicationController < ActionController::Base
|
|||
HotSearchKeyword.add(keyword)
|
||||
end
|
||||
|
||||
# author: zxh
|
||||
# blockchain相关项目活动调用函数
|
||||
# return true: 表示上链操作成功; return false: 表示上链操作失败
|
||||
def push_activity_2_blockchain(activity_type, model)
|
||||
if activity_type == "issue_create"
|
||||
|
||||
project_id = model['project_id']
|
||||
project = Project.find(project_id)
|
||||
if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# 无需执行上链操作
|
||||
return true
|
||||
end
|
||||
|
||||
id = model['id']
|
||||
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
identifier = project['identifier']
|
||||
|
||||
author_id = project['user_id']
|
||||
author = User.find(author_id)
|
||||
username = author['login']
|
||||
|
||||
action = 'opened'
|
||||
|
||||
title = model['subject']
|
||||
content = model['description']
|
||||
created_at = model['created_on']
|
||||
updated_at = model['updated_on']
|
||||
|
||||
# 调用区块链接口
|
||||
params = {
|
||||
"request-type": "upload issue info",
|
||||
"issue_id": "gitlink-" + id.to_s,
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"issue_number": 0, # 暂时不需要改字段
|
||||
"reponame": identifier,
|
||||
"ownername": ownername,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"created_at": created_at,
|
||||
"updated_at": updated_at
|
||||
}.to_json
|
||||
resp_body = Blockchain::InvokeBlockchainApi.call(params)
|
||||
if resp_body['status'] == 10
|
||||
raise ApplicationService::Error, resp_body['message']
|
||||
elsif resp_body['status'] != 0
|
||||
raise ApplicationService::Error, "区块链接口请求失败."
|
||||
end
|
||||
|
||||
elsif activity_type == "issue_comment_create"
|
||||
issue_comment_id = model['id']
|
||||
issue_id = model['journalized_id']
|
||||
parent_id = model['parent_id'].nil? ? "" : model['parent_id']
|
||||
|
||||
issue = Issue.find(issue_id)
|
||||
issue_classify = issue['issue_classify'] # issue或pull_request
|
||||
project_id = issue['project_id']
|
||||
project = Project.find(project_id)
|
||||
|
||||
if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# 无需执行上链操作
|
||||
return
|
||||
end
|
||||
|
||||
identifier = project['identifier']
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
|
||||
author_id = model['user_id']
|
||||
author = User.find(author_id)
|
||||
username = author['login']
|
||||
|
||||
action = 'created'
|
||||
|
||||
content = model['notes']
|
||||
created_at = model['created_on']
|
||||
|
||||
if issue_classify == "issue"
|
||||
params = {
|
||||
"request-type": "upload issue comment info",
|
||||
"issue_comment_id": "gitlink-" + issue_comment_id.to_s,
|
||||
"issue_comment_number": 0, # 暂时不需要
|
||||
"issue_number": 0, # 暂时不需要
|
||||
"issue_id": "gitlink-" + issue_id.to_s,
|
||||
"repo_id": "gitlink-" + project.id.to_s,
|
||||
"parent_id": parent_id.to_s,
|
||||
"reponame": identifier,
|
||||
"ownername": ownername,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"content": content,
|
||||
"created_at": created_at,
|
||||
}.to_json
|
||||
elsif issue_classify == "pull_request"
|
||||
params = {
|
||||
"request-type": "upload pull request comment info",
|
||||
"pull_request_comment_id": "gitlink-" + issue_comment_id.to_s,
|
||||
"pull_request_comment_number": 0, # 不考虑该字段
|
||||
"pull_request_number": 0, # 不考虑该字段
|
||||
"pull_request_id": "gitlink-" + issue_id.to_s,
|
||||
"parent_id": parent_id.to_s,
|
||||
"repo_id": "gitlink-" + project.id.to_s,
|
||||
"reponame": identifier,
|
||||
"ownername": ownername,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"content": content,
|
||||
"created_at": created_at,
|
||||
}.to_json
|
||||
end
|
||||
|
||||
# 调用区块链接口
|
||||
resp_body = Blockchain::InvokeBlockchainApi.call(params)
|
||||
if resp_body['status'] == 10
|
||||
raise ApplicationService::Error, resp_body['message']
|
||||
elsif resp_body['status'] != 0
|
||||
raise ApplicationService::Error, "区块链接口请求失败."
|
||||
end
|
||||
elsif activity_type == "pull_request_create"
|
||||
# 调用区块链接口
|
||||
project_id = model['project_id']
|
||||
project = Project.find(project_id)
|
||||
if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# 无需执行上链操作
|
||||
return
|
||||
end
|
||||
|
||||
pull_request_id = model['id']
|
||||
identifier = project['identifier']
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
|
||||
action = 'opened'
|
||||
|
||||
title = model['title']
|
||||
content = model['body']
|
||||
|
||||
source_branch = model['head']
|
||||
source_repo_id = model['fork_project_id'].nil? ? project_id : model['fork_project_id']
|
||||
|
||||
target_branch = model['base']
|
||||
target_repo_id = project_id
|
||||
|
||||
author_id = model['user_id']
|
||||
author = User.find(author_id)
|
||||
username = author['login']
|
||||
|
||||
created_at = model['created_at']
|
||||
updated_at = model['updated_at']
|
||||
|
||||
# 查询pull request对应的commit信息
|
||||
commits = Gitea::PullRequest::CommitsService.call(ownername, identifier, model['gitea_number'], current_user&.gitea_token)
|
||||
if commits.nil?
|
||||
raise ApplicationService::Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败
|
||||
end
|
||||
commit_shas = []
|
||||
commits.each do |c|
|
||||
commit_shas << c["Sha"]
|
||||
end
|
||||
params = {
|
||||
"request-type": "upload pull request info",
|
||||
"pull_request_id": "gitlink-" + pull_request_id.to_s,
|
||||
"pull_request_number": 0, # trustie没有该字段
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"ownername": ownername,
|
||||
"reponame": identifier,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"source_branch": source_branch,
|
||||
"target_branch": target_branch,
|
||||
"reviewers": [], # trustie没有该字段
|
||||
"commit_shas": commit_shas,
|
||||
"merge_user": "", # trustie没有该字段
|
||||
"created_at": created_at,
|
||||
"updated_at": updated_at
|
||||
}.to_json
|
||||
resp_body = Blockchain::InvokeBlockchainApi.call(params)
|
||||
if resp_body['status'] == 9
|
||||
raise ApplicationService::Error, resp_body['message']
|
||||
elsif resp_body['status'] != 0
|
||||
raise ApplicationService::Error, "区块链接口请求失败."
|
||||
end
|
||||
elsif activity_type == "pull_request_merge"
|
||||
# 调用区块链接口
|
||||
project_id = model['project_id']
|
||||
project = Project.find(project_id)
|
||||
if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# 无需执行上链操作
|
||||
return
|
||||
end
|
||||
|
||||
pull_request_id = model['id']
|
||||
identifier = project['identifier']
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
|
||||
action = 'merged'
|
||||
|
||||
created_at = model['created_at']
|
||||
updated_at = model['updated_at']
|
||||
|
||||
# 查询pull request对应的commit信息
|
||||
commits = Gitea::PullRequest::CommitsService.call(ownername, identifier, model['gitea_number'], current_user&.gitea_token)
|
||||
if commits.nil?
|
||||
raise ApplicationService::Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败
|
||||
end
|
||||
commit_shas = []
|
||||
commits.each do |c|
|
||||
commit_shas << c["Sha"]
|
||||
end
|
||||
|
||||
# 将pull request相关信息写入链上
|
||||
params = {
|
||||
"request-type": "upload pull request info",
|
||||
"pull_request_id": "gitlink-" + pull_request_id.to_s,
|
||||
"pull_request_number": 0, # trustie没有该字段
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"ownername": ownername,
|
||||
"reponame": identifier,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"source_branch": source_branch,
|
||||
"target_branch": target_branch,
|
||||
"reviewers": [], # trustie没有该字段
|
||||
"commit_shas": commit_shas,
|
||||
"merge_user": "", # trustie没有该字段
|
||||
"created_at": created_at,
|
||||
"updated_at": updated_at
|
||||
}.to_json
|
||||
resp_body = Blockchain::InvokeBlockchainApi.call(params)
|
||||
if resp_body['status'] == 9
|
||||
raise ApplicationService::Error, resp_body['message']
|
||||
elsif resp_body['status'] != 0
|
||||
raise ApplicationService::Error, "区块链接口请求失败."
|
||||
end
|
||||
|
||||
|
||||
# 将commit相关信息写入链上
|
||||
commit_shas.each do |commit_sha|
|
||||
commit_diff = Gitea::Commit::DiffService.call(ownername, identifier, commit_sha, owner['gitea_token'])
|
||||
commit = Gitea::Commit::InfoService.call(ownername, identifier, commit_sha, owner['gitea_token'])
|
||||
params = {
|
||||
"request-type": "upload commit info",
|
||||
"commit_hash": commit_sha,
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"author": commit['commit']['author']['name'],
|
||||
"author_email": commit['commit']['author']['email'],
|
||||
"committer": commit['commit']['committer']['name'],
|
||||
"committer_email": commit['commit']['committer']['email'],
|
||||
"author_time": commit['commit']['author']['date'],
|
||||
"committer_time": commit['commit']['committer']['date'],
|
||||
"content": commit['commit']['message'],
|
||||
"commit_diff": commit_diff.present? ? commit_diff['Files'].to_s : ""
|
||||
}.to_json
|
||||
resp_body = Blockchain::InvokeBlockchainApi.call(params)
|
||||
if resp_body['status'] == 7
|
||||
raise ApplicationService::Error, resp_body['message']
|
||||
elsif resp_body['status'] != 0
|
||||
raise ApplicationService::Error, "区块链接口请求失败."
|
||||
end
|
||||
end
|
||||
|
||||
elsif activity_type == "pull_request_refuse"
|
||||
|
||||
# 调用区块链接口
|
||||
project_id = model['project_id']
|
||||
project = Project.find(project_id)
|
||||
if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# 无需执行上链操作
|
||||
return true
|
||||
end
|
||||
|
||||
pull_request_id = model['id']
|
||||
identifier = project['identifier']
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
|
||||
action = 'refused'
|
||||
|
||||
# 将pull request相关信息写入链上
|
||||
params = {
|
||||
"request-type": "upload pull request info",
|
||||
"pull_request_id": "gitlink-" + pull_request_id.to_s,
|
||||
"pull_request_number": 0, # trustie没有该字段
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"ownername": ownername,
|
||||
"reponame": identifier,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"source_branch": source_branch,
|
||||
"target_branch": target_branch,
|
||||
"reviewers": [], # trustie没有该字段
|
||||
"commit_shas": commit_shas,
|
||||
"merge_user": "", # trustie没有该字段
|
||||
"created_at": created_at,
|
||||
"updated_at": updated_at
|
||||
}.to_json
|
||||
resp_body = Blockchain::InvokeBlockchainApi.call(params)
|
||||
if resp_body['status'] == 9
|
||||
raise ApplicationService::Error, resp_body['message']
|
||||
elsif resp_body['status'] != 0
|
||||
raise ApplicationService::Error, "区块链接口请求失败."
|
||||
end
|
||||
end
|
||||
end
|
||||
def find_atme_receivers
|
||||
@atme_receivers = User.where(login: params[:receivers_login])
|
||||
end
|
||||
|
||||
# 接口限流,请求量大有性能问题
|
||||
def request_limit
|
||||
record_count = Rails.cache.read("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H%M')}/#{request.remote_ip}")
|
||||
if record_count.present?
|
||||
record_count = record_count + 1
|
||||
else
|
||||
record_count = 1
|
||||
end
|
||||
tip_exception("请求太快,请稍后再试。") if record_count > 100
|
||||
|
||||
Rails.cache.write("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H%M')}/#{request.remote_ip}", record_count, expires_in: 1.minute)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -31,21 +31,16 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
def get_file
|
||||
normal_status(-1, "参数缺失") if params[:download_url].blank?
|
||||
url = base_url.starts_with?("https:") ? params[:download_url].to_s.gsub("http:", "https:") : params[:download_url].to_s
|
||||
if url.starts_with?(base_url) && !url.starts_with?("#{base_url}/repo")
|
||||
url = base_url.starts_with?("https:") ? URI.encode(params[:download_url].to_s.gsub("http:", "https:")) : URI.encode(params[:download_url].to_s)
|
||||
if url.starts_with?(base_url)
|
||||
domain = GiteaService.gitea_config[:domain]
|
||||
api_url = GiteaService.gitea_config[:base_url]
|
||||
url = ("/repos"+url.split(base_url + "/api")[1])
|
||||
filepath, ref = url.split("/")[-1].split("?")
|
||||
url.gsub!(url.split("/")[-1], '')
|
||||
Rails.logger.info("url===#{url}")
|
||||
Rails.logger.info(filepath)
|
||||
request_url = [domain, api_url, URI.encode(url), URI.escape(filepath), "?ref=#{URI.escape(ref.split('ref=')[1])}&access_token=#{User.where(admin: true).take&.gitea_token}"].join
|
||||
Rails.logger.info("request_url===#{request_url}")
|
||||
url = ("/repos"+url.split(base_url + "/api")[1]).gsub('?filepath=', '/').gsub('&', '?')
|
||||
request_url = [domain, api_url, url, "?ref=#{params[:ref]}&access_token=#{current_user&.gitea_token}"].join
|
||||
response = Faraday.get(request_url)
|
||||
filename = filepath
|
||||
filename = url.to_s.split("/").pop()
|
||||
else
|
||||
response = Faraday.get(URI.encode(url))
|
||||
response = Faraday.get(url)
|
||||
filename = params[:download_url].to_s.split("/").pop()
|
||||
end
|
||||
send_data(response.body.force_encoding("UTF-8"), filename: filename, type: "application/octet-stream", disposition: 'attachment')
|
||||
|
@ -94,10 +89,6 @@ class AttachmentsController < ApplicationController
|
|||
@attachment.author_id = current_user.id
|
||||
@attachment.disk_directory = month_folder
|
||||
@attachment.cloud_url = remote_path
|
||||
@attachment.uuid = SecureRandom.uuid
|
||||
@attachment.description = params[:description]
|
||||
@attachment.container_id = params[:container_id]
|
||||
@attachment.container_type = params[:container_type]
|
||||
@attachment.save!
|
||||
else
|
||||
logger.info "文件已存在,id = #{@attachment.id}, filename = #{@attachment.filename}"
|
||||
|
@ -127,7 +118,7 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
# 附件为视频时,点击播放
|
||||
def preview_attachment
|
||||
attachment = Attachment.where_id_or_uuid(params[:id]).first
|
||||
attachment = Attachment.find_by(id: params[:id])
|
||||
dir_path = "#{Rails.root}/public/preview"
|
||||
Dir.mkdir(dir_path) unless Dir.exist?(dir_path)
|
||||
if params[:status] == "preview"
|
||||
|
@ -147,14 +138,12 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
private
|
||||
def find_file
|
||||
tip_exception(404, "您访问的页面不存在或已被删除") if params[:id].blank?
|
||||
@file =
|
||||
if params[:type] == 'history'
|
||||
AttachmentHistory.find params[:id]
|
||||
else
|
||||
Attachment.where_id_or_uuid(params[:id]).first
|
||||
Attachment.find params[:id]
|
||||
end
|
||||
tip_exception(404, "您访问的页面不存在或已被删除") if @file.blank?
|
||||
end
|
||||
|
||||
def delete_file(file_path)
|
||||
|
@ -224,22 +213,21 @@ class AttachmentsController < ApplicationController
|
|||
def attachment_candown
|
||||
unless current_user.admin? || current_user.business?
|
||||
candown = true
|
||||
if @file.container && @file.uuid.nil?
|
||||
if @file.container.is_a?(Issue)
|
||||
project = @file.container.project
|
||||
candown = project.is_public || (current_user.logged? && project.member?(current_user))
|
||||
elsif @file.container.is_a?(Journal)
|
||||
project = @file.container.issue.project
|
||||
candown = project.is_public || (current_user.logged? && project.member?(current_user))
|
||||
elsif @file.container.is_a?(Project)
|
||||
project = @file.container
|
||||
candown = project.is_public || (current_user.logged? && project.member?(current_user))
|
||||
else
|
||||
project = nil
|
||||
unless params[:type] == 'history'
|
||||
if @file.container && current_user.logged?
|
||||
if @file.container.is_a?(Issue)
|
||||
course = @file.container.project
|
||||
candown = course.member?(current_user) || course.is_public
|
||||
elsif @file.container.is_a?(Journal)
|
||||
course = @file.container.issue.project
|
||||
candown = course.member?(current_user) || course.is_public
|
||||
else
|
||||
course = nil
|
||||
end
|
||||
tip_exception(403, "您没有权限进入") if course.present? && !candown
|
||||
tip_exception(403, "您没有权限进入") if @file.container.is_a?(ApplyUserAuthentication)
|
||||
end
|
||||
tip_exception(403, "您没有权限进入") if project.present? && !candown
|
||||
end
|
||||
tip_exception(403, "您没有权限查看") if @file.is_public == 0 && @file.author_id != current_user.id
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,19 +1,35 @@
|
|||
class BindUsersController < ApplicationController
|
||||
# before_action :require_login
|
||||
|
||||
def create
|
||||
Rails.logger.debug "--------------开始绑定用户------------"
|
||||
Rails.logger.debug "--------------params: #{params.to_unsafe_h}"
|
||||
tip_exception '系统错误' if session[:unionid].blank?
|
||||
# user = CreateBindUserService.call(create_params)
|
||||
#
|
||||
if params[:type] == "qq"
|
||||
begin
|
||||
user = CreateBindUserService.call(current_user, create_params)
|
||||
successful_authentication(user) if user.id != current_user.id
|
||||
|
||||
bind_user = User.try_to_login(params[:username], params[:password])
|
||||
tip_exception '用户名或者密码错误' if bind_user.blank?
|
||||
tip_exception '用户名或者密码错误' unless bind_user.check_password?(params[:password].to_s)
|
||||
tip_exception '参数错误' unless ["qq", "wechat", "gitee", "github", "educoder", "acge"].include?(params[:type].to_s)
|
||||
tip_exception '该账号已被绑定,请更换其他账号进行绑定' if bind_user.bind_open_user?(params[:type].to_s)
|
||||
render_ok
|
||||
rescue ApplicationService::Error => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
else
|
||||
begin
|
||||
tip_exception '系统错误' if session[:unionid].blank?
|
||||
|
||||
"OpenUsers::#{params[:type].to_s.capitalize}".constantize.create!(user: bind_user, uid: session[:unionid])
|
||||
successful_authentication(bind_user)
|
||||
@user = bind_user
|
||||
bind_user = User.try_to_login(params[:username], params[:password])
|
||||
tip_exception '用户名或者密码错误' if bind_user.blank?
|
||||
tip_exception '用户名或者密码错误' unless bind_user.check_password?(params[:password].to_s)
|
||||
tip_exception '该账号已被绑定,请更换其他账号进行绑定' if bind_user.bind_open_user?(params[:type].to_s)
|
||||
|
||||
OpenUsers::Wechat.create!(user: bind_user, uid: session[:unionid])
|
||||
successful_authentication(bind_user)
|
||||
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
render_error(e.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new_user
|
||||
|
|
|
@ -39,7 +39,6 @@ class ClaimsController < ApplicationController
|
|||
|
||||
journal = Journal.new(journal_params)
|
||||
if journal.save
|
||||
SendTemplateMessageJob.perform_later('IssueClaim', current_user.id, @issue&.id)
|
||||
render file: 'app/views/claims/list.json.jbuilder'
|
||||
else
|
||||
normal_status(-1,"新建声明关联评论操作失败")
|
||||
|
|
|
@ -19,11 +19,9 @@ class CommitLogsController < ApplicationController
|
|||
params[:commits].each do |commit|
|
||||
commit_id = commit[:id]
|
||||
message = commit[:message]
|
||||
commit_date = Time.parse(commit[:timestamp]) || Time.now
|
||||
commit_log = CommitLog.create(user: user, project: project, repository_id: repository_id,
|
||||
CommitLog.create(user: user, project: project, repository_id: repository_id,
|
||||
name: repository_name, full_name: repository_full_name,
|
||||
ref: ref, commit_id: commit_id, message: message, created_at: commit_date, updated_at: commit_date)
|
||||
commit_log.project_trends.create(user_id: user.id, project_id: project&.id, action_type: "create") if user.id !=2
|
||||
ref: ref, commit_id: commit_id, message: message)
|
||||
# 统计数据新增
|
||||
CacheAsyncSetJob.perform_later("project_common_service", {commits: 1}, project.id)
|
||||
end
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue