FIX merge develop branch
This commit is contained in:
commit
3af75e1a1c
|
@ -21,7 +21,7 @@ class Organizations::BaseController < ApplicationController
|
|||
end
|
||||
|
||||
def team_not_found_condition
|
||||
@team.team_users.where(user_id: current_user.id).blank? && !@organization.is_owner?(current_user.id)
|
||||
!current_user&.admin? && @team.team_users.where(user_id: current_user.id).blank? && !@organization.is_owner?(current_user.id)
|
||||
end
|
||||
|
||||
def user_mark
|
||||
|
|
|
@ -36,8 +36,10 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
login = @organization.login
|
||||
@organization.update!(login: organization_params[:name]) if organization_params[:name].present?
|
||||
@organization.organization_extension.update_attributes!(organization_params.except(:name))
|
||||
@organization.login = organization_params[:name] if organization_params[:name].present?
|
||||
@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)
|
||||
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
||||
end
|
||||
|
@ -82,7 +84,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
def organization_params
|
||||
params.permit(:name, :description, :website, :location,
|
||||
:repo_admin_change_team_access, :visibility,
|
||||
:max_repo_creation)
|
||||
:max_repo_creation, :nickname)
|
||||
end
|
||||
|
||||
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("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("resources")) if @project.has_menu_permission("resources")
|
||||
menu.append(menu_hash_by_name("activity"))
|
||||
menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.manager?(current_user)
|
||||
|
||||
|
@ -182,7 +183,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
private
|
||||
def project_params
|
||||
params.permit(:user_id, :name, :description, :repository_name, :website,
|
||||
params.permit(:user_id, :name, :description, :repository_name, :website, :lesson_url,
|
||||
:project_category_id, :project_language_id, :license_id, :ignore_id, :private)
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
|||
|
||||
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users]
|
||||
before_action :check_user_exist, only: [:show, :homepage_info,:projects, :watch_users, :fan_users]
|
||||
before_action :require_login, only: %i[me list]
|
||||
before_action :require_login, only: %i[me list sync_user_info]
|
||||
before_action :connect_to_ci_db, only: [:get_user_info]
|
||||
skip_before_action :check_sign, only: [:attachment_show]
|
||||
|
||||
|
@ -233,6 +233,26 @@ class UsersController < ApplicationController
|
|||
render_ok
|
||||
end
|
||||
|
||||
def sync_user_info
|
||||
user = User.find_by_login params[:login]
|
||||
return render_forbidden unless user === current_user
|
||||
|
||||
sync_params = {
|
||||
email: params[:email],
|
||||
password: params[:password]
|
||||
}
|
||||
|
||||
Users::UpdateInfoForm.new(sync_params.merge(login: params[:login])).validate!
|
||||
|
||||
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params)
|
||||
if interactor.success?
|
||||
user.update!(password: params[:password], mail: params[:email], status: User::STATUS_EDIT_INFO)
|
||||
render_ok
|
||||
else
|
||||
render_error(interactor.error)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def load_user
|
||||
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class Users::UpdateInfoForm
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :email, :password, :login
|
||||
|
||||
validates :email, presence: true, format: { with: CustomRegexp::EMAIL }
|
||||
validates :password, presence: true
|
||||
validates :login, presence: true
|
||||
end
|
|
@ -1,7 +1,6 @@
|
|||
module RepositoriesHelper
|
||||
def render_permission(user, project)
|
||||
return "Admin" if user&.admin?
|
||||
return "Owner" if user === project.owner
|
||||
project.get_premission(user)
|
||||
end
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ class Organization < Owner
|
|||
|
||||
scope :with_visibility, ->(visibility) { joins(:organization_extension).where(organization_extensions: {visibility: visibility}) if visibility.present? }
|
||||
|
||||
def self.build(name, gitea_token=nil)
|
||||
self.create!(login: name, gitea_token: gitea_token)
|
||||
def self.build(name, nickname, gitea_token=nil)
|
||||
self.create!(login: name, nickname: nickname, gitea_token: gitea_token)
|
||||
end
|
||||
|
||||
def can_create_project?(user_id)
|
||||
|
@ -113,7 +113,9 @@ class Organization < Owner
|
|||
end
|
||||
|
||||
def real_name
|
||||
login
|
||||
name = lastname + firstname
|
||||
name = name.blank? ? (nickname.blank? ? login : nickname) : name
|
||||
name.gsub(/\s+/, '').strip #6.11 -hs
|
||||
end
|
||||
|
||||
def show_real_name
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) default(""), not null
|
||||
# description :text(65535)
|
||||
# description :text(4294967295)
|
||||
# homepage :string(255) default("")
|
||||
# is_public :boolean default("1"), not null
|
||||
# parent_id :integer
|
||||
|
@ -43,6 +43,17 @@
|
|||
# watchers_count :integer default("0")
|
||||
# issues_count :integer default("0")
|
||||
# pull_requests_count :integer default("0")
|
||||
# language :string(255)
|
||||
# versions_count :integer default("0")
|
||||
# issue_tags_count :integer default("0")
|
||||
# closed_issues_count :integer default("0")
|
||||
# open_devops :boolean default("0")
|
||||
# gitea_webhook_id :integer
|
||||
# open_devops_count :integer default("0")
|
||||
# recommend :boolean default("0")
|
||||
# platform :integer default("0")
|
||||
# default_branch :string(255) default("master")
|
||||
# website :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
@ -59,10 +70,6 @@
|
|||
# index_projects_on_updated_on (updated_on)
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Project < ApplicationRecord
|
||||
include Matchable
|
||||
include Publicable
|
||||
|
@ -231,10 +238,12 @@ class Project < ApplicationRecord
|
|||
end
|
||||
|
||||
def get_premission user
|
||||
permission = "Reporter"
|
||||
member = members.find_by(user: user)
|
||||
return "Owner" if owner?(user)
|
||||
return "Manager" if manager?(user)
|
||||
return "Developer" if develper?(user)
|
||||
return "Reporter" if reporter?(user)
|
||||
|
||||
member&.roles&.last&.name || permission
|
||||
return ""
|
||||
end
|
||||
|
||||
def fork_project
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
class ProjectUnit < ApplicationRecord
|
||||
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}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class Ci::Builds::ListQuery < ApplicationQuery
|
|||
scope
|
||||
end
|
||||
|
||||
builds = scope.by_branch(params[:branch]) if params[:branch]
|
||||
builds = builds.by_branch(params[:branch]) if params[:branch]
|
||||
|
||||
custom_sort(builds, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ class Organizations::CreateService < ApplicationService
|
|||
end
|
||||
|
||||
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,
|
||||
location, repo_admin_change_team_access,
|
||||
visibility, max_repo_creation)
|
||||
|
|
|
@ -24,6 +24,8 @@ class Projects::ForkService < ApplicationService
|
|||
new_repository.identifier = @project.identifier
|
||||
new_repository.save!
|
||||
|
||||
ProjectUnit.init_types(clone_project.id)
|
||||
|
||||
result = Gitea::Repository::ForkService.new(@project.owner, @target_owner, @project.identifier, @organization).call
|
||||
|
||||
@project.update_column('forked_count', @project&.forked_count.to_i + 1)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
json.id organization.id
|
||||
json.name organization.login
|
||||
json.nickname organization.nickname
|
||||
json.description organization.description
|
||||
json.website organization.website
|
||||
json.location organization.location
|
||||
|
|
|
@ -25,6 +25,7 @@ json.projects @projects do |project|
|
|||
json.image_url render_educoder_avatar_url(project.project_educoder)
|
||||
else
|
||||
user = project.owner
|
||||
json.type user.type
|
||||
json.name user.try(:show_real_name)
|
||||
json.login user.login
|
||||
json.image_url render_avatar_url(user)
|
||||
|
|
|
@ -6,3 +6,4 @@ json.project_category_id @project.project_category_id
|
|||
json.project_language_id @project.project_language_id
|
||||
json.is_public @project.is_public
|
||||
json.website @project.website
|
||||
json.lesson_url @project.lesson_url
|
|
@ -1,11 +1,11 @@
|
|||
json.author do
|
||||
author = User.find_by(login: commit['Author']['Name'])
|
||||
json.partial! 'repositories/commit_author', locals: { user: author }
|
||||
json.partial! 'repositories/commit_author', locals: { user: author, name: commit['Committer']['Name'] }
|
||||
end
|
||||
|
||||
json.committer do
|
||||
author = User.find_by(login: commit['Committer']['Name'])
|
||||
json.partial! 'repositories/commit_author', locals: { user: author }
|
||||
json.partial! 'repositories/commit_author', locals: { user: author, name: commit['Committer']['Name'] }
|
||||
end
|
||||
json.timestamp render_unix_time(commit['Committer']['When'])
|
||||
json.time_from_now time_from_now(commit['Committer']['When'])
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
json.content @project.content
|
||||
json.website @project.website
|
||||
json.lesson_url @project.lesson_url
|
||||
if @result[:readme].blank?
|
||||
json.readme nil
|
||||
else
|
||||
|
|
|
@ -7,3 +7,4 @@ json.project_language_id @project.project_language_id
|
|||
json.private !@project.is_public
|
||||
json.website @project.website
|
||||
json.project_units @project.project_units.pluck(:unit_type)
|
||||
json.lesson_url @project.lesson_url
|
|
@ -218,6 +218,7 @@ Rails.application.routes.draw do
|
|||
post :sync_salt
|
||||
get :trustie_projects
|
||||
get :trustie_related_projects
|
||||
post :sync_user_info
|
||||
|
||||
scope '/ci', module: :ci do
|
||||
scope do
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddLessonUrlToProjects < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :projects, :lesson_url, :string
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue