team count and delete orgs

This commit is contained in:
chenjing 2023-02-22 09:12:16 +08:00 committed by xxq250
parent 9aef00ce06
commit 960337206b
3 changed files with 16 additions and 64 deletions

View File

@ -147,52 +147,13 @@ class Organization < Owner
def projects_count
Project.where( user_id: self.id).count
end
# 用户账号状态
def active?
status == User::STATUS_ACTIVE
def teams_count
teams.count
end
def registered?
status == User::STATUS_REGISTERED
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!
def organization_users_count
organization_users.count
end
def real_name

View File

@ -1,24 +1,15 @@
class Admins::DeleteOrganizationService < Gitea::ClientService
attr_reader :token, :name
def initialize(name)
@name = name
end
def call
response = delete(url, params)
render_status(response)
Gitea::Organization::DeleteService.call(token,name)
end
private
def params
Hash.new.merge(token: token)
end
def url
"/orgs/#{name}".freeze
end
def token
{
username: GiteaService.gitea_config[:access_key_id],

View File

@ -1,14 +1,14 @@
<table class="table table-hover users-list-table">
<thead class="thead-light">
<tr>
<th width="4%">序号</th>
<th width="4%">ID</th>
<th width="5%">序号</th>
<th width="8%" class="text-left">login</th>
<th width="8%" class="text-left">昵称</th>
<th width="10%"><%= 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="12%">项目数</th>
<th width="14%">操作</th>
<th width="10%" class="text-left">昵称</th>
<th width="15%"><%= sort_tag('创建于', name: 'created_on', path: admins_organizations_path) %></th>
<th width="8%" >团队</th>
<th width="8%" >成员</th>
<th width="8%">项目数</th>
<th width="10%">操作</th>
</tr>
</thead>
<tbody>
@ -16,7 +16,6 @@
<% organizations.each_with_index do |org, index| %>
<tr class="org-item-<%= org.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td><%= org.id %></td>
<td class="text-left">
<%= link_to "/#{org.login}", target: '_blank' do %>
<%= overflow_hidden_span org.login, width: 100 %>
@ -24,7 +23,8 @@
</td>
<td><%= org.nickname %> </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 class="action-container">
<%= link_to '查看', admins_organization_path(org), class: 'action' %>