team count and delete orgs
This commit is contained in:
parent
ac8372d7e1
commit
05f103b0c4
|
@ -147,52 +147,13 @@ class Organization < Owner
|
||||||
def projects_count
|
def projects_count
|
||||||
Project.where( user_id: self.id).count
|
Project.where( user_id: self.id).count
|
||||||
end
|
end
|
||||||
|
|
||||||
# 用户账号状态
|
def teams_count
|
||||||
def active?
|
teams.count
|
||||||
status == User::STATUS_ACTIVE
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def registered?
|
def organization_users_count
|
||||||
status == User::STATUS_REGISTERED
|
organization_users.count
|
||||||
end
|
|
||||||
|
|
||||||
def locked?
|
|
||||||
status == User::STATUS_LOCKED
|
|
||||||
end
|
|
||||||
|
|
||||||
def need_edit_info?
|
|
||||||
status == User::STATUS_EDIT_INFO
|
|
||||||
end
|
|
||||||
|
|
||||||
def activate
|
|
||||||
self.status = User::STATUS_ACTIVE
|
|
||||||
end
|
|
||||||
|
|
||||||
def register
|
|
||||||
self.status = User::STATUS_REGISTERED
|
|
||||||
end
|
|
||||||
|
|
||||||
def lock
|
|
||||||
self.status = User::STATUS_LOCKED
|
|
||||||
end
|
|
||||||
|
|
||||||
def need_edit_info
|
|
||||||
self.status = User::STATUS_EDIT_INFO
|
|
||||||
end
|
|
||||||
|
|
||||||
def activate!
|
|
||||||
update_attribute(:status, STATUS_ACTIVE)
|
|
||||||
prohibit_gitea_user_login!(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
def register!
|
|
||||||
update_attribute(:status, STATUS_REGISTERED)
|
|
||||||
end
|
|
||||||
|
|
||||||
def lock!
|
|
||||||
update_attribute(:status, STATUS_LOCKED)
|
|
||||||
prohibit_gitea_user_login!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def real_name
|
def real_name
|
||||||
|
|
|
@ -1,24 +1,15 @@
|
||||||
class Admins::DeleteOrganizationService < Gitea::ClientService
|
class Admins::DeleteOrganizationService < Gitea::ClientService
|
||||||
attr_reader :token, :name
|
attr_reader :token, :name
|
||||||
|
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
@name = name
|
@name = name
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
response = delete(url, params)
|
Gitea::Organization::DeleteService.call(token,name)
|
||||||
render_status(response)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def params
|
|
||||||
Hash.new.merge(token: token)
|
|
||||||
end
|
|
||||||
|
|
||||||
def url
|
|
||||||
"/orgs/#{name}".freeze
|
|
||||||
end
|
|
||||||
|
|
||||||
def token
|
def token
|
||||||
{
|
{
|
||||||
username: GiteaService.gitea_config[:access_key_id],
|
username: GiteaService.gitea_config[:access_key_id],
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<table class="table table-hover users-list-table">
|
<table class="table table-hover users-list-table">
|
||||||
<thead class="thead-light">
|
<thead class="thead-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th width="4%">序号</th>
|
<th width="5%">序号</th>
|
||||||
<th width="4%">ID</th>
|
|
||||||
<th width="8%" class="text-left">login</th>
|
<th width="8%" class="text-left">login</th>
|
||||||
<th width="8%" class="text-left">昵称</th>
|
<th width="10%" class="text-left">昵称</th>
|
||||||
<th width="10%"><%= sort_tag('创建于', name: 'created_on', path: admins_organizations_path) %></th>
|
<th width="15%"><%= sort_tag('创建于', name: 'created_on', path: admins_organizations_path) %></th>
|
||||||
<th width="10%"><%= sort_tag('最后登录', name: 'last_login_on', path: admins_organizations_path) %></th>
|
<th width="8%" >团队</th>
|
||||||
<th width="12%">项目数</th>
|
<th width="8%" >成员</th>
|
||||||
<th width="14%">操作</th>
|
<th width="8%">项目数</th>
|
||||||
|
<th width="10%">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -16,7 +16,6 @@
|
||||||
<% organizations.each_with_index do |org, index| %>
|
<% organizations.each_with_index do |org, index| %>
|
||||||
<tr class="org-item-<%= org.id %>">
|
<tr class="org-item-<%= org.id %>">
|
||||||
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
||||||
<td><%= org.id %></td>
|
|
||||||
<td class="text-left">
|
<td class="text-left">
|
||||||
<%= link_to "/#{org.login}", target: '_blank' do %>
|
<%= link_to "/#{org.login}", target: '_blank' do %>
|
||||||
<%= overflow_hidden_span org.login, width: 100 %>
|
<%= overflow_hidden_span org.login, width: 100 %>
|
||||||
|
@ -24,7 +23,8 @@
|
||||||
</td>
|
</td>
|
||||||
<td><%= org.nickname %> </td>
|
<td><%= org.nickname %> </td>
|
||||||
<td><%= display_text(org.created_on&.strftime('%Y-%m-%d %H:%M')) %></td>
|
<td><%= display_text(org.created_on&.strftime('%Y-%m-%d %H:%M')) %></td>
|
||||||
<td><%= display_text(org.last_login_on&.strftime('%Y-%m-%d %H:%M')) %></td>
|
<td><%= link_to org.teams_count, "/#{org.login}", target: "_blank" %></td>
|
||||||
|
<td><%= link_to org.organization_users_count, "/#{org.login}", target: "_blank" %></td>
|
||||||
<td><%= link_to org.projects_count, "/#{org.login}", target: "_blank" %></td>
|
<td><%= link_to org.projects_count, "/#{org.login}", target: "_blank" %></td>
|
||||||
<td class="action-container">
|
<td class="action-container">
|
||||||
<%= link_to '查看', admins_organization_path(org), class: 'action' %>
|
<%= link_to '查看', admins_organization_path(org), class: 'action' %>
|
||||||
|
|
Loading…
Reference in New Issue