Merge branch 'develop' into trustie_server
This commit is contained in:
commit
2b0c987558
|
@ -36,8 +36,10 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||||
def update
|
def update
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
login = @organization.login
|
login = @organization.login
|
||||||
@organization.update!(login: organization_params[:name]) if organization_params[:name].present?
|
@organization.login = organization_params[:name] if organization_params[:name].present?
|
||||||
@organization.organization_extension.update_attributes!(organization_params.except(:name))
|
@organization.nickname = organization_params[:nickname] if organization_params[:nickname].present?
|
||||||
|
@organization.save!
|
||||||
|
@organization.organization_extension.update_attributes!(organization_params.except(:name, :nickname))
|
||||||
Gitea::Organization::UpdateService.call(@organization.gitea_token, login, @organization.reload)
|
Gitea::Organization::UpdateService.call(@organization.gitea_token, login, @organization.reload)
|
||||||
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
||||||
end
|
end
|
||||||
|
@ -82,7 +84,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||||
def organization_params
|
def organization_params
|
||||||
params.permit(:name, :description, :website, :location,
|
params.permit(:name, :description, :website, :location,
|
||||||
:repo_admin_change_team_access, :visibility,
|
:repo_admin_change_team_access, :visibility,
|
||||||
:max_repo_creation)
|
:max_repo_creation, :nickname)
|
||||||
end
|
end
|
||||||
|
|
||||||
def password
|
def password
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ProjectsController < ApplicationController
|
||||||
menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls")
|
menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls")
|
||||||
menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops")
|
menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops")
|
||||||
menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
|
menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
|
||||||
|
menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources")
|
||||||
menu.append(menu_hash_by_name("activity"))
|
menu.append(menu_hash_by_name("activity"))
|
||||||
menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.manager?(current_user)
|
menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.manager?(current_user)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
module RepositoriesHelper
|
module RepositoriesHelper
|
||||||
def render_permission(user, project)
|
def render_permission(user, project)
|
||||||
return "Admin" if user&.admin?
|
return "Admin" if user&.admin?
|
||||||
return "Owner" if user === project.owner
|
|
||||||
project.get_premission(user)
|
project.get_premission(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,8 @@ class Organization < Owner
|
||||||
|
|
||||||
scope :with_visibility, ->(visibility) { joins(:organization_extension).where(organization_extensions: {visibility: visibility}) if visibility.present? }
|
scope :with_visibility, ->(visibility) { joins(:organization_extension).where(organization_extensions: {visibility: visibility}) if visibility.present? }
|
||||||
|
|
||||||
def self.build(name, gitea_token=nil)
|
def self.build(name, nickname, gitea_token=nil)
|
||||||
self.create!(login: name, gitea_token: gitea_token)
|
self.create!(login: name, nickname: nickname, gitea_token: gitea_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_create_project?(user_id)
|
def can_create_project?(user_id)
|
||||||
|
@ -113,7 +113,9 @@ class Organization < Owner
|
||||||
end
|
end
|
||||||
|
|
||||||
def real_name
|
def real_name
|
||||||
login
|
name = lastname + firstname
|
||||||
|
name = name.blank? ? (nickname.blank? ? login : nickname) : name
|
||||||
|
name.gsub(/\s+/, '').strip #6.11 -hs
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_real_name
|
def show_real_name
|
||||||
|
|
|
@ -1,75 +1,75 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: projects
|
# Table name: projects
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255) default(""), not null
|
# name :string(255) default(""), not null
|
||||||
# description :text(4294967295)
|
# description :text(4294967295)
|
||||||
# homepage :string(255) default("")
|
# homepage :string(255) default("")
|
||||||
# is_public :boolean default("1"), not null
|
# is_public :boolean default("1"), not null
|
||||||
# parent_id :integer
|
# parent_id :integer
|
||||||
# created_on :datetime
|
# created_on :datetime
|
||||||
# updated_on :datetime
|
# updated_on :datetime
|
||||||
# identifier :string(255)
|
# identifier :string(255)
|
||||||
# status :integer default("1"), not null
|
# status :integer default("1"), not null
|
||||||
# lft :integer
|
# lft :integer
|
||||||
# rgt :integer
|
# rgt :integer
|
||||||
# inherit_members :boolean default("0"), not null
|
# inherit_members :boolean default("0"), not null
|
||||||
# project_type :integer default("0")
|
# project_type :integer default("0")
|
||||||
# hidden_repo :boolean default("0"), not null
|
# hidden_repo :boolean default("0"), not null
|
||||||
# attachmenttype :integer default("1")
|
# attachmenttype :integer default("1")
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
# dts_test :integer default("0")
|
# dts_test :integer default("0")
|
||||||
# enterprise_name :string(255)
|
# enterprise_name :string(255)
|
||||||
# organization_id :integer
|
# organization_id :integer
|
||||||
# project_new_type :integer
|
# project_new_type :integer
|
||||||
# gpid :integer
|
# gpid :integer
|
||||||
# forked_from_project_id :integer
|
# forked_from_project_id :integer
|
||||||
# forked_count :integer default("0")
|
# forked_count :integer default("0")
|
||||||
# publish_resource :integer default("0")
|
# publish_resource :integer default("0")
|
||||||
# visits :integer default("0")
|
# visits :integer default("0")
|
||||||
# hot :integer default("0")
|
# hot :integer default("0")
|
||||||
# invite_code :string(255)
|
# invite_code :string(255)
|
||||||
# qrcode :string(255)
|
# qrcode :string(255)
|
||||||
# qrcode_expiretime :integer default("0")
|
# qrcode_expiretime :integer default("0")
|
||||||
# script :text(65535)
|
# script :text(65535)
|
||||||
# training_status :integer default("0")
|
# training_status :integer default("0")
|
||||||
# rep_identifier :string(255)
|
# rep_identifier :string(255)
|
||||||
# project_category_id :integer
|
# project_category_id :integer
|
||||||
# project_language_id :integer
|
# project_language_id :integer
|
||||||
# license_id :integer
|
# license_id :integer
|
||||||
# ignore_id :integer
|
# ignore_id :integer
|
||||||
# praises_count :integer default("0")
|
# praises_count :integer default("0")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# issues_count :integer default("0")
|
# issues_count :integer default("0")
|
||||||
# pull_requests_count :integer default("0")
|
# pull_requests_count :integer default("0")
|
||||||
# language :string(255)
|
# language :string(255)
|
||||||
# versions_count :integer default("0")
|
# versions_count :integer default("0")
|
||||||
# issue_tags_count :integer default("0")
|
# issue_tags_count :integer default("0")
|
||||||
# closed_issues_count :integer default("0")
|
# closed_issues_count :integer default("0")
|
||||||
# open_devops :boolean default("0")
|
# open_devops :boolean default("0")
|
||||||
# gitea_webhook_id :integer
|
# gitea_webhook_id :integer
|
||||||
# open_devops_count :integer default("0")
|
# open_devops_count :integer default("0")
|
||||||
# recommend :boolean default("0")
|
# recommend :boolean default("0")
|
||||||
# platform :integer default("0")
|
# platform :integer default("0")
|
||||||
# default_branch :string(255) default("master")
|
# default_branch :string(255) default("master")
|
||||||
# website :string(255)
|
# website :string(255)
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# 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_is_public (is_public)
|
# index_projects_on_is_public (is_public)
|
||||||
# index_projects_on_lft (lft)
|
# index_projects_on_lft (lft)
|
||||||
# index_projects_on_name (name)
|
# index_projects_on_name (name)
|
||||||
# index_projects_on_platform (platform)
|
# index_projects_on_platform (platform)
|
||||||
# index_projects_on_project_type (project_type)
|
# index_projects_on_project_type (project_type)
|
||||||
# index_projects_on_recommend (recommend)
|
# index_projects_on_recommend (recommend)
|
||||||
# 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)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,10 +242,12 @@ class Project < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_premission user
|
def get_premission user
|
||||||
permission = "Reporter"
|
return "Owner" if owner?(user)
|
||||||
member = members.find_by(user: user)
|
return "Manager" if manager?(user)
|
||||||
|
return "Developer" if develper?(user)
|
||||||
|
return "Reporter" if reporter?(user)
|
||||||
|
|
||||||
member&.roles&.last&.name || permission
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def fork_project
|
def fork_project
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
class ProjectUnit < ApplicationRecord
|
class ProjectUnit < ApplicationRecord
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
|
||||||
enum unit_type: {code: 1, issues: 2, pulls: 3, devops: 4, versions: 5}
|
enum unit_type: {code: 1, issues: 2, pulls: 3, devops: 4, versions: 5, resources: 6}
|
||||||
|
|
||||||
validates :unit_type, uniqueness: { scope: :project_id}
|
validates :unit_type, uniqueness: { scope: :project_id}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Organizations::CreateService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_org_and_extension
|
def create_org_and_extension
|
||||||
@organization = Organization.build(params[:name], user.gitea_token)
|
@organization = Organization.build(params[:name], params[:nickname], user.gitea_token)
|
||||||
org_extension = OrganizationExtension.build(organization.id, description, website,
|
org_extension = OrganizationExtension.build(organization.id, description, website,
|
||||||
location, repo_admin_change_team_access,
|
location, repo_admin_change_team_access,
|
||||||
visibility, max_repo_creation)
|
visibility, max_repo_creation)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
json.id organization.id
|
json.id organization.id
|
||||||
json.name organization.login
|
json.name organization.login
|
||||||
|
json.nickname organization.nickname
|
||||||
json.description organization.description
|
json.description organization.description
|
||||||
json.website organization.website
|
json.website organization.website
|
||||||
json.location organization.location
|
json.location organization.location
|
||||||
|
|
|
@ -25,6 +25,7 @@ json.projects @projects do |project|
|
||||||
json.image_url render_educoder_avatar_url(project.project_educoder)
|
json.image_url render_educoder_avatar_url(project.project_educoder)
|
||||||
else
|
else
|
||||||
user = project.owner
|
user = project.owner
|
||||||
|
json.type user.type
|
||||||
json.name user.try(:show_real_name)
|
json.name user.try(:show_real_name)
|
||||||
json.login user.login
|
json.login user.login
|
||||||
json.image_url render_avatar_url(user)
|
json.image_url render_avatar_url(user)
|
||||||
|
|
Loading…
Reference in New Issue