From 7a28d1912b7222317dd98113e141057b9578c5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 23 Jul 2019 22:25:04 +0800 Subject: [PATCH 01/11] b --- public/react/config/webpack.config.prod.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/config/webpack.config.prod.js b/public/react/config/webpack.config.prod.js index 7b9795e80..0abd707af 100644 --- a/public/react/config/webpack.config.prod.js +++ b/public/react/config/webpack.config.prod.js @@ -301,8 +301,8 @@ module.exports = { }, warnings: false, compress: { - drop_debugger: true, - drop_console: true + drop_debugger: false, + drop_console: false } } }), From 69f958c64786f5a5fa8a756bf2e48f4df4ff0e64 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 24 Jul 2019 10:41:45 +0800 Subject: [PATCH 02/11] user center project package module --- .../users/project_packages_controller.rb | 17 +++++ app/models/project_package.rb | 3 + app/models/user.rb | 9 +++ app/services/users/project_package_service.rb | 76 +++++++++++++++++++ .../project_packages/index.json.jbuilder | 20 +++++ config/routes.rb | 1 + 6 files changed, 126 insertions(+) create mode 100644 app/controllers/users/project_packages_controller.rb create mode 100644 app/services/users/project_package_service.rb create mode 100644 app/views/users/project_packages/index.json.jbuilder diff --git a/app/controllers/users/project_packages_controller.rb b/app/controllers/users/project_packages_controller.rb new file mode 100644 index 000000000..edd6bd29b --- /dev/null +++ b/app/controllers/users/project_packages_controller.rb @@ -0,0 +1,17 @@ +class Users::ProjectPackagesController < Users::BaseController + + def index + packages = Users::ProjectPackageService.call(observed_user, query_params) + + @count = packages.count + @packages = paginate(packages.includes(:project_package_category)) + + bidding_users = BiddingUser.where(project_package_id: @packages.map(&:id), user_id: observed_user.id) + bidding_users = bidding_users.group(:project_package_id).select(:project_package_id, :status) + @bidding_status_map = bidding_users.each_with_object({}) { |u, h| h[u.project_package_id] = u.status } + end + + def query_params + params.permit(:category, :status, :sort_by, :sort_direction) + end +end \ No newline at end of file diff --git a/app/models/project_package.rb b/app/models/project_package.rb index fc541097a..219f60ca4 100644 --- a/app/models/project_package.rb +++ b/app/models/project_package.rb @@ -13,6 +13,9 @@ class ProjectPackage < ApplicationRecord has_many :attachments, as: :container, dependent: :destroy + scope :visible, -> { where(status: %i[published bidding_ended bidding_finished]) } + scope :invisible, -> { where(status: %i[pending applying refused]) } + aasm(:status) do state :pending, initiali: true state :applying diff --git a/app/models/user.rb b/app/models/user.rb index 73036c73e..03c97b9f3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -123,6 +123,11 @@ class User < ApplicationRecord has_many :user_interests, dependent: :delete_all has_many :interests, through: :user_interests, source: :repertoire + # 众包 + has_many :project_packages, foreign_key: :creator_id, dependent: :destroy + has_many :bidding_users, dependent: :destroy + has_many :bidden_project_packages, through: :bidding_users, source: :project_package + # Groups and active users scope :active, lambda { where(status: STATUS_ACTIVE) } @@ -572,6 +577,10 @@ class User < ApplicationRecord Attendance.find_by(user_id: id)&.next_gold || 60 # 基础50,连续签到+10 end + def admin_or_business? + admin? || business? + end + protected def validate_password_length # 管理员的初始密码是5位 diff --git a/app/services/users/project_package_service.rb b/app/services/users/project_package_service.rb new file mode 100644 index 000000000..870cdc98e --- /dev/null +++ b/app/services/users/project_package_service.rb @@ -0,0 +1,76 @@ +class Users::ProjectPackageService < ApplicationService + include CustomSortable + + sort_columns :published_at, default_by: :published_at, default_direction: :desc + + attr_reader :user, :params + + def initialize(user, params) + @user = user + @params = params + end + + def call + packages = category_scope_filter + + packages = user_policy_filter(packages) + + custom_sort(packages, :published_at, params[:sort_direction]) + end + + private + + def category_scope_filter + case params[:category] + when 'bidden' then + user.bidden_project_packages + when 'manage' then + user.project_packages + else + ids = user.bidding_users.pluck(:project_package_id) + user.project_packages.pluck(:id) + ProjectPackage.where(id: ids) + end + end + + def user_policy_filter(relations) + if self_or_admin? + status_filter(relations) + else + relations.visible + end + end + + def status_filter(relations) + return relations unless self_or_admin? + + case params[:category] + when 'bidden' then bidding_status_filter(relations) + when 'manage' then package_status_filter(relations) + else relations + end + end + + def bidding_status_filter(relations) + case params[:status] + when 'bidding_lost' then + relations.where(bidding_users: { status: :bidding_lost }) + when 'bidding_won' then + relations.where(bidding_users: { status: :bidding_won }) + else + relations + end + end + + def package_status_filter(relations) + case params[:status] + when 'unpublished' then relations.invisible + when 'bidding' then relations.where(status: :published) + when 'finished' then relations.where(status: %w[bidding_ended bidding_finished]) + else relations + end + end + + def self_or_admin? + User.current&.id == user.id || User.current&.admin_or_business? + end +end \ No newline at end of file diff --git a/app/views/users/project_packages/index.json.jbuilder b/app/views/users/project_packages/index.json.jbuilder new file mode 100644 index 000000000..a2574d558 --- /dev/null +++ b/app/views/users/project_packages/index.json.jbuilder @@ -0,0 +1,20 @@ +user = observed_user + +json.count @count +json.project_packages do + json.array! @packages.each do |package| + json.extract! package, :id, :title, :status, :min_price, :max_price, :visit_count, :bidding_users_count + + is_creator = user.id == package.creator_id + json.type is_creator ? 'manage' : 'bidden' + json.category_id package.project_package_category_id + json.category_name package.category_name + + unless is_creator + json.bidden_status @bidding_status_map[package.id] + end + + json.deadline_at package.display_deadline_at + json.published_at package.display_published_at + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 16140e99c..bb5bc49cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -50,6 +50,7 @@ Rails.application.routes.draw do resource :experience_records, only: [:show] resource :grade_records, only: [:show] resource :watch, only: [:create, :destroy] + resources :project_packages, only: [:index] end From b59765568af5921864b437121bf187412251f763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 24 Jul 2019 10:54:37 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/user/Interestpage.js | 4 ++++ public/react/src/modules/user/InterestpageMax.js | 5 +++++ public/react/src/modules/user/common.css | 3 +++ 3 files changed, 12 insertions(+) diff --git a/public/react/src/modules/user/Interestpage.js b/public/react/src/modules/user/Interestpage.js index 5b4b69cf6..4c3c39406 100644 --- a/public/react/src/modules/user/Interestpage.js +++ b/public/react/src/modules/user/Interestpage.js @@ -188,6 +188,10 @@ class InterestpageComponent extends Component { if (response !== undefined) { // this.Jumptotheinterestpage(); // window.location.href = "/" + if(response.data.message!==undefined){ + + return; + } this.setMyEduCoderModals() } diff --git a/public/react/src/modules/user/InterestpageMax.js b/public/react/src/modules/user/InterestpageMax.js index 8ed2580d7..82b3e7e0f 100644 --- a/public/react/src/modules/user/InterestpageMax.js +++ b/public/react/src/modules/user/InterestpageMax.js @@ -189,6 +189,11 @@ class InterestpageMax extends Component { if (response !== undefined) { // this.Jumptotheinterestpage(); // window.location.href = "/" + + if(response.data.message!==undefined){ + + return; + } this.setMyEduCoderModals() } diff --git a/public/react/src/modules/user/common.css b/public/react/src/modules/user/common.css index 6271c9941..b80677ee5 100644 --- a/public/react/src/modules/user/common.css +++ b/public/react/src/modules/user/common.css @@ -262,4 +262,7 @@ .bth100{ width: 100px; margin: 0 auto; +} +.ant-input-affix-wrapper .ant-input-prefix, .ant-input-affix-wrapper .ant-input-suffix { + background: #ffffff!important; } \ No newline at end of file From b72f4dcfff1641152a0839e8e58d398e7a144305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 24 Jul 2019 11:29:12 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 5 ++--- public/react/src/modules/courses/coursesPublic/Addcourses.js | 2 ++ .../src/modules/courses/shixunHomework/ShixunhomeWorkItem.js | 2 +- public/react/src/modules/tpm/NewHeader.js | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 003ef5a9b..cf62730d7 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -25,9 +25,7 @@ if (isDev) { if (_search) { parsed = queryString.parse(_search); } - debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : - window.location.search.indexOf('debug=s') != -1 ? 'student' : - window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || '' + debugType = window.location.search.indexOf('debug=t') != -1 ? "cxt" : '' } window._debugType = debugType; @@ -144,6 +142,7 @@ export function initAxiosInterceptors(props) { // } if (response.data.status === 403) { // props.history.replace('/403') + debugger // 这里会分2个情况,1、刚进入页面发请求返回的403;2、进入页面后,其他用户操作触发请求返回的403; // TODO 这里做一个403弹框比较好? locationurl('/403'); diff --git a/public/react/src/modules/courses/coursesPublic/Addcourses.js b/public/react/src/modules/courses/coursesPublic/Addcourses.js index e8bd8b9cf..922c68650 100644 --- a/public/react/src/modules/courses/coursesPublic/Addcourses.js +++ b/public/react/src/modules/courses/coursesPublic/Addcourses.js @@ -147,6 +147,8 @@ class Addcourses extends Component{ if(Addcoursestype===true){ this.props.hideAddcoursestype(); + }else{ + window.location.href = "/"; } } diff --git a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js index 5f41cdefb..b4adea17f 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js @@ -382,7 +382,7 @@ class ShixunhomeWorkItem extends Component{ 实训详情 {this.props.isAdminOrCreator()?this.editname(discussMessage.name,discussMessage.homework_id)} className={"btn colorblue ml20 font-16"}>重命名:""} {/* 设置*/} - 设置 + 设置 :""} diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index da8e71a40..830c8b1d4 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -487,10 +487,11 @@ submittojoinclass=(value)=>{ } showSearchOpen=(e)=>{ + debugger this.setState({ showSearchOpentype:true }) - e.stopPropagation(e);//阻止冒泡 + } hideshowSearchOpen=(e)=>{ @@ -500,7 +501,7 @@ submittojoinclass=(value)=>{ showSearchOpentype:false, setevaluatinghides:false }) - e.stopPropagation(e);//阻止冒泡 + } } From f064afdd46e70f0568efa0651425a29fc27f0c94 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 24 Jul 2019 12:31:49 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E7=AD=94=E6=A1=88=E8=AE=B0=E5=BD=95=E6=89=A3=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20190724013024_modify_final_score_for_games.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/migrate/20190724013024_modify_final_score_for_games.rb diff --git a/db/migrate/20190724013024_modify_final_score_for_games.rb b/db/migrate/20190724013024_modify_final_score_for_games.rb new file mode 100644 index 000000000..e926cccd6 --- /dev/null +++ b/db/migrate/20190724013024_modify_final_score_for_games.rb @@ -0,0 +1,15 @@ +class ModifyFinalScoreForGames < ActiveRecord::Migration[5.2] + def change + grades = Grade.where(container_type: "Answer") + grades.each do |grade| + g = Game.find_by_id(grade.container_id) + if g.present? + if g.status == 2 && g.answer_open > 0 && g.final_score <= 0 && g.end_time < grade.created_at + g.update_column(:final_score, g.challenge.score) + elsif g.final_score < 0 + g.update_column(:final_score, 0) + end + end + end + end +end From 976798de574e3a566dee6ec3f812d7c8c37e9fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 24 Jul 2019 12:33:33 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/NewHeader.js | 190 +++------------------- 1 file changed, 21 insertions(+), 169 deletions(-) diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index 830c8b1d4..37fac626d 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -495,6 +495,7 @@ submittojoinclass=(value)=>{ } hideshowSearchOpen=(e)=>{ + debugger let {setevaluatinghides}=this.state; if(setevaluatinghides===true){ this.setState({ @@ -519,6 +520,7 @@ submittojoinclass=(value)=>{ } setevaluatinghides=()=>{ + debugger this.setState( { setevaluatinghides:true @@ -600,6 +602,7 @@ submittojoinclass=(value)=>{ // rolearr:["",""], // console.log("618"); // console.log(user_phone_binded); + console.log(showSearchOpentype) return (
@@ -670,8 +673,21 @@ submittojoinclass=(value)=>{ >工程认证 - -