Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

issues25489
杨树明 5 years ago
commit 2b377f9bf2

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

@ -0,0 +1,3 @@
// Place all the styles related to the trustie_hacks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

@ -1,6 +1,11 @@
class Competitions::CertificatesController < Competitions::BaseController
def personal
prize_user = CompetitionPrizeUser.find_by!(user: current_user, id: params[:id])
prize_user =
if current_user.admin_or_business?
CompetitionPrizeUser.find(params[:id])
else
CompetitionPrizeUser.find_by!(user: current_user, id: params[:id])
end
return render_not_found unless prize_user.certificate_exist?
team = prize_user.competition_team
@ -12,7 +17,7 @@ class Competitions::CertificatesController < Competitions::BaseController
def team
team = CompetitionTeam.find(params[:id])
return render_forbidden unless team.team_members.exists?(user_id: current_user.id)
return render_forbidden unless current_user.admin_or_business? || team.team_members.exists?(user_id: current_user.id)
return render_not_found unless team.certificate_exists?
prize = team.competition_prize_users.first.competition_prize

@ -1,8 +1,10 @@
class Competitions::PrizesController < Competitions::BaseController
before_action :require_prize_user!
helper_method :current_prize_user
def show
self_prizes = current_competition.competition_prize_users.where(user_id: current_user.id).includes(:competition_team).order(:competition_prize_id)
self_prizes = current_competition.competition_prize_users.where(user_id: current_prize_user.id).includes(:competition_team).order(:competition_prize_id)
@leader = self_prizes.any?{ |prize_user| prize_user.leader? && prize_user.competition_prize.category == 'bonus' } # 是否为队长并且有奖金奖励
if @leader
@ -22,8 +24,13 @@ class Competitions::PrizesController < Competitions::BaseController
private
def require_prize_user!
return if current_competition.competition_prize_users.exists?(user: current_user)
return if current_competition.competition_prize_users.exists?(user: current_prize_user)
return if current_user.admin_or_business? || current_user.id == current_prize_user.id
render_forbidden
end
def current_prize_user
@_current_prize_user ||= User.find(params[:user_id])
end
end

@ -0,0 +1,48 @@
class TrustieHacksController < ApplicationController
before_action :require_admin, :except => [:index]
before_action :require_login, :except => [:index]
before_action :find_hackathon
before_action :find_hack, :except => [:create, :index]
def index
## 分页参数
page = params[:page] || 1
limit = params[:limit] || 16
hacks = @hackathon.trustie_hacks
@hackathon_users_count = hacks ? 0 : hacks.sum(:hack_users_count)
@hacks = hacks.page(page).per(limit)
end
def edit ;end
def create
@hackathon.trustie_hacks.create!(name: params[:name], description: params[:description])
render_ok
end
def update
@hack.update_attributes(name: params[:name], description: params[:description])
end
def edit_hackathon ;end
def update_hackathon
@hackathon.update_attributes(name: params[:name], description: params[:description])
end
private
def find_hackathon
@hackathon = TrustieHackathon.first ||
TrustieHackathon.create(name: params[:name], description: params[:description])
end
def find_hack
@hack = TrustieHack.find params[:id]
end
end

@ -0,0 +1,2 @@
module TrustieHacksHelper
end

@ -0,0 +1,3 @@
class HackUser < ApplicationRecord
belongs_to :trustie_hack, counter_cache: true
end

@ -0,0 +1,4 @@
class TrustieHack < ApplicationRecord
has_many :hack_users, :dependent => :destroy
belongs_to :trustie_hackathon, counter_cache: true
end

@ -0,0 +1,5 @@
class TrustieHackathon < ApplicationRecord
has_many :trustie_hacks, :dependent => :destroy
end

@ -5,7 +5,7 @@ if @leader
json.bank_account_editable @bank_account_editable
end
json.all_certified current_user.all_certified?
json.all_certified current_prize_user.all_certified?
json.personal_certifications do
json.array! @self_prizes do |prize_user|
json.url personal_competition_certificate_path(current_competition.identifier, prize_user)

@ -0,0 +1 @@
json.(@hack, :id, :name, :description)

@ -0,0 +1,2 @@
json.name @hackathon&.name
json.description @hackathon&.description

@ -0,0 +1,9 @@
json.hackathon do
json.(@hackathon, :id, :name, :description)
json.hackathon_users_count @hackathon_users_count
end
json.hacks @hacks do |hack|
json.(hack, :id, :name, :description, :hack_users_count)
end

@ -513,7 +513,6 @@ Rails.application.routes.draw do
post :join_exercise_banks # 加入习题集
post :publish # 立即发布
post :end_exercise # 立即截止
``
end
end
@ -875,6 +874,14 @@ Rails.application.routes.draw do
resources :searchs, only: [:index]
end
resources :trustie_hacks, path: :osshackathon do
collection do
get :edit_hackathon
post :update_hackathon
end
end
end
namespace :admins do

@ -0,0 +1,10 @@
class CreateTrustieHackathons < ActiveRecord::Migration[5.2]
def change
create_table :trustie_hackathons do |t|
t.string :name
t.string :description
t.integer :trustie_hacks_count, default: 0
t.timestamps
end
end
end

@ -0,0 +1,11 @@
class CreateTrustieHacks < ActiveRecord::Migration[5.2]
def change
create_table :trustie_hacks do |t|
t.string :name
t.string :description
t.references :user
t.integer :hack_users_count, default: 0
t.timestamps
end
end
end

@ -0,0 +1,9 @@
class CreateHackUsers < ActiveRecord::Migration[5.2]
def change
create_table :hack_users do |t|
t.references :user
t.references :trustie_hack
t.timestamps
end
end
end

@ -304,7 +304,7 @@ class SingleEditor extends Component{
<span className="fr">标准答案</span>
</React.Fragment>
:
<span className="fr color-orange">请点击正确选项</span>
""
}
</div>

@ -1,5 +1,5 @@
state说明
tasks详情接口
顶层state--tasks详情接口
allowed_unlock 为true时才允许非管理员用户解锁隐藏测试集
discusses_count 总评论数
@ -124,6 +124,28 @@ state说明
user 当前关卡所属用户的信息
user_praise 当前用户是否点赞
/MainContentContainer 里的state
repositoryCode: '',
open: false, // 繁忙等级等提示用Dialog考虑重构封装到根组件
gameBuilding: false, // 评测中标志
codeStatus: SAVED, // 0 已修改 1 保存中 2 已保存 3 保存失败
codeLoading: true, // code加载中
readRepoTimeout: false, // 加载代码轮训超时
resetCodeDialogOpen: false, // 重新加载初始代码弹框的bool控制
resetPassedCodeDialogOpen: false, // 重新加载上次通过的代码的bool控制
isEditablePath: true // 当前文件是否可编辑
CodeRepositoryViewContainer 里的state
drawerOpen: false, // 代码目录Drawer的bool控制 repoFilesDrawer
loadingFirstRepoFiles: false, // 代码目录树加载中的bool控制
fileTreeData: "", // 目录树节点数据[]
fileTreeSelectedKeys: [], // 目录树被选择的节点的key
codeRepositoryViewExpanded: false, --
tabIndex: 0, // tab值
settingDrawerOpen: false // 设置面板Drawer的bool控制
-------------- -------------- -------------- -------------- -------------- -------------- -------------- -------------- --------------
TPIContextProvider

@ -682,7 +682,11 @@ class PathDetailIndex extends Component{
<div>
<p className="font-16 clearfix fl" onDoubleClick={() => this.modifysy(1)}>{team_title}</p>
<Popover placement="right" content={this.maincontent()} trigger="hover">
<i className={"iconfont icon-sandian fr color999"}></i>
<i className={"iconfont icon-sandian fr color999"} style={{
width: "30px",
height: "30px",
textAlign: "center",
}}></i>
</Popover>
</div>
:

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe TrustieHacksController, type: :controller do
end

@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the TrustieHacksHelper. For example:
#
# describe TrustieHacksHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe TrustieHacksHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe HackUser, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe TrustieHack, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe TrustieHackathon, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save