Merge pull request #446 from ngoduykhanh/fix_account

Fix account deletion. Add more info in Account table #433
This commit is contained in:
Khanh Ngo 2019-01-23 09:23:07 +07:00 committed by GitHub
commit 829d556462
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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':