From 8d41c270448856034ae0591c5356268a36026189 Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 17 Oct 2022 10:42:40 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=88=90=E5=91=98=E6=B7=BB=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 5c8ed963e..92eb68f35 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -65,13 +65,13 @@ class MembersController < ApplicationController def check_member_exists! @current_user_header_team = Team.joins(:team_users, :team_projects).where(team_projects: {project_id: @project.id}, team_users: {user_id: current_user.id}).order(authorize: :desc).take - return render_error("user_id为#{params[:user_id]}的用户已经是项目成员") if member_exists? || (params[:user_id].to_i == current_user.id && @current_user_header_team.present?) + return render_error("#{@user&.nickname}已经是项目成员") if member_exists? || (params[:user_id].to_i == current_user.id && @current_user_header_team.present?) end def check_member_not_exists! @current_user_header_team = Team.joins(:team_users, :team_projects).where(team_projects: {project_id: @project.id}, team_users: {user_id: current_user.id}).order(authorize: :desc).take return render_error("用户为组织成员,请到组织下操作!") if (params[:user_id].to_i == current_user.id && @current_user_header_team.present?) && !member_exists? - return render_error("user_id为#{params[:user_id]}的用户还不是项目成员") unless member_exists? + return render_error("#{@user&.nickname}还不是项目成员") unless member_exists? end def check_user_profile_completed From 8807be6e4d1e1c4e238467a8bb29996d9dd5d76f Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 17 Oct 2022 10:52:57 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=AF=AD=E8=A8=80=E6=96=B0=E5=A2=9E=E5=94=AF=E4=B8=80?= =?UTF-8?q?=E6=80=A7=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/project_languages_controller.rb | 7 ++++--- app/models/project_language.rb | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/admins/project_languages_controller.rb b/app/controllers/admins/project_languages_controller.rb index 0f26f25bb..69594eb50 100644 --- a/app/controllers/admins/project_languages_controller.rb +++ b/app/controllers/admins/project_languages_controller.rb @@ -27,17 +27,18 @@ class Admins::ProjectLanguagesController < Admins::BaseController flash[:success] = '创建成功' else redirect_to admins_project_languages_path - flash[:danger] = '创建失败' + flash[:danger] = @project_language.errors.full_messages.join(",") end end def update - if @project_language.update_attribute(:name, @name) + @project_language.attributes = {name: @name} + if @project_language.save redirect_to admins_project_languages_path flash[:success] = '更新成功' else redirect_to admins_project_languages_path - flash[:success] = '更新失败' + flash[:danger] = @project_language.errors.full_messages.join(",") end end diff --git a/app/models/project_language.rb b/app/models/project_language.rb index ced6c5f9e..09b0b80f2 100644 --- a/app/models/project_language.rb +++ b/app/models/project_language.rb @@ -12,4 +12,6 @@ class ProjectLanguage < ApplicationRecord include Projectable + + validates :name, uniqueness: true end From dd1af6712ccc435f389cd27630be59db54413158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Mon, 17 Oct 2022 11:08:54 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fixed=20=E9=A1=B9=E7=9B=AE=E6=88=90?= =?UTF-8?q?=E5=91=98=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 5c8ed963e..378f1ae93 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -65,13 +65,13 @@ class MembersController < ApplicationController def check_member_exists! @current_user_header_team = Team.joins(:team_users, :team_projects).where(team_projects: {project_id: @project.id}, team_users: {user_id: current_user.id}).order(authorize: :desc).take - return render_error("user_id为#{params[:user_id]}的用户已经是项目成员") if member_exists? || (params[:user_id].to_i == current_user.id && @current_user_header_team.present?) + return render_error("#{User.find_by(id: params[:user_id]).try(:login)}已经是项目成员") if member_exists? || (params[:user_id].to_i == current_user.id && @current_user_header_team.present?) end def check_member_not_exists! @current_user_header_team = Team.joins(:team_users, :team_projects).where(team_projects: {project_id: @project.id}, team_users: {user_id: current_user.id}).order(authorize: :desc).take return render_error("用户为组织成员,请到组织下操作!") if (params[:user_id].to_i == current_user.id && @current_user_header_team.present?) && !member_exists? - return render_error("user_id为#{params[:user_id]}的用户还不是项目成员") unless member_exists? + return render_error("#{User.find_by(id: params[:user_id]).try(:login)}还不是项目成员") unless member_exists? end def check_user_profile_completed From 5196f33f24137dc5c21e947a43a3c5c621427aa0 Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 17 Oct 2022 12:57:24 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=AE=B8=E5=8F=AF=E8=AF=81=E6=96=B0=E5=A2=9E=E9=AA=8C?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/project_licenses_controller.rb | 50 +++++++++---------- app/models/license.rb | 4 ++ config/locales/zh-CN.yml | 3 ++ 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/controllers/admins/project_licenses_controller.rb b/app/controllers/admins/project_licenses_controller.rb index 5c16a884b..44ae75118 100644 --- a/app/controllers/admins/project_licenses_controller.rb +++ b/app/controllers/admins/project_licenses_controller.rb @@ -1,6 +1,6 @@ class Admins::ProjectLicensesController < Admins::BaseController 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 sort_by = License.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at' @@ -30,13 +30,12 @@ class Admins::ProjectLicensesController < Admins::BaseController # position: max_position # } @project_license = License.new(license_params) - - if @project_license.save! + if @project_license.save redirect_to admins_project_licenses_path flash[:success] = "创建成功" else - render :new - flash[:danger] = "创建失败" + redirect_to admins_project_licenses_path + flash[:danger] = @project_license.errors.full_messages.join(",") end end @@ -54,12 +53,13 @@ class Admins::ProjectLicensesController < Admins::BaseController # permissions: permissions.to_s, # limitations: limitations.to_s # } - if @project_license.update_attributes(license_params) + @project_license.attributes = license_params + if @project_license.save redirect_to admins_project_licenses_path flash[:success] = "更新成功" else - render :edit - flash[:danger] = "更新失败" + render admins_project_licenses_path + flash[:danger] = @project_license.errors.full_messages.join(",") end end @@ -98,23 +98,23 @@ class Admins::ProjectLicensesController < Admins::BaseController params.require(:license).permit(:name,:content) end - def validate_params - name = params[:license][:name] - if name.blank? - flash[:danger] = "名称不允许为空" - redirect_to admins_project_licenses_path - elsif check_license_present?(name) && @project_license.blank? - flash[:danger] = "创建失败:名称已存在" - redirect_to admins_project_licenses_path - end - end + # def validate_params + # name = params[:license][:name] + # if name.blank? + # flash[:danger] = "名称不允许为空" + # redirect_to admins_project_licenses_path + # elsif check_license_present?(name) && @project_license.blank? + # flash[:danger] = "创建失败:名称已存在" + # redirect_to admins_project_licenses_path + # end + # end - def check_license_present?(name) - return true if name.blank? - name_downcase = name.downcase - name_upcase = name.upcase - name_first_big = name.capitalize - License.exists?(name: name_downcase) || License.exists?(name: name_upcase) || License.exists?(name: name_first_big) - end + # def check_license_present?(name) + # return true if name.blank? + # name_downcase = name.downcase + # name_upcase = name.upcase + # name_first_big = name.capitalize + # License.exists?(name: name_downcase) || License.exists?(name: name_upcase) || License.exists?(name: name_first_big) + # end end diff --git a/app/models/license.rb b/app/models/license.rb index 0a14fb85e..676254717 100644 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -11,4 +11,8 @@ class License < ApplicationRecord include Projectable + + validates :content, presence: true + validates :name, uniqueness: true, presence: true + end diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 62ea16966..95b7c429b 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -223,6 +223,9 @@ zh-CN: platform: '直播平台' live_time: '开播时间' duration: '直播时长' + license: + name: '许可证名称' + content: '许可证内容' close_pr: 合并请求 roles: Developer: 开发者 From dcc7ab6738bf69fef2afc5c41a1efe6124fe2906 Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 17 Oct 2022 13:01:08 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=88=86=E7=B1=BB=E5=8E=BB=E6=8E=89=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admins/project_categories/_form_modal.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/admins/project_categories/_form_modal.html.erb b/app/views/admins/project_categories/_form_modal.html.erb index fc58d3345..3ad6e044c 100644 --- a/app/views/admins/project_categories/_form_modal.html.erb +++ b/app/views/admins/project_categories/_form_modal.html.erb @@ -21,6 +21,7 @@ <%= p.number_field :pinned_index,class: "form-control input-lg",placeholder: "精选等级",required: true%> + <%if false%>
<% logo_img = @project_category.logo_url %>
@@ -34,6 +35,7 @@
尺寸:高度38px以内,宽等比例缩放
+ <% end %>