2019-11-12 11:07:34 +00:00
|
|
|
from flask_table import Table, Col, LinkCol
|
2019-07-10 12:36:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AdminUserTable(Table):
|
|
|
|
"""
|
|
|
|
Declares the table describing colum by column.
|
|
|
|
"""
|
|
|
|
classes = ['highlight', 'responsive-table']
|
2019-09-09 13:02:17 +00:00
|
|
|
username = Col('Username', column_html_attrs={'class': 'username'},
|
|
|
|
th_html_attrs={'class': 'sort',
|
|
|
|
'data-sort': 'username'})
|
|
|
|
email = Col('Email', column_html_attrs={'class': 'email'},
|
|
|
|
th_html_attrs={'class': 'sort',
|
|
|
|
'data-sort': 'email'})
|
|
|
|
role_id = Col('Role', column_html_attrs={'class': 'role'},
|
|
|
|
th_html_attrs={'class': 'sort',
|
|
|
|
'data-sort': 'role'})
|
|
|
|
confirmed = Col('Confrimed Status', column_html_attrs={'class': 'confirmed'},
|
|
|
|
th_html_attrs={'class': 'sort',
|
|
|
|
'data-sort': 'confirmed'})
|
|
|
|
id = Col('User Id', column_html_attrs={'class': 'id'},
|
|
|
|
th_html_attrs={'class': 'sort',
|
|
|
|
'data-sort': 'id'})
|
2019-08-15 13:56:53 +00:00
|
|
|
url = LinkCol('Profile', 'admin.admin_user_page',
|
2019-09-09 13:02:17 +00:00
|
|
|
url_kwargs=dict(user_id='id'),
|
|
|
|
anchor_attrs={'class': 'waves-effect waves-light btn-small'})
|
2019-07-10 12:36:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AdminUserItem(object):
|
|
|
|
"""
|
|
|
|
Describes one item like one row per table.
|
|
|
|
"""
|
|
|
|
|
2019-08-15 13:56:53 +00:00
|
|
|
def __init__(self, username, email, role_id, confirmed, id):
|
2019-07-10 12:36:31 +00:00
|
|
|
self.username = username
|
|
|
|
self.email = email
|
|
|
|
self.role_id = role_id
|
|
|
|
self.confirmed = confirmed
|
2019-08-15 13:56:53 +00:00
|
|
|
self.id = id
|
2019-07-10 12:36:31 +00:00
|
|
|
|
|
|
|
if self.role_id == 1:
|
|
|
|
self.role_id = 'User'
|
|
|
|
elif self.role_id == 2:
|
|
|
|
self.role_id = 'Admin'
|