merge from develop
This commit is contained in:
commit
a15d0827b7
|
@ -6,7 +6,7 @@ module Admins::ProjectsHelper
|
|||
if owner.is_a?(User)
|
||||
link_to(project.owner&.real_name, "/#{project&.owner&.login}", target: '_blank')
|
||||
elsif owner.is_a?(Organization)
|
||||
link_to(project.owner&.real_name, "/organize/#{project&.owner&.login}", target: '_blank')
|
||||
link_to(project.owner&.real_name, "/#{project&.owner&.login}", target: '_blank')
|
||||
else
|
||||
""
|
||||
end
|
||||
|
|
|
@ -15,13 +15,14 @@ class Admins::UpdateUserService < ApplicationService
|
|||
user.firstname = ''
|
||||
user.password = params[:password] if params[:password].present?
|
||||
|
||||
user.user_extension.assign_attributes(user_extension_attributes)
|
||||
user.user_extension.assign_attributes(user_extension_attributes) if user.user_extension.present?
|
||||
|
||||
old_login = user.login
|
||||
ActiveRecord::Base.transaction do
|
||||
user.save!
|
||||
user.user_extension.save!
|
||||
user.user_extension.save! if user.user_extension.present?
|
||||
update_gitea_user(old_login)
|
||||
update_gitea_user_email(user.previous_changes[:mail])
|
||||
end
|
||||
|
||||
user
|
||||
|
@ -65,4 +66,14 @@ class Admins::UpdateUserService < ApplicationService
|
|||
Util.logger_error(ex)
|
||||
raise Error, '保存失败'
|
||||
end
|
||||
|
||||
def update_gitea_user_email(change_options)
|
||||
return if change_options.blank?
|
||||
return if user.gitea_uid.blank? || user.gitea_token.blank?
|
||||
$gitea_client.delete_user_emails({body: {emails: [change_options[0]]}.to_json, query: {access_token: user.gitea_token}})
|
||||
$gitea_client.post_user_emails({body: {emails: [change_options[1]]}.to_json, query: {access_token: user.gitea_token}})
|
||||
rescue Exception => ex
|
||||
Util.logger_error(ex)
|
||||
raise Error, '保存失败'
|
||||
end
|
||||
end
|
|
@ -68,12 +68,12 @@
|
|||
<%= f.label :identity, label: '职业' %>
|
||||
<%= select_tag('user[identity]', [], class: 'form-control identity-select optional', 'data-value': @user.user_extension&.identity, 'data-first-title': '请选择') %>
|
||||
</div>
|
||||
<div class="form-group technical-title-select-wrapper optional col-md-1" style="<%= @user.user_extension.student? ? 'display:none;' : '' %>">
|
||||
<div class="form-group technical-title-select-wrapper optional col-md-1" style="<%= @user&.user_extension&.student? ? 'display:none;' : '' %>">
|
||||
<%= f.label :technical_title, label: '职称' %>
|
||||
<%= select_tag('user[technical_title]', [], class: 'form-control technical-title-select optional', 'data-value': @user.technical_title) %>
|
||||
</div>
|
||||
|
||||
<%= f.input :student_id, as: :tel, label: '学号', wrapper_html: { class: 'col-md-2', style: @user.user_extension.student? ? '' : 'display:none;' }, input_html: { class: 'student-id-input' } %>
|
||||
<%= f.input :student_id, as: :tel, label: '学号', wrapper_html: { class: 'col-md-2', style: @user&.user_extension&.student? ? '' : 'display:none;' }, input_html: { class: 'student-id-input' } %>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<td><%= user.identity %></td>
|
||||
<td><%= display_text(user.created_on&.strftime('%Y-%m-%d %H:%M')) %></td>
|
||||
<td><%= display_text(user.last_login_on&.strftime('%Y-%m-%d %H:%M')) %></td>
|
||||
<td><%= link_to user.projects_count, "/users/#{user.login}/projects", target: "_blank" %></td>
|
||||
<td><%= link_to user.projects_count, "/#{user.login}/projects", target: "_blank" %></td>
|
||||
<td class="action-container">
|
||||
<%= link_to '编辑', edit_admins_user_path(user), class: 'action' %>
|
||||
|
||||
|
|
Loading…
Reference in New Issue