parent
3f73484596
commit
0c58447afb
|
@ -31,4 +31,13 @@ class Organizations::BaseController < ApplicationController
|
|||
def project_mark
|
||||
params[:repo_name] || params[:id]
|
||||
end
|
||||
|
||||
private
|
||||
def limited_condition
|
||||
@organization.organization_extension.limited? && !current_user.logged?
|
||||
end
|
||||
|
||||
def privacy_condition
|
||||
@organization.organization_extension.privacy? && @organization.organization_users.where(user_id: current_user.id).blank?
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
class Organizations::OrganizationsController < Organizations::BaseController
|
||||
before_action :require_login, except: [:index, :show]
|
||||
before_action :convert_base64_image!, only: [:create, :update]
|
||||
before_action :convert_image!, only: [:create, :update]
|
||||
before_action :load_organization, only: [:show, :update, :destroy]
|
||||
before_action :check_user_can_edit_org, only: [:update, :destroy]
|
||||
|
||||
|
@ -11,6 +11,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
@organizations = Organization.from("( #{ logged_organizations_sql } UNION #{ privacy_organizations_sql } ) AS users")
|
||||
else
|
||||
@organizations = Organization.with_visibility("common")
|
||||
kaminari_paginate(@organizations)
|
||||
end
|
||||
@organizations = @organizations.ransack(login_cont: params[:search]).result if params[:search].present?
|
||||
@organizations = @organizations.includes(:organization_extension).order("organization_extensions.#{sort_by} #{sort_direction}")
|
||||
|
@ -56,9 +57,17 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
end
|
||||
|
||||
private
|
||||
def convert_base64_image!
|
||||
max_size = EduSetting.get('upload_avatar_max_size')
|
||||
@image = Util.convert_base64_image(params[:image].to_s.strip, max_size: max_size)
|
||||
def convert_image!
|
||||
max_size = EduSetting.get('upload_avatar_max_size') || 2 * 1024 * 1024 # 2M
|
||||
if params[:image].class == ActionDispatch::Http::UploadedFile
|
||||
@image = params[:image]
|
||||
render_error('请上传文件') if @image.size.zero?
|
||||
render_error('文件大小超过限制') if @image.size > max_size
|
||||
else
|
||||
image = params[:image].to_s.strip
|
||||
return render_error('请上传正确的图片') if image.blank?
|
||||
@image = Util.convert_base64_image(image, max_size: max_size)
|
||||
end
|
||||
rescue Base64ImageConverter::Error => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class ProjectsController < ApplicationController
|
|||
scope = Projects::ListQuery.call(params)
|
||||
|
||||
# @projects = kaminari_paginate(scope)
|
||||
@projects = paginate scope.includes(:project_category, :project_language, :repository, :project_educoder, owner: :user_extension)
|
||||
@projects = paginate scope.includes(:project_category, :project_language, :repository, :project_educoder, :owner)
|
||||
|
||||
category_id = params[:category_id]
|
||||
@total_count =
|
||||
|
@ -128,7 +128,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def recommend
|
||||
@projects = Project.recommend.includes(:repository, :project_category, owner: :user_extension).limit(5)
|
||||
@projects = Project.recommend.includes(:repository, :project_category, :owner).limit(5)
|
||||
end
|
||||
|
||||
def about
|
||||
|
|
|
@ -61,12 +61,14 @@ module ProjectsHelper
|
|||
{
|
||||
login: project.project_educoder.owner,
|
||||
name: project.project_educoder.owner,
|
||||
type: 'Educoder',
|
||||
image_url: project.project_educoder.image_url
|
||||
}
|
||||
else
|
||||
{
|
||||
login: @owner.login,
|
||||
name: @owner.real_name,
|
||||
type: @owner.type,
|
||||
image_url: url_to_avatar(@owner)
|
||||
}
|
||||
end
|
||||
|
|
|
@ -167,7 +167,7 @@ class User < Owner
|
|||
where("LOWER(concat(lastname, firstname, login, mail)) LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
|
||||
}
|
||||
|
||||
scope :simple_select, -> {select(:id, :login, :lastname,:firstname, :nickname, :gitea_uid)}
|
||||
scope :simple_select, -> {select(:id, :login, :lastname,:firstname, :nickname, :gitea_uid, :type)}
|
||||
|
||||
attr_accessor :password, :password_confirmation
|
||||
|
||||
|
|
|
@ -11,16 +11,30 @@ class Organizations::CreateService < ApplicationService
|
|||
Rails.logger.info("######Organization create_service begin######")
|
||||
Rails.logger.info("######params #{params}######")
|
||||
ActiveRecord::Base.transaction do
|
||||
<<<<<<< HEAD
|
||||
create_org_and_extension
|
||||
create_owner_info
|
||||
create_gitea_org
|
||||
sync_owner_team_gtid
|
||||
=======
|
||||
@organization = Organization.build(params[:name])
|
||||
org_extension = OrganizationExtension.build(@organization.id, description, website,
|
||||
location, repo_admin_change_team_access,
|
||||
visibility, max_repo_creation)
|
||||
team = Team.build_owner(@organization.id)
|
||||
TeamUnit.build_owner(@organization.id, team.id)
|
||||
OrganizationUser.build(@organization.id, user.id, true)
|
||||
TeamUser.build(@organization.id, user.id, team.id)
|
||||
|
||||
Gitea::Organization::CreateService.call(user.gitea_token, @organization)
|
||||
>>>>>>> 38887e6... [FIX]
|
||||
|
||||
Rails.logger.info("######Organization create_service end######")
|
||||
end
|
||||
@organization
|
||||
end
|
||||
|
||||
<<<<<<< HEAD
|
||||
private
|
||||
def description
|
||||
params[:description]
|
||||
|
@ -32,6 +46,18 @@ class Organizations::CreateService < ApplicationService
|
|||
|
||||
def location
|
||||
params[:location]
|
||||
=======
|
||||
def description
|
||||
params[:description].present? ? params[:description] : nil
|
||||
end
|
||||
|
||||
def website
|
||||
params[:website].present? ? params[:website] : nil
|
||||
end
|
||||
|
||||
def location
|
||||
params[:location].present? ? params[:location] : nil
|
||||
>>>>>>> 38887e6... [FIX]
|
||||
end
|
||||
|
||||
def repo_admin_change_team_access
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
json.total_count @projects.total_count
|
||||
json.projects @projects.each do |project|
|
||||
json.(project, :id, :name, :identifier, :description, :forked_count, :praises_count)
|
||||
json.(project, :id, :name, :identifier, :description, :forked_count, :praises_count, :forked_from_project_id)
|
||||
json.mirror_url project.repository&.mirror_url
|
||||
json.type project.numerical_for_project_type
|
||||
json.praised project.praised_by?(current_user)
|
||||
json.last_update_time render_unix_time(project.updated_on)
|
||||
json.time_ago time_from_now(project.updated_on)
|
||||
|
|
|
@ -18,11 +18,13 @@ json.author do
|
|||
if project.educoder?
|
||||
project_educoder = project.project_educoder
|
||||
json.name project_educoder&.owner
|
||||
json.type 'Educoder'
|
||||
json.login project_educoder&.repo_name.split('/')[0]
|
||||
json.image_url render_educoder_avatar_url(project.project_educoder)
|
||||
else
|
||||
user = project.owner
|
||||
json.name user.try(:show_real_name)
|
||||
json.type user&.type
|
||||
json.login user.login
|
||||
json.image_url render_avatar_url(user)
|
||||
end
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
json.author do
|
||||
if @project.forge?
|
||||
json.login user.login
|
||||
json.type user&.type
|
||||
json.name user.real_name
|
||||
json.image_url url_to_avatar(user)
|
||||
else
|
||||
json.login @project.project_educoder&.repo_name&.split('/')[0]
|
||||
json.name @project.project_educoder&.owner
|
||||
json.type 'Educoder'
|
||||
json.image_url @project.project_educoder&.image_url
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue