| @@ -31,6 +31,7 @@ class Admins::OrganizationsController < Admins::BaseController | |||||
| def destroy | def destroy | ||||
| @org.destroy! | @org.destroy! | ||||
| Admins::DeleteOrganizationService.call(@org.login) | 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 | render_delete_success | ||||
| end | end | ||||
| @@ -35,6 +35,7 @@ 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 | ||||
| @@ -25,15 +25,16 @@ 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) | ||||
| render_delete_success | render_delete_success | ||||
| end | end | ||||
| 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 | ||||
| @@ -1,6 +1,7 @@ | |||||
| class Organizations::OrganizationUsersController < Organizations::BaseController | class Organizations::OrganizationUsersController < Organizations::BaseController | ||||
| before_action :load_organization | 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 | def index | ||||
| @organization_users = @organization.organization_users.includes(:user) | @organization_users = @organization.organization_users.includes(:user) | ||||
| @@ -16,6 +17,10 @@ class Organizations::OrganizationUsersController < Organizations::BaseController | |||||
| @organization_users = kaminari_paginate(@organization_users) | @organization_users = kaminari_paginate(@organization_users) | ||||
| end | end | ||||
| def pm_check_user | |||||
| render_ok | |||||
| end | |||||
| def destroy | def destroy | ||||
| tip_exception("您不能从所有者团队中删除最后一个用户") if @organization.is_owner_team_last_one?(@operate_user.id) | tip_exception("您不能从所有者团队中删除最后一个用户") if @organization.is_owner_team_last_one?(@operate_user.id) | ||||
| ActiveRecord::Base.transaction do | ActiveRecord::Base.transaction do | ||||
| @@ -1,8 +1,8 @@ | |||||
| class Organizations::TeamUsersController < Organizations::BaseController | class Organizations::TeamUsersController < Organizations::BaseController | ||||
| before_action :load_organization, :load_team | before_action :load_organization, :load_team | ||||
| before_action :load_operate_user, only: [:create, :destroy] | |||||
| before_action :load_operate_user, only: [:create, :destroy, :pm_check_user] | |||||
| before_action :check_user_profile_completed, only: [:create] | before_action :check_user_profile_completed, only: [:create] | ||||
| before_action :load_team_user, only: [:destroy] | |||||
| before_action :load_team_user, only: [:destroy, :pm_check_user] | |||||
| before_action :check_user_can_edit_org, only: [:create, :destroy] | before_action :check_user_can_edit_org, only: [:create, :destroy] | ||||
| def index | def index | ||||
| @@ -14,6 +14,10 @@ class Organizations::TeamUsersController < Organizations::BaseController | |||||
| @team_users = kaminari_paginate(@team_users) | @team_users = kaminari_paginate(@team_users) | ||||
| end | end | ||||
| def pm_check_user | |||||
| render_ok | |||||
| end | |||||
| def create | def create | ||||
| ActiveRecord::Base.transaction do | ActiveRecord::Base.transaction do | ||||
| @team_user = TeamUser.build(@organization.id, @operate_user.id, @team.id) | @team_user = TeamUser.build(@organization.id, @operate_user.id, @team.id) | ||||
| @@ -19,6 +19,10 @@ module RepositoriesHelper | |||||
| default_type.include?(str.to_s.gsub("\r", "").downcase) | default_type.include?(str.to_s.gsub("\r", "").downcase) | ||||
| end | end | ||||
| def is_text_file?(entry) | |||||
| entry['is_text_file'] | |||||
| end | |||||
| def is_readme?(type, str) | def is_readme?(type, str) | ||||
| return false if type != 'file' || str.blank? | return false if type != 'file' || str.blank? | ||||
| readme_types = ["readme.md", "readme", "readme_en.md", "readme_zh.md", "readme_en", "readme_zh"] | 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}") | # 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("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding? | ||||
| return Base64.decode64(content).force_encoding('UTF-8') | return Base64.decode64(content).force_encoding('UTF-8') | ||||
| elsif entry['is_text_file'] == true | |||||
| return render_decode64_content(entry['content']) | |||||
| else | else | ||||
| file_type = File.extname(entry['name'].to_s)[1..-1] | file_type = File.extname(entry['name'].to_s)[1..-1] | ||||
| if image_type?(file_type) | if image_type?(file_type) | ||||
| @@ -26,6 +26,8 @@ | |||||
| # cloud_url :string(255) default("") | # cloud_url :string(255) default("") | ||||
| # course_second_category_id :integer default("0") | # course_second_category_id :integer default("0") | ||||
| # delay_publish :boolean default("0") | # delay_publish :boolean default("0") | ||||
| # memo_image :boolean default("0") | |||||
| # extra_type :integer default("0") | |||||
| # | # | ||||
| # Indexes | # Indexes | ||||
| # | # | ||||
| @@ -36,7 +36,7 @@ class GlccMediumTermExamineMaterial < ActiveRecord::Base | |||||
| unless pull_index == 5 | unless pull_index == 5 | ||||
| state << 2 | state << 2 | ||||
| end | 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)) | project = Project.find_by(identifier: url_array[4], user_id:user.try(:id)) | ||||
| pr = PullRequest.where(project:project, gitea_number:url_array[6]) | pr = PullRequest.where(project:project, gitea_number:url_array[6]) | ||||
| @@ -17,7 +17,7 @@ | |||||
| # | # | ||||
| # Indexes | # Indexes | ||||
| # | # | ||||
| # index_identity_verifications_on_number (number) | |||||
| # index_identity_verifications_on_user_id (user_id) | |||||
| # | # | ||||
| class IdentityVerification < ApplicationRecord | class IdentityVerification < ApplicationRecord | ||||
| @@ -51,7 +51,7 @@ | |||||
| class Issue < ApplicationRecord | class Issue < ApplicationRecord | ||||
| #issue_type 1为普通,2为悬赏 | #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 | belongs_to :tracker,optional: true | ||||
| has_many :project_trends, as: :trend, dependent: :destroy | has_many :project_trends, as: :trend, dependent: :destroy | ||||
| has_one :pull_request | has_one :pull_request | ||||
| @@ -7,6 +7,7 @@ | |||||
| # content :text(65535) | # content :text(65535) | ||||
| # created_at :datetime not null | # created_at :datetime not null | ||||
| # updated_at :datetime not null | # updated_at :datetime not null | ||||
| # is_secret :boolean default("0") | |||||
| # | # | ||||
| class License < ApplicationRecord | class License < ApplicationRecord | ||||
| @@ -11,6 +11,7 @@ | |||||
| # course_group_id :integer default("0") | # course_group_id :integer default("0") | ||||
| # is_collect :integer default("1") | # is_collect :integer default("1") | ||||
| # graduation_group_id :integer default("0") | # graduation_group_id :integer default("0") | ||||
| # is_apply_signature :boolean default("0") | |||||
| # team_user_id :integer | # team_user_id :integer | ||||
| # | # | ||||
| # Indexes | # Indexes | ||||
| @@ -5,6 +5,7 @@ | |||||
| # id :integer not null, primary key | # id :integer not null, primary key | ||||
| # user_id :integer | # user_id :integer | ||||
| # organization_id :integer | # organization_id :integer | ||||
| # is_creator :boolean default("0") | |||||
| # created_at :datetime not null | # created_at :datetime not null | ||||
| # updated_at :datetime not null | # updated_at :datetime not null | ||||
| # | # | ||||
| @@ -62,6 +62,7 @@ | |||||
| # | # | ||||
| # Indexes | # Indexes | ||||
| # | # | ||||
| # index_projects_on_forked_count (forked_count) | |||||
| # index_projects_on_forked_from_project_id (forked_from_project_id) | # index_projects_on_forked_from_project_id (forked_from_project_id) | ||||
| # index_projects_on_identifier (identifier) | # index_projects_on_identifier (identifier) | ||||
| # index_projects_on_invite_code (invite_code) | # index_projects_on_invite_code (invite_code) | ||||
| @@ -71,6 +72,7 @@ | |||||
| # index_projects_on_license_id (license_id) | # index_projects_on_license_id (license_id) | ||||
| # index_projects_on_name (name) | # index_projects_on_name (name) | ||||
| # index_projects_on_platform (platform) | # 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_category_id (project_category_id) | ||||
| # index_projects_on_project_language_id (project_language_id) | # index_projects_on_project_language_id (project_language_id) | ||||
| # index_projects_on_project_type (project_type) | # index_projects_on_project_type (project_type) | ||||
| @@ -78,6 +80,7 @@ | |||||
| # index_projects_on_rgt (rgt) | # index_projects_on_rgt (rgt) | ||||
| # index_projects_on_status (status) | # index_projects_on_status (status) | ||||
| # index_projects_on_updated_on (updated_on) | # index_projects_on_updated_on (updated_on) | ||||
| # index_projects_on_user_id (user_id) | |||||
| # | # | ||||
| class Project < ApplicationRecord | class Project < ApplicationRecord | ||||
| @@ -15,6 +15,7 @@ | |||||
| # Indexes | # Indexes | ||||
| # | # | ||||
| # index_project_categories_on_ancestry (ancestry) | # index_project_categories_on_ancestry (ancestry) | ||||
| # index_project_categories_on_id (id) | |||||
| # | # | ||||
| class ProjectCategory < ApplicationRecord | class ProjectCategory < ApplicationRecord | ||||
| @@ -9,6 +9,10 @@ | |||||
| # created_at :datetime not null | # created_at :datetime not null | ||||
| # updated_at :datetime not null | # updated_at :datetime not null | ||||
| # | # | ||||
| # Indexes | |||||
| # | |||||
| # index_project_languages_on_id (id) | |||||
| # | |||||
| class ProjectLanguage < ApplicationRecord | class ProjectLanguage < ApplicationRecord | ||||
| include Projectable | include Projectable | ||||
| @@ -27,6 +27,7 @@ | |||||
| # | # | ||||
| # Indexes | # Indexes | ||||
| # | # | ||||
| # index_name (project_id) | |||||
| # index_repositories_on_identifier (identifier) | # index_repositories_on_identifier (identifier) | ||||
| # index_repositories_on_project_id (project_id) | # index_repositories_on_project_id (project_id) | ||||
| # index_repositories_on_user_id (user_id) | # index_repositories_on_user_id (user_id) | ||||
| @@ -9,6 +9,7 @@ | |||||
| # created_at :datetime not null | # created_at :datetime not null | ||||
| # updated_at :datetime not null | # updated_at :datetime not null | ||||
| # ip :string(255) | # ip :string(255) | ||||
| # data_bank :text(65535) | |||||
| # | # | ||||
| # Indexes | # Indexes | ||||
| # | # | ||||
| @@ -22,9 +22,9 @@ | |||||
| # school_id :integer | # school_id :integer | ||||
| # description :string(255) | # description :string(255) | ||||
| # department_id :integer | # department_id :integer | ||||
| # province :string(255) | |||||
| # city :string(255) | |||||
| # province :text(65535) | |||||
| # custom_department :string(255) | # custom_department :string(255) | ||||
| # city :string(255) | |||||
| # show_email :boolean default("0") | # show_email :boolean default("0") | ||||
| # show_location :boolean default("0") | # show_location :boolean default("0") | ||||
| # show_department :boolean default("0") | # show_department :boolean default("0") | ||||
| @@ -76,7 +76,7 @@ class Api::V1::Issues::ListService < ApplicationService | |||||
| end | end | ||||
| # keyword | # 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 | @total_issues_count = issues.distinct.size | ||||
| @closed_issues_count = issues.closed.distinct.size | @closed_issues_count = issues.closed.distinct.size | ||||
| @@ -2,7 +2,8 @@ if @project.forge? | |||||
| is_dir = @sub_entries.is_a?(Array) | is_dir = @sub_entries.is_a?(Array) | ||||
| file_name = entry['name'] | file_name = entry['name'] | ||||
| file_type = file_name.starts_with?('.') ? file_name[1..-1] : File.extname(file_name.to_s)[1..-1] | 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) | image_type = image_type?(file_type) | ||||
| json.name file_name | json.name file_name | ||||
| json.sha entry['sha'] | json.sha entry['sha'] | ||||
| @@ -146,6 +146,7 @@ Rails.application.routes.draw do | |||||
| resources :organization_users, only: [:index, :destroy] do | resources :organization_users, only: [:index, :destroy] do | ||||
| collection do | collection do | ||||
| delete :quit | delete :quit | ||||
| get :pm_check_user | |||||
| end | end | ||||
| end | end | ||||
| resources :clas | resources :clas | ||||
| @@ -156,6 +157,7 @@ Rails.application.routes.draw do | |||||
| resources :team_users, only: [:index, :create, :destroy] do | resources :team_users, only: [:index, :create, :destroy] do | ||||
| collection do | collection do | ||||
| delete :quit | delete :quit | ||||
| get :pm_check_user | |||||
| end | end | ||||
| end | end | ||||
| resources :team_projects, only: [:index, :create, :destroy] do | resources :team_projects, only: [:index, :create, :destroy] do | ||||
| @@ -0,0 +1,5 @@ | |||||
| class AddDataBankToUserActions < ActiveRecord::Migration[5.2] | |||||
| def change | |||||
| add_column :user_actions, :data_bank, :text | |||||
| end | |||||
| end | |||||