From 3ccac9192d873072fab3fe879082ad96d8b495b3 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Sat, 7 Oct 2023 21:12:58 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87pr=E8=AF=86?= =?UTF-8?q?=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/glcc_medium_term_examine_material.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/glcc_medium_term_examine_material.rb b/app/models/glcc_medium_term_examine_material.rb index 56e78c29e..0e22690c8 100644 --- a/app/models/glcc_medium_term_examine_material.rb +++ b/app/models/glcc_medium_term_examine_material.rb @@ -36,7 +36,7 @@ class GlccMediumTermExamineMaterial < ActiveRecord::Base unless pull_index == 5 state << 2 end - user = User.find_by(login: url_array[3]) + user = Owner.find_by(login: url_array[3]) project = Project.find_by(identifier: url_array[4], user_id:user.try(:id)) pr = PullRequest.where(project:project, gitea_number:url_array[6]) From b92fdb8388fe84e7b485dfdb8827c42511993846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B1=E5=91=B1=E5=91=B1?= Date: Sun, 8 Oct 2023 09:54:26 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BE=93=E5=85=A5issue?= =?UTF-8?q?=E7=BC=96=E5=8F=B7=E6=97=A0=E6=B3=95=E6=9F=A5=E8=AF=A2=E5=88=B0?= =?UTF-8?q?=E8=AF=A5issue=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/api/v1/issues/list_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/api/v1/issues/list_service.rb b/app/services/api/v1/issues/list_service.rb index 5a3f97e98..b6ef11789 100644 --- a/app/services/api/v1/issues/list_service.rb +++ b/app/services/api/v1/issues/list_service.rb @@ -76,7 +76,7 @@ class Api::V1::Issues::ListService < ApplicationService end # keyword - issues = issues.ransack(id_eq: keyword).result.or(issues.ransack(subject_or_description_cont: keyword).result) if keyword.present? + issues = issues.ransack(id_or_project_issues_index_eq: keyword).result.or(issues.ransack(subject_or_description_cont: keyword).result) if keyword.present? @total_issues_count = issues.distinct.size @closed_issues_count = issues.closed.distinct.size From 6cb7af0401c2ea93e0197863b90c2d72aedaa667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B1=E5=91=B1=E5=91=B1?= Date: Tue, 10 Oct 2023 13:49:52 +0800 Subject: [PATCH 3/6] add data_bank to user action --- app/controllers/admins/organizations_controller.rb | 1 + app/controllers/admins/projects_controller.rb | 1 + app/controllers/admins/users_controller.rb | 5 +++-- app/models/attachment.rb | 2 ++ app/models/identity_verification.rb | 2 +- app/models/license.rb | 1 + app/models/member.rb | 1 + app/models/organization_user.rb | 1 + app/models/project.rb | 3 +++ app/models/project_category.rb | 1 + app/models/project_language.rb | 4 ++++ app/models/repository.rb | 1 + app/models/user_action.rb | 1 + app/models/user_extension.rb | 4 ++-- db/migrate/20231010030020_add_data_bank_to_user_actions.rb | 5 +++++ 15 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20231010030020_add_data_bank_to_user_actions.rb diff --git a/app/controllers/admins/organizations_controller.rb b/app/controllers/admins/organizations_controller.rb index c2e0ea96c..3d4eac4c6 100644 --- a/app/controllers/admins/organizations_controller.rb +++ b/app/controllers/admins/organizations_controller.rb @@ -31,6 +31,7 @@ class Admins::OrganizationsController < Admins::BaseController 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 diff --git a/app/controllers/admins/projects_controller.rb b/app/controllers/admins/projects_controller.rb index 4175f7250..f1f797043 100644 --- a/app/controllers/admins/projects_controller.rb +++ b/app/controllers/admins/projects_controller.rb @@ -35,6 +35,7 @@ class Admins::ProjectsController < Admins::BaseController Gitea::Repository::DeleteService.new(project.owner, project.identifier).call project.destroy! # render_delete_success + UserAction.create(action_id: project.id, action_type: "DestroyProject", user_id: current_user.id, :ip => request.remote_ip, data_bank: project.attributes.to_json) redirect_to admins_projects_path flash[:success] = "删除成功" end diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index b948f8232..e15e39242 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -25,15 +25,16 @@ class Admins::UsersController < Admins::BaseController end def destroy + UserAction.create(action_id: @user.id, action_type: "DestroyUser", user_id: current_user.id, :ip => request.remote_ip, data_bank: @user.attributes.to_json) @user.destroy! Gitea::User::DeleteService.call(@user.login) - + render_delete_success end def lock @user.lock! - + UserAction.create(action_id: @user.id, action_type: "LockUser", user_id: current_user.id, :ip => request.remote_ip) render_ok end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 0c056f60c..f79aca153 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -26,6 +26,8 @@ # cloud_url :string(255) default("") # course_second_category_id :integer default("0") # delay_publish :boolean default("0") +# memo_image :boolean default("0") +# extra_type :integer default("0") # # Indexes # diff --git a/app/models/identity_verification.rb b/app/models/identity_verification.rb index 983755b16..3c8c88d9b 100644 --- a/app/models/identity_verification.rb +++ b/app/models/identity_verification.rb @@ -17,7 +17,7 @@ # # Indexes # -# index_identity_verifications_on_number (number) +# index_identity_verifications_on_user_id (user_id) # class IdentityVerification < ApplicationRecord diff --git a/app/models/license.rb b/app/models/license.rb index d14a9db14..f84e63573 100644 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -7,6 +7,7 @@ # content :text(65535) # created_at :datetime not null # updated_at :datetime not null +# is_secret :boolean default("0") # class License < ApplicationRecord diff --git a/app/models/member.rb b/app/models/member.rb index 521f939c5..aaaf34efc 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -11,6 +11,7 @@ # course_group_id :integer default("0") # is_collect :integer default("1") # graduation_group_id :integer default("0") +# is_apply_signature :boolean default("0") # team_user_id :integer # # Indexes diff --git a/app/models/organization_user.rb b/app/models/organization_user.rb index 4ff6946b7..900710a9a 100644 --- a/app/models/organization_user.rb +++ b/app/models/organization_user.rb @@ -5,6 +5,7 @@ # id :integer not null, primary key # user_id :integer # organization_id :integer +# is_creator :boolean default("0") # created_at :datetime not null # updated_at :datetime not null # diff --git a/app/models/project.rb b/app/models/project.rb index 1f27a55ad..5f9fcef68 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -62,6 +62,7 @@ # # Indexes # +# index_projects_on_forked_count (forked_count) # index_projects_on_forked_from_project_id (forked_from_project_id) # index_projects_on_identifier (identifier) # index_projects_on_invite_code (invite_code) @@ -71,6 +72,7 @@ # index_projects_on_license_id (license_id) # index_projects_on_name (name) # index_projects_on_platform (platform) +# index_projects_on_praises_count (praises_count) # index_projects_on_project_category_id (project_category_id) # index_projects_on_project_language_id (project_language_id) # index_projects_on_project_type (project_type) @@ -78,6 +80,7 @@ # index_projects_on_rgt (rgt) # index_projects_on_status (status) # index_projects_on_updated_on (updated_on) +# index_projects_on_user_id (user_id) # class Project < ApplicationRecord diff --git a/app/models/project_category.rb b/app/models/project_category.rb index 97a304259..bc6f8427d 100644 --- a/app/models/project_category.rb +++ b/app/models/project_category.rb @@ -15,6 +15,7 @@ # Indexes # # index_project_categories_on_ancestry (ancestry) +# index_project_categories_on_id (id) # class ProjectCategory < ApplicationRecord diff --git a/app/models/project_language.rb b/app/models/project_language.rb index 0770a1efa..22a4a81ff 100644 --- a/app/models/project_language.rb +++ b/app/models/project_language.rb @@ -9,6 +9,10 @@ # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_project_languages_on_id (id) +# class ProjectLanguage < ApplicationRecord include Projectable diff --git a/app/models/repository.rb b/app/models/repository.rb index f2815dde7..7d3f207ea 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -27,6 +27,7 @@ # # Indexes # +# index_name (project_id) # index_repositories_on_identifier (identifier) # index_repositories_on_project_id (project_id) # index_repositories_on_user_id (user_id) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 384475c4f..b4173fe77 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -9,6 +9,7 @@ # created_at :datetime not null # updated_at :datetime not null # ip :string(255) +# data_bank :text(65535) # # Indexes # diff --git a/app/models/user_extension.rb b/app/models/user_extension.rb index ef4af5fd3..aeb9a9d83 100644 --- a/app/models/user_extension.rb +++ b/app/models/user_extension.rb @@ -22,9 +22,9 @@ # school_id :integer # description :string(255) # department_id :integer -# province :string(255) -# city :string(255) +# province :text(65535) # custom_department :string(255) +# city :string(255) # show_email :boolean default("0") # show_location :boolean default("0") # show_department :boolean default("0") diff --git a/db/migrate/20231010030020_add_data_bank_to_user_actions.rb b/db/migrate/20231010030020_add_data_bank_to_user_actions.rb new file mode 100644 index 000000000..66f792854 --- /dev/null +++ b/db/migrate/20231010030020_add_data_bank_to_user_actions.rb @@ -0,0 +1,5 @@ +class AddDataBankToUserActions < ActiveRecord::Migration[5.2] + def change + add_column :user_actions, :data_bank, :text + end +end From 5a28204b12e7058ee9eaaadc69c5fb1d5b39d943 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 10 Oct 2023 14:17:08 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fixed=20=E6=96=87=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=98=AF=E5=90=A6=E6=96=87=E6=9C=AC=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E6=98=BE=E7=A4=BA=E5=A4=9A=E7=A7=8D=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/repositories_helper.rb | 6 ++++++ app/views/repositories/_simple_entry.json.jbuilder | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index ee783da87..f364c11ff 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -19,6 +19,10 @@ module RepositoriesHelper default_type.include?(str.to_s.gsub("\r", "").downcase) end + def is_text_file?(entry) + entry['is_text_file'] + end + def is_readme?(type, str) return false if type != 'file' || str.blank? readme_types = ["readme.md", "readme", "readme_en.md", "readme_zh.md", "readme_en", "readme_zh"] @@ -232,6 +236,8 @@ module RepositoriesHelper # Rails.logger.info("content===#{content}") return Base64.decode64(content).force_encoding("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding? return Base64.decode64(content).force_encoding('UTF-8') + elsif entry['is_text_file'] == true + return render_decode64_content(entry['content']) else file_type = File.extname(entry['name'].to_s)[1..-1] if image_type?(file_type) diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index 9ad5e3fc2..56b75c198 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -2,7 +2,8 @@ if @project.forge? is_dir = @sub_entries.is_a?(Array) file_name = entry['name'] file_type = file_name.starts_with?('.') ? file_name[1..-1] : File.extname(file_name.to_s)[1..-1] - direct_download = %w(makefile dockerfile readme).exclude?(file_name.to_s.downcase) && download_type(file_type) + # direct_download = %w(makefile dockerfile readme).exclude?(file_name.to_s.downcase) && download_type(file_type) + direct_download = entry['is_text_file'] == true ? false : true image_type = image_type?(file_type) json.name file_name json.sha entry['sha'] From 19d36af37fa9663ce692170ec928eb7550e879f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B1=E5=91=B1=E5=91=B1?= Date: Thu, 12 Oct 2023 11:12:53 +0800 Subject: [PATCH 5/6] update --- app/controllers/organizations/team_users_controller.rb | 8 ++++++-- app/models/issue.rb | 2 +- config/routes.rb | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/organizations/team_users_controller.rb b/app/controllers/organizations/team_users_controller.rb index 7a71dbbad..b6c4ed29d 100644 --- a/app/controllers/organizations/team_users_controller.rb +++ b/app/controllers/organizations/team_users_controller.rb @@ -1,8 +1,8 @@ class Organizations::TeamUsersController < Organizations::BaseController before_action :load_organization, :load_team - before_action :load_operate_user, only: [:create, :destroy] + before_action :load_operate_user, only: [:create, :destroy, :check_user] before_action :check_user_profile_completed, only: [:create] - before_action :load_team_user, only: [:destroy] + before_action :load_team_user, only: [:destroy, :check_user] before_action :check_user_can_edit_org, only: [:create, :destroy] def index @@ -14,6 +14,10 @@ class Organizations::TeamUsersController < Organizations::BaseController @team_users = kaminari_paginate(@team_users) end + def pm_check_user + render_ok + end + def create ActiveRecord::Base.transaction do @team_user = TeamUser.build(@organization.id, @operate_user.id, @team.id) diff --git a/app/models/issue.rb b/app/models/issue.rb index eae5acf6f..4420ed18e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -51,7 +51,7 @@ class Issue < ApplicationRecord #issue_type 1为普通,2为悬赏 - belongs_to :project, counter_cache: true, touch: true + belongs_to :project, counter_cache: true, touch: true, optional: true belongs_to :tracker,optional: true has_many :project_trends, as: :trend, dependent: :destroy has_one :pull_request diff --git a/config/routes.rb b/config/routes.rb index cc10bd987..07cc9d6ed 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -156,6 +156,7 @@ Rails.application.routes.draw do resources :team_users, only: [:index, :create, :destroy] do collection do delete :quit + get :pm_check_user end end resources :team_projects, only: [:index, :create, :destroy] do From d60ba95444d84db586a41ed9e66978b770b4cdc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B1=E5=91=B1=E5=91=B1?= Date: Thu, 12 Oct 2023 11:25:23 +0800 Subject: [PATCH 6/6] OrganizationUsers add pm_check_user --- .../organizations/organization_users_controller.rb | 7 ++++++- app/controllers/organizations/team_users_controller.rb | 4 ++-- config/routes.rb | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/organizations/organization_users_controller.rb b/app/controllers/organizations/organization_users_controller.rb index b31ca1e40..d9035dc14 100644 --- a/app/controllers/organizations/organization_users_controller.rb +++ b/app/controllers/organizations/organization_users_controller.rb @@ -1,6 +1,7 @@ class Organizations::OrganizationUsersController < Organizations::BaseController before_action :load_organization - before_action :load_operate_user, :load_organization_user, :check_user_can_edit_org, only: [:destroy] + before_action :load_operate_user, :load_organization_user, only: [:destroy, :pm_check_user] + before_action :check_user_can_edit_org, only: [:destroy] def index @organization_users = @organization.organization_users.includes(:user) @@ -16,6 +17,10 @@ class Organizations::OrganizationUsersController < Organizations::BaseController @organization_users = kaminari_paginate(@organization_users) end + def pm_check_user + render_ok + end + def destroy tip_exception("您不能从所有者团队中删除最后一个用户") if @organization.is_owner_team_last_one?(@operate_user.id) ActiveRecord::Base.transaction do diff --git a/app/controllers/organizations/team_users_controller.rb b/app/controllers/organizations/team_users_controller.rb index b6c4ed29d..373645220 100644 --- a/app/controllers/organizations/team_users_controller.rb +++ b/app/controllers/organizations/team_users_controller.rb @@ -1,8 +1,8 @@ class Organizations::TeamUsersController < Organizations::BaseController before_action :load_organization, :load_team - before_action :load_operate_user, only: [:create, :destroy, :check_user] + before_action :load_operate_user, only: [:create, :destroy, :pm_check_user] before_action :check_user_profile_completed, only: [:create] - before_action :load_team_user, only: [:destroy, :check_user] + before_action :load_team_user, only: [:destroy, :pm_check_user] before_action :check_user_can_edit_org, only: [:create, :destroy] def index diff --git a/config/routes.rb b/config/routes.rb index 07cc9d6ed..312f267da 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -146,6 +146,7 @@ Rails.application.routes.draw do resources :organization_users, only: [:index, :destroy] do collection do delete :quit + get :pm_check_user end end resources :clas