Fix account deletion. Add more info in Account table

This commit is contained in:
Khanh Ngo 2019-01-11 09:00:51 +07:00
parent 7da6bd5f99
commit 458826bc77
No known key found for this signature in database
GPG key ID: B9AE3BAF6D5A7B22
3 changed files with 9 additions and 2 deletions

View file

@ -558,7 +558,7 @@ class Account(db.Model):
"""
account = Account.query.filter(Account.name == self.name).first()
for domain in account.domains:
domain.assoc_account(None)
Domain(name=domain.name).assoc_account(None)
def create_account(self):
"""
@ -664,6 +664,7 @@ class Account(db.Model):
users.append(User(id=uid).get_user_info_by_id().username)
self.grant_privileges(users)
def add_user(self, user):
"""
Add a single user to Account by User

View file

@ -36,6 +36,8 @@
<th>Description</th>
<th>Contact</th>
<th>Mail</th>
<th>Member</th>
<th>Domain</th>
<th>Action</th>
</tr>
</thead>
@ -46,6 +48,8 @@
<td>{{ account.description }}</td>
<td>{{ account.contact }}</td>
<td>{{ account.mail }}</td>
<td>{{ account.user_num }}</td>
<td>{{ account.domains|length }}</td>
<td width="15%">
<button type="button" class="btn btn-flat btn-success" onclick="window.location.href='{{ url_for('admin_editaccount', account_name=account.name) }}'">
Edit&nbsp;<i class="fa fa-cog"></i>

View file

@ -17,7 +17,7 @@ from flask import g, request, make_response, jsonify, render_template, session,
from flask_login import login_user, logout_user, current_user, login_required
from werkzeug import secure_filename
from .models import User, Account, Domain, Record, Role, Server, History, Anonymous, Setting, DomainSetting, DomainTemplate, DomainTemplateRecord
from .models import User, Account, AccountUser, Domain, Record, Role, Server, History, Anonymous, Setting, DomainSetting, DomainTemplate, DomainTemplateRecord
from app import app, login_manager, csrf
from app.lib import utils
from app.oauth import github_oauth, google_oauth, oidc_oauth
@ -1344,6 +1344,8 @@ def admin_editaccount(account_name=None):
def admin_manageaccount():
if request.method == 'GET':
accounts = Account.query.order_by(Account.name).all()
for account in accounts:
account.user_num = AccountUser.query.filter(AccountUser.account_id==account.id).count()
return render_template('admin_manageaccount.html', accounts=accounts)
if request.method == 'POST':