Compare commits

..

No commits in common. "master" and "feature" have entirely different histories.

939 changed files with 1392830 additions and 77094 deletions

5
.gitignore vendored
View File

@ -10,7 +10,7 @@
# Ignore lock config file # Ignore lock config file
*.log *.log
.env
# mac # mac
*.DS_Store *.DS_Store
.bashrc .bashrc
@ -81,8 +81,7 @@ db/bak/
docker/ docker/
educoder.sql educoder.sql
redis_data/ redis_data/
Dockerfile
dump.rdb dump.rdb
.tags* .tags*
ceshi_user.xlsx ceshi_user.xlsx
public/trace_task_results
public/项目活跃度排行.xls

View File

@ -1,59 +0,0 @@
FROM ubuntu:20.04
RUN apt-get update
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-get install -y nodejs
WORKDIR /home/app/gitlink
ADD ./ /home/app/gitlink
RUN cd /home/app/gitlink
RUN /bin/bash -l -c 'gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/'
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 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 /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'
EXPOSE 4000
RUN /bin/bash -l -c 'RAILS_ENV=production puma -C config/puma.rb'

View File

@ -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"

26
Gemfile
View File

@ -1,10 +1,9 @@
#source 'https://gems.ruby-china.com' source 'https://gems.ruby-china.com'
source 'https://mirrors.cloud.tencent.com/rubygems/'
git_source(:github) { |repo| "https://github.com/#{repo}.git" } git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'rails', '~> 5.2.0' gem 'rails', '~> 5.2.0'
gem 'mysql2', '>= 0.4.4', '< 0.6.0' gem 'mysql2', '>= 0.4.4', '< 0.6.0'
gem 'puma', '~> 5.6.5' gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0' gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0' gem 'uglifier', '>= 1.3.0'
@ -23,7 +22,7 @@ gem 'chinese_pinyin'
gem 'rack-cors' gem 'rack-cors'
gem 'redis-rails' gem 'redis-rails'
gem 'roo-xls' gem 'roo-xls'
gem 'simple_xlsx_reader', '~>1.0.4' gem 'simple_xlsx_reader'
gem 'rubyzip' gem 'rubyzip'
@ -53,7 +52,7 @@ gem 'acts_as_list'
gem 'omniauth-cas' gem 'omniauth-cas'
# profiler Middleware # profiler Middleware
# gem 'rack-mini-profiler' gem 'rack-mini-profiler'
# object-based searching # object-based searching
gem 'ransack' gem 'ransack'
@ -99,10 +98,9 @@ gem 'font-awesome-sass', '4.7.0'
gem 'rails-i18n', '~> 5.1' gem 'rails-i18n', '~> 5.1'
# job # job
gem 'sidekiq',"5.2.8" gem 'sidekiq'
gem 'sinatra' gem 'sinatra'
gem "sidekiq-cron", "1.2.0" gem "sidekiq-cron", "~> 1.1"
gem 'sidekiq-failures'
# batch insert # batch insert
gem 'bulk_insert' gem 'bulk_insert'
@ -120,10 +118,6 @@ gem 'deep_cloneable', '~> 3.0.0'
# oauth2 # oauth2
gem 'omniauth', '~> 1.9.0' gem 'omniauth', '~> 1.9.0'
gem 'omniauth-oauth2', '~> 1.6.0' 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 # global var
gem 'request_store' gem 'request_store'
@ -134,11 +128,3 @@ gem 'harmonious_dictionary', '~> 0.0.1'
gem 'parallel', '~> 1.19', '>= 1.19.1' gem 'parallel', '~> 1.19', '>= 1.19.1'
gem 'letter_avatar' gem 'letter_avatar'
gem 'jwt'
gem 'doorkeeper'
gem 'doorkeeper-jwt'
gem 'gitea-client', '~> 1.4.6'

View File

@ -1,5 +1,5 @@
GEM GEM
remote: https://mirrors.cloud.tencent.com/rubygems/ remote: https://gems.ruby-china.com/
specs: specs:
aasm (5.0.6) aasm (5.0.6)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@ -106,12 +106,6 @@ GEM
activerecord (>= 3.1.0, < 7) activerecord (>= 3.1.0, < 7)
diff-lcs (1.3) diff-lcs (1.3)
diffy (3.3.0) diffy (3.3.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
doorkeeper (5.5.1)
railties (>= 5)
doorkeeper-jwt (0.4.1)
jwt (>= 2.1)
e2mmap (0.1.0) e2mmap (0.1.0)
elasticsearch (7.5.0) elasticsearch (7.5.0)
elasticsearch-api (= 7.5.0) elasticsearch-api (= 7.5.0)
@ -135,8 +129,6 @@ GEM
fugit (1.4.1) fugit (1.4.1)
et-orbi (~> 1.1, >= 1.1.8) et-orbi (~> 1.1, >= 1.1.8)
raabro (~> 1.4) raabro (~> 1.4)
gitea-client (1.4.2)
rest-client (~> 2.1.0)
globalid (0.4.2) globalid (0.4.2)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
grape-entity (0.7.1) grape-entity (0.7.1)
@ -147,9 +139,6 @@ GEM
harmonious_dictionary (0.0.1) harmonious_dictionary (0.0.1)
hashie (3.6.0) hashie (3.6.0)
htmlentities (4.3.4) htmlentities (4.3.4)
http-accept (1.7.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
i18n (1.8.2) i18n (1.8.2)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
io-like (0.3.1) io-like (0.3.1)
@ -187,9 +176,6 @@ GEM
mimemagic (~> 0.3.2) mimemagic (~> 0.3.2)
maruku (0.7.3) maruku (0.7.3)
method_source (0.9.2) method_source (0.9.2)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0218.1)
mimemagic (0.3.10) mimemagic (0.3.10)
nokogiri (~> 1) nokogiri (~> 1)
rake rake
@ -203,7 +189,6 @@ GEM
mustermann (1.1.1) mustermann (1.1.1)
ruby2_keywords (~> 0.0.1) ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3) mysql2 (0.5.3)
netrc (0.11.0)
nio4r (2.5.2) nio4r (2.5.2)
nokogiri (1.10.8) nokogiri (1.10.8)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
@ -220,21 +205,9 @@ GEM
addressable (~> 2.3) addressable (~> 2.3)
nokogiri (~> 1.5) nokogiri (~> 1.5)
omniauth (~> 1.2) 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) omniauth-oauth2 (1.6.0)
oauth2 (~> 1.1) oauth2 (~> 1.1)
omniauth (~> 1.9) 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) parallel (1.19.1)
parser (2.7.1.1) parser (2.7.1.1)
ast (~> 2.4.0) ast (~> 2.4.0)
@ -245,12 +218,13 @@ GEM
powerpack (0.1.2) powerpack (0.1.2)
prettier (0.18.2) prettier (0.18.2)
public_suffix (4.0.3) public_suffix (4.0.3)
puma (5.6.5) puma (3.12.2)
nio4r (~> 2.0)
raabro (1.4.0) raabro (1.4.0)
rack (2.0.9) rack (2.0.9)
rack-cors (1.1.1) rack-cors (1.1.1)
rack (>= 2.0.0) rack (>= 2.0.0)
rack-mini-profiler (2.0.1)
rack (>= 1.2.0)
rack-protection (2.0.8.1) rack-protection (2.0.8.1)
rack rack
rack-test (1.1.0) rack-test (1.1.0)
@ -314,11 +288,6 @@ GEM
regexp_parser (1.7.0) regexp_parser (1.7.0)
request_store (1.5.0) request_store (1.5.0)
rack (>= 1.4) 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 (1.4.0)
nokogiri nokogiri
roo (2.8.3) roo (2.8.3)
@ -396,8 +365,6 @@ GEM
sidekiq-cron (1.2.0) sidekiq-cron (1.2.0)
fugit (~> 1.1) fugit (~> 1.1)
sidekiq (>= 4.2.1) sidekiq (>= 4.2.1)
sidekiq-failures (1.0.4)
sidekiq (>= 4.0.0)
simple_form (5.0.2) simple_form (5.0.2)
actionpack (>= 5.0) actionpack (>= 5.0)
activemodel (>= 5.0) activemodel (>= 5.0)
@ -447,9 +414,6 @@ GEM
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (4.2.0) uglifier (4.2.0)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (1.6.1) unicode-display_width (1.6.1)
web-console (3.7.0) web-console (3.7.0)
actionview (>= 5.0) actionview (>= 5.0)
@ -486,18 +450,14 @@ DEPENDENCIES
chromedriver-helper chromedriver-helper
deep_cloneable (~> 3.0.0) deep_cloneable (~> 3.0.0)
diffy diffy
doorkeeper
doorkeeper-jwt
enumerize enumerize
faraday (~> 0.15.4) faraday (~> 0.15.4)
font-awesome-sass (= 4.7.0) font-awesome-sass (= 4.7.0)
gitea-client (~> 1.4.2)
grape-entity (~> 0.7.1) grape-entity (~> 0.7.1)
groupdate (~> 4.1.0) groupdate (~> 4.1.0)
harmonious_dictionary (~> 0.0.1) harmonious_dictionary (~> 0.0.1)
jbuilder (~> 2.5) jbuilder (~> 2.5)
jquery-rails jquery-rails
jwt
kaminari (~> 1.1, >= 1.1.1) kaminari (~> 1.1, >= 1.1.1)
letter_avatar letter_avatar
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
@ -505,16 +465,13 @@ DEPENDENCIES
oauth2 oauth2
omniauth (~> 1.9.0) omniauth (~> 1.9.0)
omniauth-cas omniauth-cas
omniauth-gitee (~> 1.0.0)
omniauth-github
omniauth-oauth2 (~> 1.6.0) omniauth-oauth2 (~> 1.6.0)
omniauth-rails_csrf_protection
omniauth-wechat-oauth2
parallel (~> 1.19, >= 1.19.1) parallel (~> 1.19, >= 1.19.1)
pdfkit pdfkit
prettier prettier
puma (~> 5.6.5) puma (~> 3.11)
rack-cors rack-cors
rack-mini-profiler
rails (~> 5.2.0) rails (~> 5.2.0)
rails-i18n (~> 5.1) rails-i18n (~> 5.1)
ransack ransack
@ -532,11 +489,10 @@ DEPENDENCIES
sass-rails (~> 5.0) sass-rails (~> 5.0)
searchkick searchkick
selenium-webdriver selenium-webdriver
sidekiq (= 5.2.8) sidekiq
sidekiq-cron (= 1.2.0) sidekiq-cron (~> 1.1)
sidekiq-failures
simple_form simple_form
simple_xlsx_reader (~> 1.0.4) simple_xlsx_reader
sinatra sinatra
solargraph (~> 0.38.0) solargraph (~> 0.38.0)
spreadsheet spreadsheet

106
README.md
View File

@ -3,14 +3,13 @@
GitLink确实开源是中国计算机学会CCF官方指定的开源创新服务平台旨在以“为开源创新服务”为使命以“成为开源创新的汇聚地”为愿景秉承“创新、开放、协作、共享”的价值观致力于为大规模开源开放协同创新助力赋能打造创新成果孵化和新工科人才培养的开源创新生态 GitLink确实开源是中国计算机学会CCF官方指定的开源创新服务平台旨在以“为开源创新服务”为使命以“成为开源创新的汇聚地”为愿景秉承“创新、开放、协作、共享”的价值观致力于为大规模开源开放协同创新助力赋能打造创新成果孵化和新工科人才培养的开源创新生态
<center> <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>
## 特色功能 ## 特色功能
- **分布式协作开发**基于Git打造分布式代码托管环境提供免费公、私有代码仓库支持在线文件编辑、代码分支管理、协作贡献统计、代码仓库复刻Fork、贡献合并请求PR、群智贡献审阅等功能让您的项目在这里健康、快速的成长 - **分布式协作开发**基于Git打造分布式代码托管环境提供免费公、私有代码仓库支持在线文件编辑、代码分支管理、协作贡献统计、代码仓库复刻Fork、贡献合并请求PR、群智贡献审阅等功能让您的项目在这里健康、快速的成长
- **一站式过程管理**:提供Issue、里程碑、通知提醒、标签归档等多样化任务管理工具支持各类开发任务的发布、指派与跟踪同时提供在线Wiki文档、组织多粒度管理等功能为您搭建一站式的项目过程管理环境让您的团队协作更高效、过程更透明 - **一站式过程管理**:提供Issue、里程碑、通知提醒、标签归档等多样化任务管理工具支持各类开发任务的发布、指派与跟踪同时提供在线Wiki文档、组织多粒度管理等功能为您搭建一站式的项目过程管理环境让您的团队协作更高效、过程更透明
- **高效流水线运维**融合DevOps思想提供轻量级的工作流引擎Engine打通编码、测试、构建、部署等开发运维环节支持自定义配置、代码静态扫描、构建自动触发、容器镜像托管等功能同时支持接入第三方运维工具让您的代码更加快速、可靠地形成高质量的产品 - **高效流水线运维**融合DevOps思想提供轻量级的工作流引擎Engine打通编码、测试、构建、部署等开发运维环节支持自定义配置、代码静态扫描、构建自动触发、容器镜像托管等功能同时支持接入第三方运维工具让您的代码更加快速、可靠地形成高质量的产品
@ -35,52 +34,18 @@ GitLink确实开源是中国计算机学会CCF官方指定的开源
* imagemagick * imagemagick
### 步骤 ### 步骤
1安装 Rails 必要的一些三方库:
- Mac OS X 1克隆稳定版本
```bash
brew install imagemagick ghostscript libxml2 libxslt libiconv
``` ```
- Ubuntu
```bash
sudo apt-get update
sudo apt-get install -y openssl libssl-dev imagemagick git ruby-dev nodejs libmariadb-dev libmysqlclient-dev shared-mime-info libpq-dev libxml2-dev libxslt-dev
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y tzdata
sudo ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
```
2安装 Ruby, Rails 运行环境:[如何快速正确的安装 Ruby, Rails 运行环境](https://ruby-china.org/wiki/install_ruby_guide)
```bash
#检验环境是否正确
ruby -v
#ruby 2.4.x ...
gem -v
#3.x.x
bundle -v
#Bundler version 2.x.x
rails -v
#Rails 5.2.x
```
3克隆稳定版本
```bash
git clone -b master https://gitlink.org.cn/Gitlink/forgeplus.git git clone -b master https://gitlink.org.cn/Gitlink/forgeplus.git
``` ```
4)安装依赖包 2安装依赖包
```bash ```bash
#进入目录 cd forgeplus && bundle install
cd forgeplus
#删除Gemfile.lock
rm -rf Gemfile.lock
#安装依赖包
bundle install
``` ```
5)配置初始化文件:进入项目根目录执行以下命令 3配置初始化文件进入项目根目录执行以下命令
```bash ```bash
cp config/configuration.yml.example config/configuration.yml cp config/configuration.yml.example config/configuration.yml
cp config/database.yml.example config/database.yml cp config/database.yml.example config/database.yml
@ -88,8 +53,8 @@ touch config/redis.yml
touch config/elasticsearch.yml touch config/elasticsearch.yml
``` ```
6)配置数据库:数据库配置信息请查看/config/database.yml文件项目默认采用mysql数据库, 如需更改,请自行修改配置信息,默认配置如下 4)配置数据库:数据库配置信息请查看/config/database.yml文件项目默认采用mysql数据库, 如需更改,请自行修改配置信息,默认配置如下
```yaml ```bash
default: &default default: &default
adapter: mysql2 adapter: mysql2
host: 127.0.0.1 host: 127.0.0.1
@ -98,7 +63,7 @@ default: &default
password: 123456 password: 123456
``` ```
7配置gitea服务(可选)如需要部署自己的gitea平台请参考[gitea官方平台文档](https://docs.gitea.io/zh-cn/install-from-binary/)。因目前gitea平台api受限暂时推荐从forge平台获取[gitea部署文件](https://www.gitlink.org.cn/Gitlink/gitea-binary)进行部署 5配置gitea服务(可选)如需要部署自己的gitea平台请参考[gitea官方平台文档](https://docs.gitea.io/zh-cn/install-from-binary/)。因目前gitea平台api受限暂时推荐从forge平台获取[gitea部署文件](https://www.gitlink.org.cn/Gitlink/gitea-binary)进行部署
- 配置gitea服务步骤 - 配置gitea服务步骤
@ -106,68 +71,69 @@ default: &default
-- 修改forge平台的 config/configuration.yml中的gitea服务指向地址 -- 修改forge平台的 config/configuration.yml中的gitea服务指向地址
```yaml ```ruby
gitea: gitea:
access_key_id: 'root' access_key_id: 'root'
access_key_secret: 'password' access_key_secret: 'password'
domain: 'http://www.gitea.example.com' domain: 'http://www.gitea.example.com'
base_url: '/api/v1' base_url: '/api/v1'
hat_base_url: '/api/hat'
``` ```
8配置/config/database.yml文件(安装redis环境:请自行搜索各平台如何安装部署redis环境) 6安装redis环境请自行搜索各平台如何安装部署redis环境
```yaml
default: &default
url: redis://localhost:6379
db: 1
production: 7安装imagemagick插件
<<: *default - Mac OS X
url: redis://localhost:6379 ```bash
brew install imagemagick ghostscript
``` ```
9创建数据库开发环境为development 生成环境为production - Linux
```bash
sudo apt-get install -y imagemagick
```
8创建数据库开发环境为development 生成环境为production
```bash ```bash
rails db:create RAILS_ENV=development rails db:create RAILS_ENV=development
``` ```
10导入数据表结构 9)导入数据表结构
```bash ```bash
bundle exec rake sync_table_structure:import_csv bundle exec rake sync_table_structure:import_csv
``` ```
11执行migrate迁移文件开发环境为development 生成环境为production 10执行migrate迁移文件开发环境为development 生成环境为production
```bash ```bash
rails db:migrate RAILS_ENV=development rails db:migrate RAILS_ENV=development
``` ```
12clone前端代码将前端代码克隆到public/react目录下目录结构应该是: public/react/build 11clone前端代码将前端代码克隆到public/react目录下目录结构应该是: public/react/build
```bash ```bash
git clone -b master https://gitlink.org.cn/Gitlink/build.git git clone -b standalone https://gitlink.org.cn/Gitlink/build.git
``` ```
13启动redis(此处以macOS系统为例) 12启动redis(此处以macOS系统为例)
```bash ```bash
redis-server& redis-server&
``` ```
14启动sidekiq开发环境为development 生成环境为production 13启动sidekiq开发环境为development 生成环境为production
```bash ```bash
bundle exec sidekiq -C config/sidekiq.yml -e production -d bundle exec sidekiq -C config/sidekiq.yml -e production -d
``` ```
15启动rails服务 14启动rails服务
```bash ```bash
rails s rails s
``` ```
16)浏览器访问:在浏览器中输入如下地址访问 15)浏览器访问:在浏览器中输入如下地址访问
```bash ```bash
http://localhost:3000/ http://localhost:3000/
``` ```
17)其他说明:通过页面注册以第一个用户为平台管理员用户 16)其他说明:通过页面注册以第一个用户为平台管理员用户
## 页面展示 ## 页面展示
@ -175,31 +141,31 @@ http://localhost:3000/
- 项目列表 - 项目列表
<center> <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>
- 代码仓库 - 代码仓库
<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>
- 任务管理 - 任务管理
<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>
- 合并请求 - 合并请求
<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>
- 引擎配置 - 引擎配置
<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> </center>

View File

@ -14,7 +14,6 @@
//= require bootstrap-datepicker //= require bootstrap-datepicker
//= require bootstrap-datetimepicker //= require bootstrap-datetimepicker
//= require bootstrap.viewer //= require bootstrap.viewer
//= require bootstrap/bootstrap-toggle
//= require jquery.mloading //= require jquery.mloading
//= require jquery-confirm.min //= require jquery-confirm.min
//= require common //= require common

View File

@ -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.

View File

@ -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.

View File

@ -63,7 +63,7 @@ $(document).on('turbolinks:load', function() {
if(!valid) return; if(!valid) return;
$.ajax({ $.ajax({
method: 'PUT', method: 'PATCH',
dataType: 'json', dataType: 'json',
url: $form.attr('action'), url: $form.attr('action'),
data: new FormData($form[0]), data: new FormData($form[0]),

View File

@ -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.

View File

@ -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' });
}
});
}
})
});
}
});

View File

@ -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.

View File

@ -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.

View File

@ -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 ***************** // ***************** reward grade modal *****************
var $rewardGradeModal = $('.admin-users-reward-grade-modal'); var $rewardGradeModal = $('.admin-users-reward-grade-modal');

View File

@ -1,180 +0,0 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.js v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
+function ($) {
'use strict';
// TOGGLE PUBLIC CLASS DEFINITION
// ==============================
var Toggle = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, this.defaults(), options)
this.render()
}
Toggle.VERSION = '2.2.0'
Toggle.DEFAULTS = {
on: 'On',
off: 'Off',
onstyle: 'primary',
offstyle: 'default',
size: 'normal',
style: '',
width: null,
height: null
}
Toggle.prototype.defaults = function() {
return {
on: this.$element.attr('data-on') || Toggle.DEFAULTS.on,
off: this.$element.attr('data-off') || Toggle.DEFAULTS.off,
onstyle: this.$element.attr('data-onstyle') || Toggle.DEFAULTS.onstyle,
offstyle: this.$element.attr('data-offstyle') || Toggle.DEFAULTS.offstyle,
size: this.$element.attr('data-size') || Toggle.DEFAULTS.size,
style: this.$element.attr('data-style') || Toggle.DEFAULTS.style,
width: this.$element.attr('data-width') || Toggle.DEFAULTS.width,
height: this.$element.attr('data-height') || Toggle.DEFAULTS.height
}
}
Toggle.prototype.render = function () {
this._onstyle = 'btn-' + this.options.onstyle
this._offstyle = 'btn-' + this.options.offstyle
var size = this.options.size === 'large' ? 'btn-lg'
: this.options.size === 'small' ? 'btn-sm'
: this.options.size === 'mini' ? 'btn-xs'
: ''
var $toggleOn = $('<label class="btn">').html(this.options.on)
.addClass(this._onstyle + ' ' + size)
var $toggleOff = $('<label class="btn">').html(this.options.off)
.addClass(this._offstyle + ' ' + size + ' active')
var $toggleHandle = $('<span class="toggle-handle btn btn-default">')
.addClass(size)
var $toggleGroup = $('<div class="toggle-group">')
.append($toggleOn, $toggleOff, $toggleHandle)
var $toggle = $('<div class="toggle btn" data-toggle="toggle">')
.addClass( this.$element.prop('checked') ? this._onstyle : this._offstyle+' off' )
.addClass(size).addClass(this.options.style)
this.$element.wrap($toggle)
$.extend(this, {
$toggle: this.$element.parent(),
$toggleOn: $toggleOn,
$toggleOff: $toggleOff,
$toggleGroup: $toggleGroup
})
this.$toggle.append($toggleGroup)
var width = this.options.width || Math.max($toggleOn.outerWidth(), $toggleOff.outerWidth())+($toggleHandle.outerWidth()/2)
var height = this.options.height || Math.max($toggleOn.outerHeight(), $toggleOff.outerHeight())
$toggleOn.addClass('toggle-on')
$toggleOff.addClass('toggle-off')
this.$toggle.css({ width: width, height: height })
if (this.options.height) {
$toggleOn.css('line-height', $toggleOn.height() + 'px')
$toggleOff.css('line-height', $toggleOff.height() + 'px')
}
this.update(true)
this.trigger(true)
}
Toggle.prototype.toggle = function () {
if (this.$element.prop('checked')) this.off()
else this.on()
}
Toggle.prototype.on = function (silent) {
if (this.$element.prop('disabled')) return false
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
this.$element.prop('checked', true)
if (!silent) this.trigger()
}
Toggle.prototype.off = function (silent) {
if (this.$element.prop('disabled')) return false
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
this.$element.prop('checked', false)
if (!silent) this.trigger()
}
Toggle.prototype.enable = function () {
this.$toggle.removeAttr('disabled')
this.$element.prop('disabled', false)
}
Toggle.prototype.disable = function () {
this.$toggle.attr('disabled', 'disabled')
this.$element.prop('disabled', true)
}
Toggle.prototype.update = function (silent) {
if (this.$element.prop('disabled')) this.disable()
else this.enable()
if (this.$element.prop('checked')) this.on(silent)
else this.off(silent)
}
Toggle.prototype.trigger = function (silent) {
this.$element.off('change.bs.toggle')
if (!silent) this.$element.change()
this.$element.on('change.bs.toggle', $.proxy(function() {
this.update()
}, this))
}
Toggle.prototype.destroy = function() {
this.$element.off('change.bs.toggle')
this.$toggleGroup.remove()
this.$element.removeData('bs.toggle')
this.$element.unwrap()
}
// TOGGLE PLUGIN DEFINITION
// ========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.toggle')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.toggle', (data = new Toggle(this, options)))
if (typeof option == 'string' && data[option]) data[option]()
})
}
var old = $.fn.bootstrapToggle
$.fn.bootstrapToggle = Plugin
$.fn.bootstrapToggle.Constructor = Toggle
// TOGGLE NO CONFLICT
// ==================
$.fn.toggle.noConflict = function () {
$.fn.bootstrapToggle = old
return this
}
// TOGGLE DATA-API
// ===============
$(function() {
$('input[type=checkbox][data-toggle^=toggle]').bootstrapToggle()
})
$(document).on('click.bs.toggle', 'div[data-toggle^=toggle]', function(e) {
var $checkbox = $(this).find('input[type=checkbox]')
$checkbox.bootstrapToggle('toggle')
e.preventDefault()
})
}(jQuery);

View File

@ -1,9 +0,0 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.js v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('<label class="btn">').html(this.options.on).addClass(this._onstyle+" "+b),d=a('<label class="btn">').html(this.options.off).addClass(this._offstyle+" "+b+" active"),e=a('<span class="toggle-handle btn btn-default">').addClass(b),f=a('<div class="toggle-group">').append(c,d,e),g=a('<div class="toggle btn" data-toggle="toggle">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(b).addClass(this.options.style);this.$element.wrap(g),a.extend(this,{$toggle:this.$element.parent(),$toggleOn:c,$toggleOff:d,$toggleGroup:f}),this.$toggle.append(f);var h=this.options.width||Math.max(c.outerWidth(),d.outerWidth())+e.outerWidth()/2,i=this.options.height||Math.max(c.outerHeight(),d.outerHeight());c.addClass("toggle-on"),d.addClass("toggle-off"),this.$toggle.css({width:h,height:i}),this.options.height&&(c.css("line-height",c.height()+"px"),d.css("line-height",d.height()+"px")),this.update(!0),this.trigger(!0)},c.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},c.prototype.on=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),void(a||this.trigger()))},c.prototype.off=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),void(a||this.trigger()))},c.prototype.enable=function(){this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},c.prototype.disable=function(){this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},c.prototype.update=function(a){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(a):this.off(a)},c.prototype.trigger=function(b){this.$element.off("change.bs.toggle"),b||this.$element.change(),this.$element.on("change.bs.toggle",a.proxy(function(){this.update()},this))},c.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var d=a.fn.bootstrapToggle;a.fn.bootstrapToggle=b,a.fn.bootstrapToggle.Constructor=c,a.fn.toggle.noConflict=function(){return a.fn.bootstrapToggle=d,this},a(function(){a("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),a(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(b){var c=a(this).find("input[type=checkbox]");c.bootstrapToggle("toggle"),b.preventDefault()})}(jQuery);
//# sourceMappingURL=bootstrap-toggle.min.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"bootstrap-toggle.min.js","sources":["bootstrap-toggle.js"],"names":["$","Plugin","option","this","each","$this","data","options","Toggle","element","$element","extend","defaults","render","VERSION","DEFAULTS","on","off","onstyle","offstyle","size","style","width","height","prototype","attr","_onstyle","_offstyle","$toggleOn","html","addClass","$toggleOff","$toggleHandle","$toggleGroup","append","$toggle","prop","wrap","parent","Math","max","outerWidth","outerHeight","css","update","trigger","toggle","silent","removeClass","enable","removeAttr","disable","change","proxy","destroy","remove","removeData","unwrap","old","fn","bootstrapToggle","Constructor","noConflict","document","e","$checkbox","find","preventDefault","jQuery"],"mappings":";;;;;;;CASE,SAAUA,GACV,YAoID,SAASC,GAAOC,GACf,MAAOC,MAAKC,KAAK,WAChB,GAAIC,GAAUL,EAAEG,MACZG,EAAUD,EAAMC,KAAK,aACrBC,EAA2B,gBAAVL,IAAsBA,CAEtCI,IAAMD,EAAMC,KAAK,YAAcA,EAAO,GAAIE,GAAOL,KAAMI,IACvC,gBAAVL,IAAsBI,EAAKJ,IAASI,EAAKJ,OAtItD,GAAIM,GAAS,SAAUC,EAASF,GAC/BJ,KAAKO,SAAYV,EAAES,GACnBN,KAAKI,QAAYP,EAAEW,UAAWR,KAAKS,WAAYL,GAC/CJ,KAAKU,SAGNL,GAAOM,QAAW,QAElBN,EAAOO,UACNC,GAAI,KACJC,IAAK,MACLC,QAAS,UACTC,SAAU,UACVC,KAAM,SACNC,MAAO,GACPC,MAAO,KACPC,OAAQ,MAGTf,EAAOgB,UAAUZ,SAAW,WAC3B,OACCI,GAAIb,KAAKO,SAASe,KAAK,YAAcjB,EAAOO,SAASC,GACrDC,IAAKd,KAAKO,SAASe,KAAK,aAAejB,EAAOO,SAASE,IACvDC,QAASf,KAAKO,SAASe,KAAK,iBAAmBjB,EAAOO,SAASG,QAC/DC,SAAUhB,KAAKO,SAASe,KAAK,kBAAoBjB,EAAOO,SAASI,SACjEC,KAAMjB,KAAKO,SAASe,KAAK,cAAgBjB,EAAOO,SAASK,KACzDC,MAAOlB,KAAKO,SAASe,KAAK,eAAiBjB,EAAOO,SAASM,MAC3DC,MAAOnB,KAAKO,SAASe,KAAK,eAAiBjB,EAAOO,SAASO,MAC3DC,OAAQpB,KAAKO,SAASe,KAAK,gBAAkBjB,EAAOO,SAASQ,SAI/Df,EAAOgB,UAAUX,OAAS,WACzBV,KAAKuB,SAAW,OAASvB,KAAKI,QAAQW,QACtCf,KAAKwB,UAAY,OAASxB,KAAKI,QAAQY,QACvC,IAAIC,GAA6B,UAAtBjB,KAAKI,QAAQa,KAAmB,SAClB,UAAtBjB,KAAKI,QAAQa,KAAmB,SACV,SAAtBjB,KAAKI,QAAQa,KAAkB,SAC/B,GACCQ,EAAY5B,EAAE,uBAAuB6B,KAAK1B,KAAKI,QAAQS,IACzDc,SAAS3B,KAAKuB,SAAW,IAAMN,GAC7BW,EAAa/B,EAAE,uBAAuB6B,KAAK1B,KAAKI,QAAQU,KAC1Da,SAAS3B,KAAKwB,UAAY,IAAMP,EAAO,WACrCY,EAAgBhC,EAAE,gDACpB8B,SAASV,GACPa,EAAejC,EAAE,8BACnBkC,OAAON,EAAWG,EAAYC,GAC5BG,EAAUnC,EAAE,iDACd8B,SAAU3B,KAAKO,SAAS0B,KAAK,WAAajC,KAAKuB,SAAWvB,KAAKwB,UAAU,QACzEG,SAASV,GAAMU,SAAS3B,KAAKI,QAAQc,MAEvClB,MAAKO,SAAS2B,KAAKF,GACnBnC,EAAEW,OAAOR,MACRgC,QAAShC,KAAKO,SAAS4B,SACvBV,UAAWA,EACXG,WAAYA,EACZE,aAAcA,IAEf9B,KAAKgC,QAAQD,OAAOD,EAEpB,IAAIX,GAAQnB,KAAKI,QAAQe,OAASiB,KAAKC,IAAIZ,EAAUa,aAAcV,EAAWU,cAAeT,EAAcS,aAAa,EACpHlB,EAASpB,KAAKI,QAAQgB,QAAUgB,KAAKC,IAAIZ,EAAUc,cAAeX,EAAWW,cACjFd,GAAUE,SAAS,aACnBC,EAAWD,SAAS,cACpB3B,KAAKgC,QAAQQ,KAAMrB,MAAOA,EAAOC,OAAQA,IACrCpB,KAAKI,QAAQgB,SAChBK,EAAUe,IAAI,cAAef,EAAUL,SAAW,MAClDQ,EAAWY,IAAI,cAAeZ,EAAWR,SAAW,OAErDpB,KAAKyC,QAAO,GACZzC,KAAK0C,SAAQ,IAGdrC,EAAOgB,UAAUsB,OAAS,WACrB3C,KAAKO,SAAS0B,KAAK,WAAYjC,KAAKc,MACnCd,KAAKa,MAGXR,EAAOgB,UAAUR,GAAK,SAAU+B,GAC/B,MAAI5C,MAAKO,SAAS0B,KAAK,aAAoB,GAC3CjC,KAAKgC,QAAQa,YAAY7C,KAAKwB,UAAY,QAAQG,SAAS3B,KAAKuB,UAChEvB,KAAKO,SAAS0B,KAAK,WAAW,QACzBW,GAAQ5C,KAAK0C,aAGnBrC,EAAOgB,UAAUP,IAAM,SAAU8B,GAChC,MAAI5C,MAAKO,SAAS0B,KAAK,aAAoB,GAC3CjC,KAAKgC,QAAQa,YAAY7C,KAAKuB,UAAUI,SAAS3B,KAAKwB,UAAY,QAClExB,KAAKO,SAAS0B,KAAK,WAAW,QACzBW,GAAQ5C,KAAK0C,aAGnBrC,EAAOgB,UAAUyB,OAAS,WACzB9C,KAAKgC,QAAQe,WAAW,YACxB/C,KAAKO,SAAS0B,KAAK,YAAY,IAGhC5B,EAAOgB,UAAU2B,QAAU,WAC1BhD,KAAKgC,QAAQV,KAAK,WAAY,YAC9BtB,KAAKO,SAAS0B,KAAK,YAAY,IAGhC5B,EAAOgB,UAAUoB,OAAS,SAAUG,GAC/B5C,KAAKO,SAAS0B,KAAK,YAAajC,KAAKgD,UACpChD,KAAK8C,SACN9C,KAAKO,SAAS0B,KAAK,WAAYjC,KAAKa,GAAG+B,GACtC5C,KAAKc,IAAI8B,IAGfvC,EAAOgB,UAAUqB,QAAU,SAAUE,GACpC5C,KAAKO,SAASO,IAAI,oBACb8B,GAAQ5C,KAAKO,SAAS0C,SAC3BjD,KAAKO,SAASM,GAAG,mBAAoBhB,EAAEqD,MAAM,WAC5ClD,KAAKyC,UACHzC,QAGJK,EAAOgB,UAAU8B,QAAU,WAC1BnD,KAAKO,SAASO,IAAI,oBAClBd,KAAK8B,aAAasB,SAClBpD,KAAKO,SAAS8C,WAAW,aACzBrD,KAAKO,SAAS+C,SAiBf,IAAIC,GAAM1D,EAAE2D,GAAGC,eAEf5D,GAAE2D,GAAGC,gBAA8B3D,EACnCD,EAAE2D,GAAGC,gBAAgBC,YAAcrD,EAKnCR,EAAE2D,GAAGb,OAAOgB,WAAa,WAExB,MADA9D,GAAE2D,GAAGC,gBAAkBF,EAChBvD,MAMRH,EAAE,WACDA,EAAE,6CAA6C4D,oBAGhD5D,EAAE+D,UAAU/C,GAAG,kBAAmB,2BAA4B,SAASgD,GACtE,GAAIC,GAAYjE,EAAEG,MAAM+D,KAAK,uBAC7BD,GAAUL,gBAAgB,UAC1BI,EAAEG,oBAGFC"}

View File

@ -1,180 +0,0 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap2-toggle.js v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
+function ($) {
'use strict';
// TOGGLE PUBLIC CLASS DEFINITION
// ==============================
var Toggle = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, this.defaults(), options)
this.render()
}
Toggle.VERSION = '2.2.0'
Toggle.DEFAULTS = {
on: 'On',
off: 'Off',
onstyle: 'primary',
offstyle: 'default',
size: 'normal',
style: '',
width: null,
height: null
}
Toggle.prototype.defaults = function() {
return {
on: this.$element.attr('data-on') || Toggle.DEFAULTS.on,
off: this.$element.attr('data-off') || Toggle.DEFAULTS.off,
onstyle: this.$element.attr('data-onstyle') || Toggle.DEFAULTS.onstyle,
offstyle: this.$element.attr('data-offstyle') || Toggle.DEFAULTS.offstyle,
size: this.$element.attr('data-size') || Toggle.DEFAULTS.size,
style: this.$element.attr('data-style') || Toggle.DEFAULTS.style,
width: this.$element.attr('data-width') || Toggle.DEFAULTS.width,
height: this.$element.attr('data-height') || Toggle.DEFAULTS.height
}
}
Toggle.prototype.render = function () {
this._onstyle = 'btn-' + this.options.onstyle
this._offstyle = 'btn-' + this.options.offstyle
var size = this.options.size === 'large' ? 'btn-large'
: this.options.size === 'small' ? 'btn-small'
: this.options.size === 'mini' ? 'btn-mini'
: ''
var $toggleOn = $('<label class="btn">').html(this.options.on)
.addClass(this._onstyle + ' ' + size)
var $toggleOff = $('<label class="btn">').html(this.options.off)
.addClass(this._offstyle + ' ' + size + ' active')
var $toggleHandle = $('<span class="toggle-handle btn btn-default">')
.addClass(size)
var $toggleGroup = $('<div class="toggle-group">')
.append($toggleOn, $toggleOff, $toggleHandle)
var $toggle = $('<div class="toggle btn" data-toggle="toggle">')
.addClass( this.$element.prop('checked') ? this._onstyle : this._offstyle+' off' )
.addClass(size).addClass(this.options.style)
this.$element.wrap($toggle)
$.extend(this, {
$toggle: this.$element.parent(),
$toggleOn: $toggleOn,
$toggleOff: $toggleOff,
$toggleGroup: $toggleGroup
})
this.$toggle.append($toggleGroup)
var width = this.options.width || Math.max($toggleOn.width(), $toggleOff.width())+($toggleHandle.outerWidth()/2)
var height = this.options.height || Math.max($toggleOn.height(), $toggleOff.height())
$toggleOn.addClass('toggle-on')
$toggleOff.addClass('toggle-off')
this.$toggle.css({ width: width, height: height })
if (this.options.height) {
$toggleOn.css('line-height', $toggleOn.height() + 'px')
$toggleOff.css('line-height', $toggleOff.height() + 'px')
}
this.update(true)
this.trigger(true)
}
Toggle.prototype.toggle = function () {
if (this.$element.prop('checked')) this.off()
else this.on()
}
Toggle.prototype.on = function (silent) {
if (this.$element.prop('disabled')) return false
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
this.$element.prop('checked', true)
if (!silent) this.trigger()
}
Toggle.prototype.off = function (silent) {
if (this.$element.prop('disabled')) return false
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
this.$element.prop('checked', false)
if (!silent) this.trigger()
}
Toggle.prototype.enable = function () {
this.$toggle.removeAttr('disabled')
this.$element.prop('disabled', false)
}
Toggle.prototype.disable = function () {
this.$toggle.attr('disabled', 'disabled')
this.$element.prop('disabled', true)
}
Toggle.prototype.update = function (silent) {
if (this.$element.prop('disabled')) this.disable()
else this.enable()
if (this.$element.prop('checked')) this.on(silent)
else this.off(silent)
}
Toggle.prototype.trigger = function (silent) {
this.$element.off('change.bs.toggle')
if (!silent) this.$element.change()
this.$element.on('change.bs.toggle', $.proxy(function() {
this.update()
}, this))
}
Toggle.prototype.destroy = function() {
this.$element.off('change.bs.toggle')
this.$toggleGroup.remove()
this.$element.removeData('bs.toggle')
this.$element.unwrap()
}
// TOGGLE PLUGIN DEFINITION
// ========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.toggle')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.toggle', (data = new Toggle(this, options)))
if (typeof option == 'string' && data[option]) data[option]()
})
}
var old = $.fn.bootstrapToggle
$.fn.bootstrapToggle = Plugin
$.fn.bootstrapToggle.Constructor = Toggle
// TOGGLE NO CONFLICT
// ==================
$.fn.toggle.noConflict = function () {
$.fn.bootstrapToggle = old
return this
}
// TOGGLE DATA-API
// ===============
$(function() {
$('input[type=checkbox][data-toggle^=toggle]').bootstrapToggle()
})
$(document).on('click.bs.toggle', 'div[data-toggle^=toggle]', function(e) {
var $checkbox = $(this).find('input[type=checkbox]')
$checkbox.bootstrapToggle('toggle')
e.preventDefault()
})
}(jQuery);

View File

@ -1,9 +0,0 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap2-toggle.js v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-large":"small"===this.options.size?"btn-small":"mini"===this.options.size?"btn-mini":"",c=a('<label class="btn">').html(this.options.on).addClass(this._onstyle+" "+b),d=a('<label class="btn">').html(this.options.off).addClass(this._offstyle+" "+b+" active"),e=a('<span class="toggle-handle btn btn-default">').addClass(b),f=a('<div class="toggle-group">').append(c,d,e),g=a('<div class="toggle btn" data-toggle="toggle">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(b).addClass(this.options.style);this.$element.wrap(g),a.extend(this,{$toggle:this.$element.parent(),$toggleOn:c,$toggleOff:d,$toggleGroup:f}),this.$toggle.append(f);var h=this.options.width||Math.max(c.width(),d.width())+e.outerWidth()/2,i=this.options.height||Math.max(c.height(),d.height());c.addClass("toggle-on"),d.addClass("toggle-off"),this.$toggle.css({width:h,height:i}),this.options.height&&(c.css("line-height",c.height()+"px"),d.css("line-height",d.height()+"px")),this.update(!0),this.trigger(!0)},c.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},c.prototype.on=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),void(a||this.trigger()))},c.prototype.off=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),void(a||this.trigger()))},c.prototype.enable=function(){this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},c.prototype.disable=function(){this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},c.prototype.update=function(a){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(a):this.off(a)},c.prototype.trigger=function(b){this.$element.off("change.bs.toggle"),b||this.$element.change(),this.$element.on("change.bs.toggle",a.proxy(function(){this.update()},this))},c.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var d=a.fn.bootstrapToggle;a.fn.bootstrapToggle=b,a.fn.bootstrapToggle.Constructor=c,a.fn.toggle.noConflict=function(){return a.fn.bootstrapToggle=d,this},a(function(){a("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),a(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(b){var c=a(this).find("input[type=checkbox]");c.bootstrapToggle("toggle"),b.preventDefault()})}(jQuery);
//# sourceMappingURL=bootstrap2-toggle.min.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"bootstrap2-toggle.min.js","sources":["bootstrap2-toggle.js"],"names":["$","Plugin","option","this","each","$this","data","options","Toggle","element","$element","extend","defaults","render","VERSION","DEFAULTS","on","off","onstyle","offstyle","size","style","width","height","prototype","attr","_onstyle","_offstyle","$toggleOn","html","addClass","$toggleOff","$toggleHandle","$toggleGroup","append","$toggle","prop","wrap","parent","Math","max","outerWidth","css","update","trigger","toggle","silent","removeClass","enable","removeAttr","disable","change","proxy","destroy","remove","removeData","unwrap","old","fn","bootstrapToggle","Constructor","noConflict","document","e","$checkbox","find","preventDefault","jQuery"],"mappings":";;;;;;;CASE,SAAUA,GACV,YAoID,SAASC,GAAOC,GACf,MAAOC,MAAKC,KAAK,WAChB,GAAIC,GAAUL,EAAEG,MACZG,EAAUD,EAAMC,KAAK,aACrBC,EAA2B,gBAAVL,IAAsBA,CAEtCI,IAAMD,EAAMC,KAAK,YAAcA,EAAO,GAAIE,GAAOL,KAAMI,IACvC,gBAAVL,IAAsBI,EAAKJ,IAASI,EAAKJ,OAtItD,GAAIM,GAAS,SAAUC,EAASF,GAC/BJ,KAAKO,SAAYV,EAAES,GACnBN,KAAKI,QAAYP,EAAEW,UAAWR,KAAKS,WAAYL,GAC/CJ,KAAKU,SAGNL,GAAOM,QAAW,QAElBN,EAAOO,UACNC,GAAI,KACJC,IAAK,MACLC,QAAS,UACTC,SAAU,UACVC,KAAM,SACNC,MAAO,GACPC,MAAO,KACPC,OAAQ,MAGTf,EAAOgB,UAAUZ,SAAW,WAC3B,OACCI,GAAIb,KAAKO,SAASe,KAAK,YAAcjB,EAAOO,SAASC,GACrDC,IAAKd,KAAKO,SAASe,KAAK,aAAejB,EAAOO,SAASE,IACvDC,QAASf,KAAKO,SAASe,KAAK,iBAAmBjB,EAAOO,SAASG,QAC/DC,SAAUhB,KAAKO,SAASe,KAAK,kBAAoBjB,EAAOO,SAASI,SACjEC,KAAMjB,KAAKO,SAASe,KAAK,cAAgBjB,EAAOO,SAASK,KACzDC,MAAOlB,KAAKO,SAASe,KAAK,eAAiBjB,EAAOO,SAASM,MAC3DC,MAAOnB,KAAKO,SAASe,KAAK,eAAiBjB,EAAOO,SAASO,MAC3DC,OAAQpB,KAAKO,SAASe,KAAK,gBAAkBjB,EAAOO,SAASQ,SAI/Df,EAAOgB,UAAUX,OAAS,WACzBV,KAAKuB,SAAW,OAASvB,KAAKI,QAAQW,QACtCf,KAAKwB,UAAY,OAASxB,KAAKI,QAAQY,QACvC,IAAIC,GAA6B,UAAtBjB,KAAKI,QAAQa,KAAmB,YAClB,UAAtBjB,KAAKI,QAAQa,KAAmB,YACV,SAAtBjB,KAAKI,QAAQa,KAAkB,WAC/B,GACCQ,EAAY5B,EAAE,uBAAuB6B,KAAK1B,KAAKI,QAAQS,IACzDc,SAAS3B,KAAKuB,SAAW,IAAMN,GAC7BW,EAAa/B,EAAE,uBAAuB6B,KAAK1B,KAAKI,QAAQU,KAC1Da,SAAS3B,KAAKwB,UAAY,IAAMP,EAAO,WACrCY,EAAgBhC,EAAE,gDACpB8B,SAASV,GACPa,EAAejC,EAAE,8BACnBkC,OAAON,EAAWG,EAAYC,GAC5BG,EAAUnC,EAAE,iDACd8B,SAAU3B,KAAKO,SAAS0B,KAAK,WAAajC,KAAKuB,SAAWvB,KAAKwB,UAAU,QACzEG,SAASV,GAAMU,SAAS3B,KAAKI,QAAQc,MAEvClB,MAAKO,SAAS2B,KAAKF,GACnBnC,EAAEW,OAAOR,MACRgC,QAAShC,KAAKO,SAAS4B,SACvBV,UAAWA,EACXG,WAAYA,EACZE,aAAcA,IAEf9B,KAAKgC,QAAQD,OAAOD,EAEpB,IAAIX,GAAQnB,KAAKI,QAAQe,OAASiB,KAAKC,IAAIZ,EAAUN,QAASS,EAAWT,SAAUU,EAAcS,aAAa,EAC1GlB,EAASpB,KAAKI,QAAQgB,QAAUgB,KAAKC,IAAIZ,EAAUL,SAAUQ,EAAWR,SAC5EK,GAAUE,SAAS,aACnBC,EAAWD,SAAS,cACpB3B,KAAKgC,QAAQO,KAAMpB,MAAOA,EAAOC,OAAQA,IACrCpB,KAAKI,QAAQgB,SAChBK,EAAUc,IAAI,cAAed,EAAUL,SAAW,MAClDQ,EAAWW,IAAI,cAAeX,EAAWR,SAAW,OAErDpB,KAAKwC,QAAO,GACZxC,KAAKyC,SAAQ,IAGdpC,EAAOgB,UAAUqB,OAAS,WACrB1C,KAAKO,SAAS0B,KAAK,WAAYjC,KAAKc,MACnCd,KAAKa,MAGXR,EAAOgB,UAAUR,GAAK,SAAU8B,GAC/B,MAAI3C,MAAKO,SAAS0B,KAAK,aAAoB,GAC3CjC,KAAKgC,QAAQY,YAAY5C,KAAKwB,UAAY,QAAQG,SAAS3B,KAAKuB,UAChEvB,KAAKO,SAAS0B,KAAK,WAAW,QACzBU,GAAQ3C,KAAKyC,aAGnBpC,EAAOgB,UAAUP,IAAM,SAAU6B,GAChC,MAAI3C,MAAKO,SAAS0B,KAAK,aAAoB,GAC3CjC,KAAKgC,QAAQY,YAAY5C,KAAKuB,UAAUI,SAAS3B,KAAKwB,UAAY,QAClExB,KAAKO,SAAS0B,KAAK,WAAW,QACzBU,GAAQ3C,KAAKyC,aAGnBpC,EAAOgB,UAAUwB,OAAS,WACzB7C,KAAKgC,QAAQc,WAAW,YACxB9C,KAAKO,SAAS0B,KAAK,YAAY,IAGhC5B,EAAOgB,UAAU0B,QAAU,WAC1B/C,KAAKgC,QAAQV,KAAK,WAAY,YAC9BtB,KAAKO,SAAS0B,KAAK,YAAY,IAGhC5B,EAAOgB,UAAUmB,OAAS,SAAUG,GAC/B3C,KAAKO,SAAS0B,KAAK,YAAajC,KAAK+C,UACpC/C,KAAK6C,SACN7C,KAAKO,SAAS0B,KAAK,WAAYjC,KAAKa,GAAG8B,GACtC3C,KAAKc,IAAI6B,IAGftC,EAAOgB,UAAUoB,QAAU,SAAUE,GACpC3C,KAAKO,SAASO,IAAI,oBACb6B,GAAQ3C,KAAKO,SAASyC,SAC3BhD,KAAKO,SAASM,GAAG,mBAAoBhB,EAAEoD,MAAM,WAC5CjD,KAAKwC,UACHxC,QAGJK,EAAOgB,UAAU6B,QAAU,WAC1BlD,KAAKO,SAASO,IAAI,oBAClBd,KAAK8B,aAAaqB,SAClBnD,KAAKO,SAAS6C,WAAW,aACzBpD,KAAKO,SAAS8C,SAiBf,IAAIC,GAAMzD,EAAE0D,GAAGC,eAEf3D,GAAE0D,GAAGC,gBAA8B1D,EACnCD,EAAE0D,GAAGC,gBAAgBC,YAAcpD,EAKnCR,EAAE0D,GAAGb,OAAOgB,WAAa,WAExB,MADA7D,GAAE0D,GAAGC,gBAAkBF,EAChBtD,MAMRH,EAAE,WACDA,EAAE,6CAA6C2D,oBAGhD3D,EAAE8D,UAAU9C,GAAG,kBAAmB,2BAA4B,SAAS+C,GACtE,GAAIC,GAAYhE,EAAEG,MAAM8D,KAAK,uBAC7BD,GAAUL,gBAAgB,UAC1BI,EAAEG,oBAGFC"}

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -8,7 +8,6 @@
@import "jquery.mloading"; @import "jquery.mloading";
@import "jquery-confirm.min"; @import "jquery-confirm.min";
@import "bootstrap-datetimepicker.min"; @import "bootstrap-datetimepicker.min";
@import "bootstrap/bootstrap-toggle.min";
@import "codemirror/lib/codemirror"; @import "codemirror/lib/codemirror";
@import "editormd/css/editormd.min"; @import "editormd/css/editormd.min";
@ -205,13 +204,3 @@ input.form-control {
font-size: 1rem; font-size: 1rem;
} }
} }
.table th, .table td {
padding: 0.75rem 0.1rem;
vertical-align: top;
border-top: 1px solid #dee2e6;
}
.table .thead-light th{
white-space: nowrap;
}

View File

@ -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/

View File

@ -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/

View File

@ -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/

View File

@ -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/

View File

@ -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/

View File

@ -1,83 +0,0 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.css v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
.checkbox label .toggle,
.checkbox-inline .toggle {
margin-left: -20px;
margin-right: 5px;
}
.toggle {
position: relative;
overflow: hidden;
}
.toggle input[type="checkbox"] {
display: none;
}
.toggle-group {
position: absolute;
width: 200%;
top: 0;
bottom: 0;
left: 0;
transition: left 0.35s;
-webkit-transition: left 0.35s;
-moz-user-select: none;
-webkit-user-select: none;
}
.toggle.off .toggle-group {
left: -100%;
}
.toggle-on {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 50%;
margin: 0;
border: 0;
border-radius: 0;
}
.toggle-off {
position: absolute;
top: 0;
bottom: 0;
left: 50%;
right: 0;
margin: 0;
border: 0;
border-radius: 0;
}
.toggle-handle {
position: relative;
margin: 0 auto;
padding-top: 0px;
padding-bottom: 0px;
height: 100%;
width: 0px;
border-width: 0 1px;
}
.toggle.btn { min-width: 59px; min-height: 34px; }
.toggle-on.btn { padding-right: 24px; }
.toggle-off.btn { padding-left: 24px; }
.toggle.btn-lg { min-width: 79px; min-height: 45px; }
.toggle-on.btn-lg { padding-right: 31px; }
.toggle-off.btn-lg { padding-left: 31px; }
.toggle-handle.btn-lg { width: 40px; }
.toggle.btn-sm { min-width: 50px; min-height: 30px;}
.toggle-on.btn-sm { padding-right: 20px; }
.toggle-off.btn-sm { padding-left: 20px; }
.toggle.btn-xs { min-width: 35px; min-height: 22px;}
.toggle-on.btn-xs { padding-right: 12px; }
.toggle-off.btn-xs { padding-left: 12px; }

View File

@ -1,28 +0,0 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.css v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px}
.toggle{position:relative;overflow:hidden}
.toggle input[type=checkbox]{display:none}
.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none}
.toggle.off .toggle-group{left:-100%}
.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0}
.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0}
.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px}
.toggle.btn{min-width:59px;min-height:34px}
.toggle-on.btn{padding-right:24px}
.toggle-off.btn{padding-left:24px}
.toggle.btn-lg{min-width:79px;min-height:45px}
.toggle-on.btn-lg{padding-right:31px}
.toggle-off.btn-lg{padding-left:31px}
.toggle-handle.btn-lg{width:40px}
.toggle.btn-sm{min-width:50px;min-height:30px}
.toggle-on.btn-sm{padding-right:20px}
.toggle-off.btn-sm{padding-left:20px}
.toggle.btn-xs{min-width:35px;min-height:22px}
.toggle-on.btn-xs{padding-right:12px}
.toggle-off.btn-xs{padding-left:12px}

View File

@ -1,85 +0,0 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap2-toggle.css v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
label.checkbox .toggle,
label.checkbox.inline .toggle {
margin-left: -20px;
margin-right: 5px;
}
.toggle {
min-width: 40px;
height: 20px;
position: relative;
overflow: hidden;
}
.toggle input[type="checkbox"] {
display: none;
}
.toggle-group {
position: absolute;
width: 200%;
top: 0;
bottom: 0;
left: 0;
transition: left 0.35s;
-webkit-transition: left 0.35s;
-moz-user-select: none;
-webkit-user-select: none;
}
.toggle.off .toggle-group {
left: -100%;
}
.toggle-on {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 50%;
margin: 0;
border: 0;
border-radius: 0;
}
.toggle-off {
position: absolute;
top: 0;
bottom: 0;
left: 50%;
right: 0;
margin: 0;
border: 0;
border-radius: 0;
}
.toggle-handle {
position: relative;
margin: 0 auto;
padding-top: 0px;
padding-bottom: 0px;
height: 100%;
width: 0px;
border-width: 0 1px;
}
.toggle-handle.btn-mini {
top: -1px;
}
.toggle.btn { min-width: 30px; }
.toggle-on.btn { padding-right: 24px; }
.toggle-off.btn { padding-left: 24px; }
.toggle.btn-large { min-width: 40px; }
.toggle-on.btn-large { padding-right: 35px; }
.toggle-off.btn-large { padding-left: 35px; }
.toggle.btn-small { min-width: 25px; }
.toggle-on.btn-small { padding-right: 20px; }
.toggle-off.btn-small { padding-left: 20px; }
.toggle.btn-mini { min-width: 20px; }
.toggle-on.btn-mini { padding-right: 12px; }
.toggle-off.btn-mini { padding-left: 12px; }

View File

@ -1,28 +0,0 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap2-toggle.css v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
label.checkbox .toggle,label.checkbox.inline .toggle{margin-left:-20px;margin-right:5px}
.toggle{min-width:40px;height:20px;position:relative;overflow:hidden}
.toggle input[type=checkbox]{display:none}
.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none}
.toggle.off .toggle-group{left:-100%}
.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0}
.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0}
.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px}
.toggle-handle.btn-mini{top:-1px}
.toggle.btn{min-width:30px}
.toggle-on.btn{padding-right:24px}
.toggle-off.btn{padding-left:24px}
.toggle.btn-large{min-width:40px}
.toggle-on.btn-large{padding-right:35px}
.toggle-off.btn-large{padding-left:35px}
.toggle.btn-small{min-width:25px}
.toggle-on.btn-small{padding-right:20px}
.toggle-off.btn-small{padding-left:20px}
.toggle.btn-mini{min-width:20px}
.toggle-on.btn-mini{padding-right:12px}
.toggle-off.btn-mini{padding-left:12px}

View File

@ -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/

View File

@ -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/

View File

@ -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/

View File

@ -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/

View File

@ -1,26 +1,6 @@
class AccountsController < ApplicationController class AccountsController < ApplicationController
before_action :require_login, only: [:login_check, :simple_update]
include ApplicationHelper include ApplicationHelper
#skip_before_action :check_account, :only => [:logout]
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!
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])
end
end
end
def index def index
render json: session render json: session
end end
@ -112,9 +92,7 @@ class AccountsController < ApplicationController
sync_params = { sync_params = {
password: params[:password].to_s, password: params[:password].to_s,
email: @user.mail, email: @user.mail
login_name: @user.login,
source_id: 0
} }
interactor = Gitea::User::UpdateInteractor.call(@user.login, sync_params) interactor = Gitea::User::UpdateInteractor.call(@user.login, sync_params)
@ -142,7 +120,6 @@ class AccountsController < ApplicationController
Register::Form.new(register_params).validate! Register::Form.new(register_params).validate!
user = Users::RegisterService.call(register_params) user = Users::RegisterService.call(register_params)
user.mail = "#{user.login}@example.org" if user.mail.blank?
password = register_params[:password].strip password = register_params[:password].strip
# gitea用户注册, email, username, password # gitea用户注册, email, username, password
@ -154,18 +131,11 @@ class AccountsController < ApplicationController
user.gitea_uid = gitea_user[:body]['id'] user.gitea_uid = gitea_user[:body]['id']
if user.save! if user.save!
UserExtension.create!(user_id: user.id) 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) successful_authentication(user)
render_ok render_ok
end 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 else
tip_exception(-1, interactor.result[:message]) tip_exception(-1, interactor.error)
end end
rescue Register::BaseForm::EmailError => e rescue Register::BaseForm::EmailError => e
render_result(-2, e.message) render_result(-2, e.message)
@ -180,14 +150,9 @@ class AccountsController < ApplicationController
rescue Register::BaseForm::VerifiCodeError => e rescue Register::BaseForm::VerifiCodeError => e
render_result(-6, e.message) render_result(-6, e.message)
rescue Exception => e rescue Exception => e
if user.present? && !e.message.to_s.include?("user already exists") Gitea::User::DeleteService.call(user.login) unless user.nil?
# Gitea::User::DeleteService.call(user.login) uid_logger_error(e.message)
# user.destroy tip_exception(-1, e.message)
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, "注册失败")
end end
end end
@ -201,12 +166,12 @@ class AccountsController < ApplicationController
return normal_status(-2, "违反平台使用规范,账号已被锁定") if @user.locked? return normal_status(-2, "违反平台使用规范,账号已被锁定") if @user.locked?
login_control = LimitForbidControl::UserLogin.new(@user) 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) password_ok = @user.check_password?(params[:password].to_s)
unless password_ok unless password_ok
if login_control.remain_times-1 == 0 if login_control.remain_times-1 == 0
normal_status(-2, "登录密码出错已达上限,账号已被锁定#{login_control.forbid_expires/60}分钟后重新登录或找回密码") normal_status(-2, "登录密码出错已达上限,账号已被锁定, #{login_control.forbid_expires/60}分钟后重新登录或找回密码")
else else
normal_status(-2, "你已经输错密码#{login_control.error_times+1}次,还剩余#{login_control.remain_times-1}次机会") normal_status(-2, "你已经输错密码#{login_control.error_times+1}次,还剩余#{login_control.remain_times-1}次机会")
end end
@ -214,7 +179,6 @@ class AccountsController < ApplicationController
return return
end end
LimitForbidControl::UserLogin.new(@user).clear
successful_authentication(@user) successful_authentication(@user)
sync_pwd_to_gitea!(@user, {password: params[:password].to_s}) # TODO用户密码未同步 sync_pwd_to_gitea!(@user, {password: params[:password].to_s}) # TODO用户密码未同步
@ -222,9 +186,7 @@ class AccountsController < ApplicationController
end end
def change_password def change_password
return render_error("两次输入的密码不一致") if params[:password].to_s != params[:new_password_repeat].to_s
@user = User.find_by(login: params[:login]) @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("未找到相关用户!") if @user.blank?
return render_error("旧密码不正确") unless @user.check_password?(params[:old_password]) return render_error("旧密码不正确") unless @user.check_password?(params[:old_password])
@ -335,8 +297,6 @@ class AccountsController < ApplicationController
send_type = verify_type(login_type, type) send_type = verify_type(login_type, type)
verification_code = code.sample(6).join 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}") sign = Digest::MD5.hexdigest("#{OPENKEY}#{value}")
tip_exception(501, "请求不合理") if sign != params[:smscode] tip_exception(501, "请求不合理") if sign != params[:smscode]
@ -356,22 +316,6 @@ class AccountsController < ApplicationController
render_ok render_ok
end end
def login_check
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 private
# type 事件类型 1用户注册 2忘记密码 3: 绑定手机 4: 绑定邮箱, 5: 验证手机号是否有效 # 如果有新的继续后面加 # type 事件类型 1用户注册 2忘记密码 3: 绑定手机 4: 绑定邮箱, 5: 验证手机号是否有效 # 如果有新的继续后面加
@ -423,7 +367,7 @@ class AccountsController < ApplicationController
end end
def register_params def register_params
params.permit(:login, :namespace, :password, :password_confirmation, :code, :type) params.permit(:login, :namespace, :password, :password_confirmation, :code)
end end
def reset_password_params def reset_password_params
@ -439,7 +383,4 @@ class AccountsController < ApplicationController
params.permit(:username, :email, :password, :platform) params.permit(:username, :email, :password, :platform)
end end
def simple_update_params
params.permit(:username, :email, :password, :platform)
end
end end

View File

@ -1,95 +1,10 @@
class Admins::DashboardsController < Admins::BaseController class Admins::DashboardsController < Admins::BaseController
def index def index
# 用户活跃数 @active_user_count = User.where(last_login_on: today).count
day_user_ids = CommitLog.where(created_at: today).pluck(:user_id).uniq @weekly_active_user_count = User.where(last_login_on: current_week).count
weekly_user_ids = CommitLog.where(created_at: current_week).pluck(:user_id).uniq @month_active_user_count = User.where(last_login_on: current_month).count
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
user_ids = User.where(created_on: pre_week).pluck(:id).uniq
weekly_keep_user_count = User.where(id: user_ids).where(last_login_on: current_week).count
@weekly_keep_rate = format("%.2f", user_ids.size > 0 ? weekly_keep_user_count.to_f / user_ids.size : 0)
# 新用户注册数
@day_new_user_count = User.where(created_on: today).count
@weekly_new_user_count = User.where(created_on: current_week).count
@month_new_user_count = User.where(created_on: current_month).count
# 活跃项目数
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).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
# 新增项目数
@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)
@new_user_count = User.where(created_on: current_month).count
end end
def month_active_user def month_active_user
@ -101,22 +16,10 @@ class Admins::DashboardsController < Admins::BaseController
{ value: count['professional'].to_i, name: '专业人士' }, { value: count['professional'].to_i, name: '专业人士' },
{ value: count[nil].to_i, name: '未选职业' }, { value: count[nil].to_i, name: '未选职业' },
] ]
render_ok(data: data) render_ok(data: data)
end 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 def evaluate
names = [] names = []
data = [] data = []
@ -138,20 +41,11 @@ class Admins::DashboardsController < Admins::BaseController
Time.now.beginning_of_day..Time.now.end_of_day Time.now.beginning_of_day..Time.now.end_of_day
end end
def pre_7_days
7.days.ago.end_of_day..Time.now.end_of_day
end
def current_week def current_week
Time.now.beginning_of_week..Time.now.end_of_day 7.days.ago.beginning_of_day..Time.now.end_of_day
end end
def current_month def current_month
30.days.ago.end_of_day..Time.now.end_of_day 30.days.ago.beginning_of_day..Time.now.end_of_day
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
end end
end end

View File

@ -1,49 +0,0 @@
class Admins::FeedbacksController < Admins::BaseController
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

View File

@ -1,32 +0,0 @@
class Admins::GlccPrCheckController < Admins::BaseController
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

View File

@ -1,37 +0,0 @@
class Admins::IdentityVerificationsController < Admins::BaseController
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

View File

@ -2,7 +2,7 @@ class Admins::ImportUsersController < Admins::BaseController
def create def create
return render_error('请上传正确的文件') if params[:file].blank? || !params[:file].is_a?(ActionDispatch::Http::UploadedFile) return render_error('请上传正确的文件') if params[:file].blank? || !params[:file].is_a?(ActionDispatch::Http::UploadedFile)
result = Admins::ImportUserFromExcelService.call(params[:file].to_io) result = Admins::ImportUserService.call(params[:file].to_io)
render_ok(result) render_ok(result)
rescue Admins::ImportUserService::Error => ex rescue Admins::ImportUserService::Error => ex
render_error(ex) render_error(ex)

View File

@ -1,29 +0,0 @@
class Admins::IssuesRankController < Admins::BaseController
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

View File

@ -25,6 +25,6 @@ class Admins::LaboratorySettingsController < Admins::BaseController
params.permit(:identifier, :name, params.permit(:identifier, :name,
:nav_logo, :login_logo, :tab_logo, :oj_banner, :nav_logo, :login_logo, :tab_logo, :oj_banner,
:subject_banner, :course_banner, :competition_banner, :moop_cases_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
end end

View File

@ -2,24 +2,8 @@ class Admins::MessageTemplatesController < Admins::BaseController
before_action :get_template, only: [:edit, :update, :destroy] before_action :get_template, only: [:edit, :update, :destroy]
def index def index
message_templates = MessageTemplate.ransack(sys_notice_or_email_or_email_title_cont: params[:search]).result message_templates = MessageTemplate.group(:type).count.keys
@message_templates = kaminari_paginate(message_templates) @message_templates = kaminari_array_paginate(message_templates)
end
def new
@message_template = MessageTemplate.new
end
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] = "创建消息模板成功"
else
render :new
flash[:danger] = "创建消息模板失败"
end
end end
def edit def edit
@ -47,9 +31,7 @@ class Admins::MessageTemplatesController < Admins::BaseController
private private
def message_template_params def message_template_params
# type = @message_template.present? ? @message_template.type : "MessageTemplate::CustomTip" params.require(@message_template.type.split("::").join("_").underscore.to_sym).permit!
# params.require(type.split("::").join("_").underscore.to_sym).permit!
params.require(:message_template_custom_tip).permit!
end end
def get_template def get_template

View File

@ -1,26 +0,0 @@
class Admins::NpsController < Admins::BaseController
def index
@on_off_switch = EduSetting.get("nps-on-off-switch").to_s == 'true'
@user_nps = UserNp.joins(:user).order(created_at: :desc)
keyword = params[:keyword].to_s.strip.presence
if keyword
sql = 'CONCAT(users.lastname, users.firstname) LIKE :keyword OR users.nickname LIKE :keyword OR users.login LIKE :keyword OR users.mail LIKE :keyword OR users.phone LIKE :keyword'
@user_nps = @user_nps.where(sql, keyword: "%#{keyword}%")
end
@user_nps = @user_nps.where("action_type != 'close'") if params[:done_score].present?
@min_score = @user_nps.where("action_type != 'close'").minimum("score")
@max_score = @user_nps.where("action_type != 'close'").maximum("score")
@score_total_count = UserNp.where("action_type !='close'").count
@user_nps = paginate @user_nps.includes(:user)
end
def switch_change
edu_setting = EduSetting.find_by(name: "nps-on-off-switch")
if edu_setting.blank?
edu_setting = EduSetting.new(name: "nps-on-off-switch")
end
edu_setting.value = params[:switch].to_s
edu_setting.save
render_ok
end
end

View File

@ -1,44 +0,0 @@
class Admins::OrganizationsController < Admins::BaseController
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

View File

@ -1,79 +0,0 @@
class Admins::PageThemesController < Admins::BaseController
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

View File

@ -1,6 +1,6 @@
class Admins::ProjectIgnoresController < Admins::BaseController class Admins::ProjectIgnoresController < Admins::BaseController
before_action :set_ignore, only: [:edit,:update, :destroy,:show] before_action :set_ignore, only: [:edit,:update, :destroy,:show]
# before_action :validate_params, only: [:create, :update] before_action :validate_params, only: [:create, :update]
def index def index
sort_by = Ignore.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at' sort_by = Ignore.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
@ -31,12 +31,12 @@ class Admins::ProjectIgnoresController < Admins::BaseController
# } # }
@project_ignore = Ignore.new(ignore_params) @project_ignore = Ignore.new(ignore_params)
if @project_ignore.save if @project_ignore.save!
redirect_to admins_project_ignores_path redirect_to admins_project_ignores_path
flash[:success] = "创建成功" flash[:success] = "创建成功"
else else
redirect_to admins_project_ignores_path render :new
flash[:danger] = @project_ignore.errors.full_messages.join(",") flash[:danger] = "创建失败"
end end
end end
@ -58,8 +58,8 @@ class Admins::ProjectIgnoresController < Admins::BaseController
redirect_to admins_project_ignores_path redirect_to admins_project_ignores_path
flash[:success] = "更新成功" flash[:success] = "更新成功"
else else
redirect_to admins_project_ignores_path render :edit
flash[:danger] = @project_ignore.errors.full_messages.join(",") flash[:danger] = "更新失败"
end end
end end
@ -98,23 +98,23 @@ class Admins::ProjectIgnoresController < Admins::BaseController
params.require(:ignore).permit(:name,:content) params.require(:ignore).permit(:name,:content)
end end
# def validate_params def validate_params
# name = params[:ignore][:name] name = params[:ignore][:name]
# if name.blank? if name.blank?
# flash[:danger] = "名称不允许为空" flash[:danger] = "名称不允许为空"
# redirect_to admins_project_ignores_path redirect_to admins_project_ignores_path
# elsif check_ignore_present?(name) && @project_ignore.blank? elsif check_ignore_present?(name) && @project_ignore.blank?
# flash[:danger] = "创建失败:名称已存在" flash[:danger] = "创建失败:名称已存在"
# redirect_to admins_project_ignores_path redirect_to admins_project_ignores_path
# end end
# end end
# def check_ignore_present?(name) def check_ignore_present?(name)
# return true if name.blank? return true if name.blank?
# name_downcase = name.downcase name_downcase = name.downcase
# name_upcase = name.upcase name_upcase = name.upcase
# name_first_big = name.capitalize name_first_big = name.capitalize
# Ignore.exists?(name: name_downcase) || Ignore.exists?(name: name_upcase) || Ignore.exists?(name: name_first_big) Ignore.exists?(name: name_downcase) || Ignore.exists?(name: name_upcase) || Ignore.exists?(name: name_first_big)
# end end
end end

View File

@ -27,18 +27,17 @@ class Admins::ProjectLanguagesController < Admins::BaseController
flash[:success] = '创建成功' flash[:success] = '创建成功'
else else
redirect_to admins_project_languages_path redirect_to admins_project_languages_path
flash[:danger] = @project_language.errors.full_messages.join(",") flash[:danger] = '创建失败'
end end
end end
def update def update
@project_language.attributes = {name: @name} if @project_language.update_attribute(:name, @name)
if @project_language.save
redirect_to admins_project_languages_path redirect_to admins_project_languages_path
flash[:success] = '更新成功' flash[:success] = '更新成功'
else else
redirect_to admins_project_languages_path redirect_to admins_project_languages_path
flash[:danger] = @project_language.errors.full_messages.join(",") flash[:success] = '更新失败'
end end
end end

View File

@ -1,6 +1,6 @@
class Admins::ProjectLicensesController < Admins::BaseController class Admins::ProjectLicensesController < Admins::BaseController
before_action :set_license, only: [:edit,:update, :destroy,:show] before_action :set_license, only: [:edit,:update, :destroy,:show]
# before_action :validate_params, only: [:create, :update] before_action :validate_params, only: [:create, :update]
def index def index
sort_by = License.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at' sort_by = License.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
@ -30,12 +30,13 @@ class Admins::ProjectLicensesController < Admins::BaseController
# position: max_position # position: max_position
# } # }
@project_license = License.new(license_params) @project_license = License.new(license_params)
if @project_license.save
if @project_license.save!
redirect_to admins_project_licenses_path redirect_to admins_project_licenses_path
flash[:success] = "创建成功" flash[:success] = "创建成功"
else else
redirect_to admins_project_licenses_path render :new
flash[:danger] = @project_license.errors.full_messages.join(",") flash[:danger] = "创建失败"
end end
end end
@ -53,13 +54,12 @@ class Admins::ProjectLicensesController < Admins::BaseController
# permissions: permissions.to_s, # permissions: permissions.to_s,
# limitations: limitations.to_s # limitations: limitations.to_s
# } # }
@project_license.attributes = license_params if @project_license.update_attributes(license_params)
if @project_license.save
redirect_to admins_project_licenses_path redirect_to admins_project_licenses_path
flash[:success] = "更新成功" flash[:success] = "更新成功"
else else
render admins_project_licenses_path render :edit
flash[:danger] = @project_license.errors.full_messages.join(",") flash[:danger] = "更新失败"
end end
end end
@ -98,23 +98,23 @@ class Admins::ProjectLicensesController < Admins::BaseController
params.require(:license).permit(:name,:content) params.require(:license).permit(:name,:content)
end end
# def validate_params def validate_params
# name = params[:license][:name] name = params[:license][:name]
# if name.blank? if name.blank?
# flash[:danger] = "名称不允许为空" flash[:danger] = "名称不允许为空"
# redirect_to admins_project_licenses_path redirect_to admins_project_licenses_path
# elsif check_license_present?(name) && @project_license.blank? elsif check_license_present?(name) && @project_license.blank?
# flash[:danger] = "创建失败:名称已存在" flash[:danger] = "创建失败:名称已存在"
# redirect_to admins_project_licenses_path redirect_to admins_project_licenses_path
# end end
# end end
# def check_license_present?(name) def check_license_present?(name)
# return true if name.blank? return true if name.blank?
# name_downcase = name.downcase name_downcase = name.downcase
# name_upcase = name.upcase name_upcase = name.upcase
# name_first_big = name.capitalize name_first_big = name.capitalize
# License.exists?(name: name_downcase) || License.exists?(name: name_upcase) || License.exists?(name: name_first_big) License.exists?(name: name_downcase) || License.exists?(name: name_upcase) || License.exists?(name: name_first_big)
# end end
end end

View File

@ -35,7 +35,6 @@ class Admins::ProjectsController < Admins::BaseController
Gitea::Repository::DeleteService.new(project.owner, project.identifier).call Gitea::Repository::DeleteService.new(project.owner, project.identifier).call
project.destroy! project.destroy!
# render_delete_success # 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 redirect_to admins_projects_path
flash[:success] = "删除成功" flash[:success] = "删除成功"
end end

View File

@ -1,55 +0,0 @@
class Admins::ProjectsRankController < Admins::BaseController
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 = @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

View File

@ -1,50 +0,0 @@
class Admins::SitePagesController < Admins::BaseController
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

View File

@ -25,7 +25,7 @@ class Admins::SystemNotificationsController < Admins::BaseController
@notification = SystemNotification.new(notification_params) @notification = SystemNotification.new(notification_params)
if @notification.save if @notification.save
redirect_to admins_system_notifications_path redirect_to admins_system_notifications_path
flash[:success] = '系统公告创建成功' flash[:success] = '系统消息创建成功'
else else
redirect_to admins_system_notifications_path redirect_to admins_system_notifications_path
flash[:danger] = @notification.errors.full_messages.join(",") flash[:danger] = @notification.errors.full_messages.join(",")
@ -37,7 +37,7 @@ class Admins::SystemNotificationsController < Admins::BaseController
if @notification.update_attributes(notification_params) if @notification.update_attributes(notification_params)
format.html do format.html do
redirect_to admins_system_notifications_path redirect_to admins_system_notifications_path
flash[:success] = '系统公告更新成功' flash[:success] = '系统消息更新成功'
end end
format.js {render_ok} format.js {render_ok}
else else
@ -53,10 +53,10 @@ class Admins::SystemNotificationsController < Admins::BaseController
def destroy def destroy
if @notification.destroy if @notification.destroy
redirect_to admins_system_notifications_path redirect_to admins_system_notifications_path
flash[:success] = "系统公告删除成功" flash[:success] = "系统消息删除成功"
else else
redirect_to admins_system_notifications_path redirect_to admins_system_notifications_path
flash[:danger] = "系统公告删除失败" flash[:danger] = "系统消息删除失败"
end end
end end

View File

@ -3,7 +3,6 @@ class Admins::Topic::BannersController < Admins::Topic::BaseController
def index def index
@banners = paginate(::Topic::Banner) @banners = paginate(::Topic::Banner)
@banners = paginate(::Topic::Banner.where("title like ?", "%#{params[:search]}%")) if params[:search].present?
end end
def new def new
@ -53,6 +52,6 @@ class Admins::Topic::BannersController < Admins::Topic::BaseController
end end
def banner_params def banner_params
params.require(:topic_banner).permit(:title, :order_index, :url) params.require(:topic_banner).permit(:title, :order_index)
end end
end end

View File

@ -25,7 +25,6 @@ class Admins::UsersController < Admins::BaseController
end end
def destroy 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! @user.destroy!
Gitea::User::DeleteService.call(@user.login) Gitea::User::DeleteService.call(@user.login)
@ -34,7 +33,7 @@ class Admins::UsersController < Admins::BaseController
def lock def lock
@user.lock! @user.lock!
UserAction.create(action_id: @user.id, action_type: "LockUser", user_id: current_user.id, :ip => request.remote_ip)
render_ok render_ok
end end
@ -58,12 +57,6 @@ class Admins::UsersController < Admins::BaseController
render_ok render_ok
end end
def fresh_gitea_token
@user.fresh_gitea_token
render_ok
end
private private
def finder_user def finder_user
@ -71,8 +64,8 @@ class Admins::UsersController < Admins::BaseController
end end
def update_params def update_params
params.require(:user).permit(%i[lastname nickname gender technical_title is_shixun_marker 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 mail phone location location_city school_id department_id admin business is_test
password login website_permission]) password professional_certification authentication login])
end end
end end

View File

@ -1,15 +0,0 @@
class Admins::UsersRankController < Admins::BaseController
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

View File

@ -1,63 +0,0 @@
class Api::V1::BaseController < ApplicationController
include Api::ProjectHelper
include Api::UserHelper
include Api::PullHelper
# before_action :doorkeeper_authorize!
# skip_before_action :user_setup
protected
# def current_user
# #client方法对接需要一直带着用户标识uid
# Rails.logger.info doorkeeper_token
# if doorkeeper_token && doorkeeper_token.resource_owner_id.blank?
# # return User.anonymous if params[:uid].nil?
# # tip_exception("2222")
# # return render_error('缺少用户标识!') if params[:uid].nil?
# User.current = User.find(params[:uid])
# else
# 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
# 具有对仓库的管理权限
def require_manager_above
@project = load_project
return render_forbidden if !current_user.admin? && !@project.manager?(current_user)
end
# 具有对仓库的操作权限
def require_operate_above
@project = load_project
return render_forbidden if !current_user.admin? && !@project.operator?(current_user)
end
# 具有仓库的操作权限或者fork仓库的操作权限
def require_operate_above_or_fork_project
@project = load_project
return render_forbidden if !current_user.admin? && !@project.operator?(current_user) && !(@project.fork_project.present? && @project.fork_project.operator?(current_user))
end
# 具有对仓库的访问权限
def require_public_and_member_above
@project = load_project
return render_forbidden if !@project.is_public && !current_user.admin? && !@project.member?(current_user)
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +0,0 @@
class Api::V1::Projects::Actions::BaseController < Api::V1::BaseController
before_action :require_public_and_member_above
end

View File

@ -1,12 +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 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
end

View File

@ -1,75 +0,0 @@
class Api::V1::Projects::BranchesController < Api::V1::BaseController
before_action :require_public_and_member_above, only: [:index, :all]
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
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]
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删除本仓库分支12删除主仓库分支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

View File

@ -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

View File

@ -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

View File

@ -1,16 +0,0 @@
class Api::V1::Projects::CommitsController < Api::V1::BaseController
before_action :require_public_and_member_above, only: [:index, :diff, :recent]
def index
@result_object = Api::V1::Projects::Commits::ListService.call(@project, {page: page, limit: limit, sha: params[:sha]}, current_user&.gitea_token)
puts @result_object
end
def diff
@result_object = Api::V1::Projects::Commits::DiffService.call(@project, params[:sha], current_user&.gitea_token)
end
def recent
@result_object = Api::V1::Projects::Commits::RecentService.call(@project, {keyword: params[:keyword], page: page, limit: limit}, current_user&.gitea_token)
end
end

View File

@ -1,17 +0,0 @@
class Api::V1::Projects::ContentsController < Api::V1::BaseController
before_action :require_operate_above_or_fork_project, only: [:batch]
def batch
@batch_content_params = batch_content_params
# 处理下author和committer信息如果没传则默认为当前用户信息
@batch_content_params.merge!(author_email: current_user.mail, author_name: current_user.login) if batch_content_params[:author_email].blank? && batch_content_params[:author_name].blank?
@batch_content_params.merge!(committer_email: current_user.mail, committer_name: current_user.login) if batch_content_params[:committer_email].blank? && batch_content_params[:committer_name].blank?
@result_object = Api::V1::Projects::Contents::BatchCreateService.call(@project, @batch_content_params, @project.owner.gitea_token)
end
private
def batch_content_params
params.require(:content).permit(:author_email, :author_name, :author_timeunix, :branch, :committer_email, :committer_name, :committer_timeunix, :message, :new_branch, files: [ :action_type, :content, :encoding, :file_path])
end
end

View File

@ -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

View File

@ -1,12 +0,0 @@
class Api::V1::Projects::GitController < Api::V1::BaseController
before_action :require_public_and_member_above, only: [:trees, :blobs]
def trees
@result_object = Api::V1::Projects::Git::TreesService.call(@project, params[:sha], {recursive: params[:recursive], page: page, limit: limit}, current_user&.gitea_token)
end
def blobs
@result_object = Api::V1::Projects::Git::BlobsService.call(@project, params[:sha], current_user&.gitea_token)
end
end

View File

@ -1,5 +0,0 @@
class Api::V1::Projects::Pulls::BaseController < Api::V1::BaseController
before_action :require_public_and_member_above
before_action :load_pull_request
end

View File

@ -1,40 +0,0 @@
class Api::V1::Projects::Pulls::JournalsController < Api::V1::Projects::Pulls::BaseController
def index
@journals = Api::V1::Projects::Pulls::Journals::ListService.call(@project, @pull_request, params, current_user)
@journals = @journals.limit(200)
end
def create
@journal = Api::V1::Projects::Pulls::Journals::CreateService.call(@project, @pull_request, create_params, current_user)
end
before_action :find_journal, only: [:update, :destroy]
def update
@journal = Api::V1::Projects::Pulls::Journals::UpdateService.call(@project, @pull_request, @journal, update_params, current_user)
end
def destroy
if @journal.destroy
render_ok
else
render_error("删除评论失败!")
end
end
private
def create_params
params.permit(:parent_id, :line_code, :note, :commit_id, :path, :type, :review_id, :diff => {})
end
def update_params
params.permit(:note, :commit_id, :state)
end
def find_journal
@journal = @pull_request.journals.find_by_id(params[:id])
return render_not_found unless @journal.present?
end
end

View File

@ -1,20 +0,0 @@
class Api::V1::Projects::Pulls::PullsController < Api::V1::BaseController
before_action :require_public_and_member_above
def index
@pulls = Api::V1::Projects::Pulls::ListService.call(@project, query_params)
@pulls = kaminari_paginate(@pulls)
end
before_action :load_pull_request, only: [:show]
def show
@result_object = Api::V1::Projects::Pulls::GetService.call(@project, @pull_request, current_user&.gitea_token)
@last_review = @pull_request.reviews.order(created_at: :desc).take
end
private
def query_params
params.permit(:status, :keyword, :priority_id, :issue_tag_id, :version_id, :reviewer_id, :sort_by, :sort_direction)
end
end

View File

@ -1,23 +0,0 @@
class Api::V1::Projects::Pulls::ReviewsController < Api::V1::Projects::Pulls::BaseController
def index
@reviews = @pull_request.reviews
@reviews = @reviews.where(status: params[:status]) if params[:status].present?
# @reviews = kaminari_paginate(@reviews)
end
before_action :require_reviewer, only: [:create]
def create
@review = Api::V1::Projects::Pulls::Reviews::CreateService.call(@project, @pull_request, review_params, current_user)
end
private
def require_reviewer
return render_forbidden('您没有审查权限,请联系项目管理员') if !current_user.admin? && !@pull_request.reviewers.exists?(current_user.id) && !@project.manager?(current_user)
end
def review_params
params.require(:review).permit(:content, :commit_id, :status)
end
end

View File

@ -1,10 +0,0 @@
class Api::V1::Projects::Pulls::VersionsController < Api::V1::Projects::Pulls::BaseController
def index
@result_object = Api::V1::Projects::Pulls::Versions::ListService.call(@project, @pull_request, {page: page, limit: limit}, current_user&.gitea_token)
end
def diff
@result_object = Api::V1::Projects::Pulls::Versions::GetDiffService.call(@project, @pull_request, params[:id], {filepath: params[:filepath]}, current_user&.gitea_token)
end
end

View File

@ -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

View File

@ -1,61 +0,0 @@
class Api::V1::Projects::WebhooksController < Api::V1::BaseController
before_action :require_manager_above
before_action :find_webhook, only: [:show, :update, :destroy, :tests, :hooktasks]
def index
# @result_object = Api::V1::Projects::Webhooks::ListService.call(@project, current_user&.gitea_token)
@webhooks = @project.webhooks
@webhooks = @webhooks.where(type: params[:type]) if params[:type].present?
@webhooks = kaminari_paginate(@webhooks)
end
def create
return render_error("webhooks数量已到上限请删除暂不使用的webhooks以进行添加操作") if @project.webhooks.size > 49
@result_object = Api::V1::Projects::Webhooks::CreateService.call(@project, create_webhook_params, current_user&.gitea_token)
end
def show
@result_object = Api::V1::Projects::Webhooks::GetService.call(@project, params[:id], current_user&.gitea_token)
end
def update
@result_object = Api::V1::Projects::Webhooks::UpdateService.call(@project, params[:id], webhook_params, current_user&.gitea_token)
end
def destroy
@result_object = Api::V1::Projects::Webhooks::DeleteService.call(@project, params[:id], current_user&.gitea_token)
if @result_object
return render_ok
else
return render_error('删除失败!')
end
end
def tests
@result_object = Api::V1::Projects::Webhooks::TestsService.call(@project, params[:id], current_user&.gitea_token)
if @result_object
return render_ok
else
return render_error('推送失败!')
end
end
def hooktasks
@hooktasks = @webhook.tasks.where(is_delivered: true).order("delivered desc")
@hooktasks = kaminari_paginate(@hooktasks)
end
private
def create_webhook_params
params.require(:webhook).permit(:active, :branch_filter, :http_method, :url, :content_type, :secret, :type, events: [])
end
def webhook_params
params.require(:webhook).permit(:active, :branch_filter, :http_method, :url, :content_type, :secret, events: [])
end
def find_webhook
@webhook = Gitea::Webhook.find_by_id(params[:id])
return render_not_found unless @webhook.present?
end
end

View File

@ -1,19 +0,0 @@
class Api::V1::ProjectsController < Api::V1::BaseController
before_action :require_public_and_member_above, only: [:show, :compare, :blame]
def index
render_ok
end
def show
@result_object = Api::V1::Projects::GetService.call(@project, current_user.gitea_token)
end
def compare
@result_object = Api::V1::Projects::CompareService.call(@project, params[:from], params[:to], current_user&.gitea_token)
end
def blame
@result_object = Api::V1::Projects::BlameService.call(@project, params[:sha], params[:filepath], current_user&.gitea_token)
end
end

View File

@ -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

View File

@ -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

View File

@ -1,13 +0,0 @@
class Api::V1::Users::ProjectsController < Api::V1::BaseController
before_action :load_observe_user
def index
@object_results = Api::V1::Users::Projects::ListService.call(@observe_user, query_params, current_user)
@projects = kaminari_paginate(@object_results)
end
private
def query_params
params.permit(:category, :is_public, :project_type, :sort_by, :sort_direction, :search)
end
end

View File

@ -1,118 +0,0 @@
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
def send_email_vefify_code
code = %W(0 1 2 3 4 5 6 7 8 9)
verification_code = code.sample(6).join
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?
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!
rescue Exception => e
logger_error(e)
tip_exception(-2,"邮件发送失败,请稍后重试")
end
ver_params = {code_type: code_type, code: verification_code, email: mail}
last_code = VerificationCode.where(code_type: code_type, email: mail).last
last_code.update_attributes!({created_at: Time.current - 10.minute}) if last_code.present?
data = VerificationCode.new(ver_params)
if data.save!
render_ok
else
tip_exception(-1, "创建数据失败")
end
end
def check_password
password = params[:password]
return tip_exception(-5, "8~16位密码支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD
return tip_exception(-5, "密码错误") unless @observe_user.check_password?(password)
render_ok
end
def check_email
mail = strip(params[:email])
return tip_exception(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL
exist_owner = Owner.find_by(mail: mail)
return tip_exception(-2, '邮箱已被使用') if exist_owner
render_ok
end
def check_email_verify_code
code = strip(params[:code])
mail = strip(params[:email])
code_type = params[:code_type]
return tip_exception(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL
verifi_code = VerificationCode.where(email: mail, 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 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
return render_ok
else
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

View File

@ -1,6 +1,4 @@
require 'oauth2' require 'oauth2'
# require 'openssl'
# require 'jwt'
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include CodeExample include CodeExample
@ -22,9 +20,9 @@ class ApplicationController < ActionController::Base
# TODO # TODO
# check sql query time # check sql query time
before_action do before_action do
# if request.subdomain === 'testforgeplus' || request.subdomain === "profiler" if request.subdomain === 'testforgeplus' || request.subdomain === "profiler"
# Rack::MiniProfiler.authorize_request Rack::MiniProfiler.authorize_request
# end end
end end
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
@ -81,7 +79,8 @@ class ApplicationController < ActionController::Base
# 判断用户的邮箱或者手机是否可用 # 判断用户的邮箱或者手机是否可用
# params[:type] 1: 注册2忘记密码3绑定 # params[:type] 1: 注册2忘记密码3绑定
def check_mail_and_phone_valid login, type 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, "请输入正确的手机号或邮箱") tip_exception(-2, "请输入正确的手机号或邮箱")
end end
@ -104,30 +103,23 @@ class ApplicationController < ActionController::Base
when 1, 2, 4, 9 when 1, 2, 4, 9
# 手机类型的发送 # 手机类型的发送
sigle_para = {phone: value} sigle_para = {phone: value}
# status = Gitlink::Sms.send(mobile: value, code: code) status = Gitlink::Sms.send(mobile: value, code: code)
# tip_exception(-2, code_msg(status)) if status != 0 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
when 8, 3, 5 when 8, 3, 5
# 邮箱类型的发送 # 邮箱类型的发送
sigle_para = {email: value} sigle_para = {email: value}
# 60s内不能重复发送 # 60s内不能重复发送
# send_email_limit_cache_key = "send_email_60_second_limit:#{value}" send_email_limit_cache_key = "send_email_60_second_limit:#{value}"
# tip_exception(-1, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key) tip_exception(-1, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
# # 短时间内不能大量发送 # 短时间内不能大量发送
# send_email_control = LimitForbidControl::SendEmailCode.new(value) send_email_control = LimitForbidControl::SendEmailCode.new(value)
# tip_exception(-1, '邮件发送太频繁,请稍后再试') if send_email_control.forbid? tip_exception(-1, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
begin begin
if send_type == 3 UserMailer.register_email(value, code).deliver_now
UserMailer.find_password(value, code).deliver_now
elsif send_type == 5 Rails.cache.write(send_email_limit_cache_key, 1, expires_in: 1.minute)
UserMailer.bind_email(value, code).deliver_now send_email_control.increment!
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!
# Mailer.run.email_register(code, value) # Mailer.run.email_register(code, value)
rescue Exception => e rescue Exception => e
logger_error(e) logger_error(e)
@ -157,27 +149,6 @@ class ApplicationController < ActionController::Base
end end
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) def validate_type(object_type)
normal_status(2, "参数") if params.has_key?(:sort_type) && !SORT_TYPE.include?(params[:sort_type].strip) normal_status(2, "参数") if params.has_key?(:sort_type) && !SORT_TYPE.include?(params[:sort_type].strip)
end end
@ -199,25 +170,7 @@ class ApplicationController < ActionController::Base
# 未授权的捕捉407弹试用申请弹框 # 未授权的捕捉407弹试用申请弹框
def require_login def require_login
#6.13 -hs #6.13 -hs
tip_exception(401, "请登录后再操作") unless User.current.logged?
end
def require_login_or_token
if params[:token].present?
user = User.try_to_autologin(params[:token])
User.current = user
end
tip_exception(401, "请登录后再操作") unless User.current.logged?
end
def require_login_cloud_ide_saas
if params[:sign].present? && params[:email].present?
sign = Digest::MD5.hexdigest("#{OPENKEY}#{params[:email]}")
if params[:sign].to_s == sign
user = User.find_by(mail: params[:email])
User.current = user
end
end
tip_exception(401, "请登录后再操作") unless User.current.logged? tip_exception(401, "请登录后再操作") unless User.current.logged?
end end
@ -296,62 +249,39 @@ class ApplicationController < ActionController::Base
#return if params[:controller] == "main" #return if params[:controller] == "main"
# Find the current user # Find the current user
#Rails.logger.info("current_laboratory is #{current_laboratory} domain is #{request.subdomain}") #Rails.logger.info("current_laboratory is #{current_laboratory} domain is #{request.subdomain}")
if request.headers["Authorization"].present? && request.headers["Authorization"].start_with?('Bearer') User.current = find_current_user
if !valid_doorkeeper_token? uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous"))
header = request.authorization
pattern = /^Bearer /i # 开放课程通过链接访问的用户
token = header.gsub(pattern, "") if !User.current.logged? && !params[:chinaoocTimestamp].blank? && !params[:websiteName].blank? && !params[:chinaoocKey].blank?
User.current, message = Bot.decode_jwt_token(token) content = "#{OPENKEY}#{params[:websiteName]}#{params[:chinaoocTimestamp]}"
tip_exception(401, message) if message.present?
else if Digest::MD5.hexdigest(content) == params[:chinaoocKey]
if @doorkeeper_token.present? user = open_class_user
# client方法对接需要一直带着用户标识uid if user
if @doorkeeper_token.resource_owner_id.blank? start_user_session(user)
tip_exception(-1, "缺少用户标识!") if params[:uid].nil? set_autologin_cookie(user)
User.current = User.find(params[:uid])
else
User.current = User.find_by(id: @doorkeeper_token.resource_owner_id)
end
end end
end
else
User.current = find_current_user
uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous"))
# 开放课程通过链接访问的用户
if !User.current.logged? && !params[:chinaoocTimestamp].blank? && !params[:websiteName].blank? && !params[:chinaoocKey].blank?
content = "#{OPENKEY}#{params[:websiteName]}#{params[:chinaoocTimestamp]}"
if Digest::MD5.hexdigest(content) == params[:chinaoocKey]
user = open_class_user
if user
start_user_session(user)
set_autologin_cookie(user)
end
User.current = user
end
end
if !User.current.logged? && Rails.env.development?
user = User.find 1
User.current = user User.current = user
start_user_session(user)
end end
end
# if !User.current.logged? && Rails.env.development?
# User.current = User.find 1
# end
# 测试版前端需求 # 测试版前端需求
logger.info("subdomain:#{request.subdomain}") logger.info("subdomain:#{request.subdomain}")
if request.subdomain != "www" if request.subdomain != "www"
if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除
User.current = User.find 81403 User.current = User.find 81403
elsif params[:debug] == 'student' elsif params[:debug] == 'student'
User.current = User.find 8686 User.current = User.find 8686
elsif params[:debug] == 'admin' elsif params[:debug] == 'admin'
logger.info "@@@@@@@@@@@@@@@@@@@@@@ debug mode....." logger.info "@@@@@@@@@@@@@@@@@@@@@@ debug mode....."
user = User.find 36480 user = User.find 36480
User.current = user User.current = user
cookies.signed[:user_id] = user.id cookies.signed[:user_id] = user.id
end
end end
end end
# User.current = User.find 81403 # User.current = User.find 81403
@ -674,15 +604,7 @@ class ApplicationController < ActionController::Base
def kaminari_paginate(relation) def kaminari_paginate(relation)
limit = params[:limit] || params[:per_page] limit = params[:limit] || params[:per_page]
limit = (limit.to_i.zero? || limit.to_i > 50) ? 50 : limit.to_i limit = (limit.to_i.zero? || limit.to_i > 20) ? 20 : 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
page = params[:page].to_i.zero? ? 1 : params[:page].to_i page = params[:page].to_i.zero? ? 1 : params[:page].to_i
relation.page(page).per(limit) relation.page(page).per(limit)
@ -715,7 +637,7 @@ class ApplicationController < ActionController::Base
end end
def find_user_with_id 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_not_found("未找到’#{params[:login]}’相关的用户") unless @user
render_error("未找到相关的用户") unless @user render_error("未找到相关的用户") unless @user
end end
@ -759,7 +681,7 @@ class ApplicationController < ActionController::Base
@project, @owner = Project.find_with_namespace(namespace, id) @project, @owner = Project.find_with_namespace(namespace, id)
if @project and (current_user.can_read_project?(@project) || controller_path == "projects/project_invite_links") if @project and current_user.can_read_project?(@project)
logger.info "########### has project and can read project" logger.info "########### has project and can read project"
@project @project
# elsif @project && current_user.is_a?(AnonymousUser) # elsif @project && current_user.is_a?(AnonymousUser)
@ -767,15 +689,9 @@ class ApplicationController < ActionController::Base
# @project = nil if !@project.is_public? # @project = nil if !@project.is_public?
# render_forbidden and return # render_forbidden and return
else else
if @project.present? logger.info "###########project not found"
logger.info "########### has project and but can't read project" @project = nil
@project = nil render_not_found and return
render_forbidden and return
else
logger.info "###########project not found"
@project = nil
render_not_found and return
end
end end
@project @project
end end
@ -840,340 +756,8 @@ class ApplicationController < ActionController::Base
HotSearchKeyword.add(keyword) HotSearchKeyword.add(keyword)
end 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 def find_atme_receivers
@atme_receivers = User.where(login: params[:receivers_login]) @atme_receivers = User.where(login: params[:receivers_login])
end 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

View File

@ -31,21 +31,16 @@ class AttachmentsController < ApplicationController
def get_file def get_file
normal_status(-1, "参数缺失") if params[:download_url].blank? 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 url = URI.encode(params[:download_url].to_s.gsub("http:", "https:"))
if url.starts_with?(base_url) && !url.starts_with?("#{base_url}/repo") if url.starts_with?(base_url)
domain = GiteaService.gitea_config[:domain] domain = Gitea.gitea_config[:domain]
api_url = GiteaService.gitea_config[:base_url] api_url = Gitea.gitea_config[:base_url]
url = ("/repos"+url.split(base_url + "/api")[1]) url = url.split(base_url)[1].gsub("api", "repos").gsub('?filepath=', '/').gsub('&', '?')
filepath, ref = url.split("/")[-1].split("?") request_url = [domain, api_url, url, "?ref=#{params[:ref]}&access_token=#{current_user&.gitea_token}"].join
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}")
response = Faraday.get(request_url) response = Faraday.get(request_url)
filename = filepath filename = url.to_s.split("/").pop()
else else
response = Faraday.get(URI.encode(url)) response = Faraday.get(url)
filename = params[:download_url].to_s.split("/").pop() filename = params[:download_url].to_s.split("/").pop()
end end
send_data(response.body.force_encoding("UTF-8"), filename: filename, type: "application/octet-stream", disposition: 'attachment') send_data(response.body.force_encoding("UTF-8"), filename: filename, type: "application/octet-stream", disposition: 'attachment')
@ -94,7 +89,6 @@ class AttachmentsController < ApplicationController
@attachment.author_id = current_user.id @attachment.author_id = current_user.id
@attachment.disk_directory = month_folder @attachment.disk_directory = month_folder
@attachment.cloud_url = remote_path @attachment.cloud_url = remote_path
@attachment.uuid = SecureRandom.uuid
@attachment.save! @attachment.save!
else else
logger.info "文件已存在id = #{@attachment.id}, filename = #{@attachment.filename}" logger.info "文件已存在id = #{@attachment.id}, filename = #{@attachment.filename}"
@ -144,14 +138,12 @@ class AttachmentsController < ApplicationController
private private
def find_file def find_file
tip_exception(404, "您访问的页面不存在或已被删除") if params[:id].blank?
@file = @file =
if params[:type] == 'history' if params[:type] == 'history'
AttachmentHistory.find params[:id] AttachmentHistory.find params[:id]
else else
Attachment.where_id_or_uuid(params[:id]).first Attachment.find params[:id]
end end
tip_exception(404, "您访问的页面不存在或已被删除") if @file.blank?
end end
def delete_file(file_path) def delete_file(file_path)
@ -221,22 +213,21 @@ class AttachmentsController < ApplicationController
def attachment_candown def attachment_candown
unless current_user.admin? || current_user.business? unless current_user.admin? || current_user.business?
candown = true candown = true
if @file.container && @file.uuid.nil? unless params[:type] == 'history'
if @file.container.is_a?(Issue) if @file.container && current_user.logged?
project = @file.container.project if @file.container.is_a?(Issue)
candown = project.is_public || (current_user.logged? && project.member?(current_user)) course = @file.container.project
elsif @file.container.is_a?(Journal) candown = course.member?(current_user) || course.is_public
project = @file.container.issue.project elsif @file.container.is_a?(Journal)
candown = project.is_public || (current_user.logged? && project.member?(current_user)) course = @file.container.issue.project
elsif @file.container.is_a?(Project) candown = course.member?(current_user)
project = @file.container else
candown = project.is_public || (current_user.logged? && project.member?(current_user)) course = nil
else end
project = nil tip_exception(403, "您没有权限进入") if course.present? && !candown
tip_exception(403, "您没有权限进入") if @file.container.is_a?(ApplyUserAuthentication)
end end
tip_exception(403, "您没有权限进入") if project.present? && !candown
end end
tip_exception(403, "您没有权限查看") if @file.is_public == 0 && @file.author_id != current_user.id
end end
end end

View File

@ -1,19 +1,35 @@
class BindUsersController < ApplicationController class BindUsersController < ApplicationController
# before_action :require_login
def create def create
Rails.logger.debug "--------------开始绑定用户------------" # user = CreateBindUserService.call(create_params)
Rails.logger.debug "--------------params: #{params.to_unsafe_h}" #
tip_exception '系统错误' if session[:unionid].blank? 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]) render_ok
tip_exception '用户名或者密码错误' if bind_user.blank? rescue ApplicationService::Error => ex
tip_exception '用户名或者密码错误' unless bind_user.check_password?(params[:password].to_s) render_error(ex.message)
tip_exception '参数错误' unless ["qq", "wechat", "gitee", "github", "educoder", "acge"].include?(params[:type].to_s) end
tip_exception '该账号已被绑定,请更换其他账号进行绑定' if bind_user.bind_open_user?(params[:type].to_s) else
begin
tip_exception '系统错误' if session[:unionid].blank?
"OpenUsers::#{params[:type].to_s.capitalize}".constantize.create!(user: bind_user, uid: session[:unionid]) bind_user = User.try_to_login(params[:username], params[:password])
successful_authentication(bind_user) tip_exception '用户名或者密码错误' if bind_user.blank?
@user = bind_user 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 end
def new_user def new_user

View File

@ -14,12 +14,12 @@ class Ci::CloudAccountsController < Ci::BaseController
def create def create
flag, msg = check_bind_cloud_account! flag, msg = check_bind_cloud_account!
return tip_exception(msg) if flag === true return render_error(msg) if flag === true
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
@cloud_account = bind_account! @cloud_account = bind_account!
if @cloud_account.blank? if @cloud_account.blank?
tip_exception('激活失败, 请检查你的云服务器信息是否正确.') render_error('激活失败, 请检查你的云服务器信息是否正确.')
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
else else
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED) current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
@ -27,17 +27,17 @@ class Ci::CloudAccountsController < Ci::BaseController
end end
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def activate def activate
return tip_exception('请先认证') unless current_user.ci_certification? return render_error('请先认证') unless current_user.ci_certification?
begin begin
@cloud_account = Ci::CloudAccount.find params[:id] @cloud_account = Ci::CloudAccount.find params[:id]
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
if @repo if @repo
return tip_exception('该项目已经激活') if @repo.repo_active? return render_error('该项目已经激活') if @repo.repo_active?
@repo.activate!(@project) @repo.activate!(@project)
else else
@repo = Ci::Repo.auto_create!(@ci_user, @project) @repo = Ci::Repo.auto_create!(@ci_user, @project)
@ -50,7 +50,7 @@ class Ci::CloudAccountsController < Ci::BaseController
end end
render_ok render_ok
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
end end
@ -59,39 +59,39 @@ class Ci::CloudAccountsController < Ci::BaseController
def bind def bind
flag, msg = check_bind_cloud_account! flag, msg = check_bind_cloud_account!
return tip_exception(msg) if flag === true return render_error(msg) if flag === true
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
@cloud_account = bind_account! @cloud_account = bind_account!
if @cloud_account.blank? if @cloud_account.blank?
tip_exception('激活失败, 请检查你的云服务器信息是否正确.') render_error('激活失败, 请检查你的云服务器信息是否正确.')
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
else else
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED) current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
end end
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def trustie_bind def trustie_bind
account = params[:account].to_s account = params[:account].to_s
return tip_exception("account不能为空.") if account.blank? return render_error("account不能为空.") if account.blank?
flag, msg = check_trustie_bind_cloud_account! flag, msg = check_trustie_bind_cloud_account!
return tip_exception(msg) if flag === true return render_error(msg) if flag === true
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
@cloud_account = trustie_bind_account! @cloud_account = trustie_bind_account!
if @cloud_account.blank? if @cloud_account.blank?
tip_exception('激活失败, 请检查你的云服务器信息是否正确.') render_error('激活失败, 请检查你的云服务器信息是否正确.')
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
else else
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED) current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
end end
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def unbind def unbind
@ -107,18 +107,18 @@ class Ci::CloudAccountsController < Ci::BaseController
render_ok render_ok
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def oauth_grant def oauth_grant
password = params[:password].to_s password = params[:password].to_s
return tip_exception('你输入的密码不正确.') unless current_user.check_password?(password) return render_error('你输入的密码不正确.') unless current_user.check_password?(password)
oauth = current_user.oauths.last oauth = current_user.oauths.last
return tip_exception("服务器出小差了.") if oauth.blank? return render_error("服务器出小差了.") if oauth.blank?
result = gitea_oauth_grant!(password, oauth) result = gitea_oauth_grant!(password, oauth)
return tip_exception('授权失败.') unless result === true return render_error('授权失败.') unless result === true
current_user.set_drone_step!(User::DEVOPS_CERTIFICATION) current_user.set_drone_step!(User::DEVOPS_CERTIFICATION)
end end

View File

@ -30,7 +30,7 @@ class Ci::PipelinesController < Ci::BaseController
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
size = Ci::Pipeline.where('branch=? and identifier=? and owner=?', params[:branch], params[:repo], params[:owner]).size size = Ci::Pipeline.where('branch=? and identifier=? and owner=?', params[:branch], params[:repo], params[:owner]).size
if size > 0 if size > 0
tip_exception("#{params[:branch]}分支已经存在流水线!") render_error("#{params[:branch]}分支已经存在流水线!")
return return
end end
pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name],owner: params[:owner], pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name],owner: params[:owner],
@ -53,7 +53,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok({id: pipeline.id}) render_ok({id: pipeline.id})
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
# 在代码库创建文件 # 在代码库创建文件
@ -81,7 +81,6 @@ class Ci::PipelinesController < Ci::BaseController
repo_branch: pipeline.branch, repo_branch: pipeline.branch,
repo_config: pipeline.file_name repo_config: pipeline.file_name
} }
Rails.logger.info("########create_params===#{create_params.to_json}")
repo = Ci::Repo.create_repo(create_params) repo = Ci::Repo.create_repo(create_params)
repo repo
end end
@ -119,7 +118,7 @@ class Ci::PipelinesController < Ci::BaseController
end end
render_ok render_ok
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def destroy def destroy
@ -133,7 +132,7 @@ class Ci::PipelinesController < Ci::BaseController
end end
render_ok render_ok
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def content def content
@ -183,7 +182,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok render_ok
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def update_stage def update_stage
@ -193,7 +192,7 @@ class Ci::PipelinesController < Ci::BaseController
end end
render_ok render_ok
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def delete_stage def delete_stage
@ -206,7 +205,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok render_ok
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def update_stage_index(pipeline_id, show_index, diff) def update_stage_index(pipeline_id, show_index, diff)
@ -230,7 +229,7 @@ class Ci::PipelinesController < Ci::BaseController
unless steps.empty? unless steps.empty?
steps.each do |step| steps.each do |step|
unless step[:template_id] unless step[:template_id]
tip_exception('请选择模板!') render_error('请选择模板!')
return return
end end
if !step[:id] if !step[:id]
@ -247,7 +246,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok render_ok
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def create_stage_step def create_stage_step
@ -263,7 +262,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok render_ok
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def update_stage_step def update_stage_step
@ -280,7 +279,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok render_ok
end end
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
def delete_stage_step def delete_stage_step
@ -290,6 +289,6 @@ class Ci::PipelinesController < Ci::BaseController
end end
render_ok render_ok
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
end end

View File

@ -30,19 +30,19 @@ class Ci::ProjectsController < Ci::BaseController
@file = interactor.result @file = interactor.result
render_result(1, "更新成功") render_result(1, "更新成功")
else else
tip_exception(interactor.error) render_error(interactor.error)
end end
end end
def activate def activate
return tip_exception('你还未认证') unless current_user.ci_certification? return render_error('你还未认证') unless current_user.ci_certification?
begin begin
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
if @repo if @repo
@repo.destroy! if @repo&.repo_user_id == 0 return render_error('该项目已经激活') if @repo.repo_active?
return tip_exception('该项目已经激活') if @repo.repo_active?
@repo.activate!(@project) @repo.activate!(@project)
return render_ok
else else
@repo = Ci::Repo.auto_create!(@ci_user, @project) @repo = Ci::Repo.auto_create!(@ci_user, @project)
@ci_user.update_column(:user_syncing, false) @ci_user.update_column(:user_syncing, false)
@ -55,12 +55,12 @@ class Ci::ProjectsController < Ci::BaseController
end end
render_ok render_ok
rescue Exception => ex rescue Exception => ex
tip_exception(ex.message) render_error(ex.message)
end end
end end
def deactivate def deactivate
return tip_exception('该项目已经取消激活') if !@repo.repo_active? return render_error('该项目已经取消激活') if !@repo.repo_active?
@project.update_column(:open_devops, false) @project.update_column(:open_devops, false)
@repo.deactivate_repos! @repo.deactivate_repos!

View File

@ -20,14 +20,14 @@ class Ci::SecretsController < Ci::BaseController
if result["id"] if result["id"]
render_ok render_ok
else else
tip_exception(result["message"]) render_error(result["message"])
end end
else else
result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], options).create_secret result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], options).create_secret
if result["id"] if result["id"]
render_ok render_ok
else else
tip_exception(result["message"]) render_error(result["message"])
end end
end end
end end
@ -39,7 +39,7 @@ class Ci::SecretsController < Ci::BaseController
Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], {name: name}).delete_secret Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], {name: name}).delete_secret
render_ok render_ok
else else
tip_exception("参数名不能为空") render_error("参数名不能为空")
end end
rescue Exception => ex rescue Exception => ex
render_ok render_ok

Some files were not shown because too many files have changed in this diff Show More