add permission string filter
This commit is contained in:
parent
4f18694de3
commit
7ef0b9dc7d
@ -4,7 +4,7 @@ from .models import Avatars, Users
|
|||||||
from .auth import digest
|
from .auth import digest
|
||||||
from .routes.users import is_logged_in, get_active_user
|
from .routes.users import is_logged_in, get_active_user
|
||||||
from .constants import (
|
from .constants import (
|
||||||
PermissionLevel,
|
PermissionLevel, permission_level_string,
|
||||||
InfoboxKind, InfoboxIcons, InfoboxHTMLClass
|
InfoboxKind, InfoboxIcons, InfoboxHTMLClass
|
||||||
)
|
)
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -120,4 +120,8 @@ def create_app():
|
|||||||
|
|
||||||
return plural
|
return plural
|
||||||
|
|
||||||
|
@app.template_filter("permission_string")
|
||||||
|
def permission_string(term):
|
||||||
|
return permission_level_string(term)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
@ -7,6 +7,17 @@ class PermissionLevel(Enum):
|
|||||||
SYSTEM = 3
|
SYSTEM = 3
|
||||||
ADMIN = 4
|
ADMIN = 4
|
||||||
|
|
||||||
|
PermissionLevelString = {
|
||||||
|
PermissionLevel.GUEST: 'Guest',
|
||||||
|
PermissionLevel.USER: 'User',
|
||||||
|
PermissionLevel.MODERATOR: 'Moderator',
|
||||||
|
PermissionLevel.SYSTEM: 'System',
|
||||||
|
PermissionLevel.ADMIN: 'Administrator',
|
||||||
|
}
|
||||||
|
|
||||||
|
def permission_level_string(perm):
|
||||||
|
return PermissionLevelString[PermissionLevel(int(perm))]
|
||||||
|
|
||||||
class InfoboxKind(IntEnum):
|
class InfoboxKind(IntEnum):
|
||||||
INFO = 0
|
INFO = 0
|
||||||
LOCK = 1
|
LOCK = 1
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
<div class="user-page-stats">
|
<div class="user-page-stats">
|
||||||
{% with stats = target_user.get_post_stats() %}
|
{% with stats = target_user.get_post_stats() %}
|
||||||
<ul class="user-stats-list">
|
<ul class="user-stats-list">
|
||||||
<li>Permission: {{ target_user.permission }}</li>
|
<li>Permission: {{ target_user.permission | permission_string }}</li>
|
||||||
<li>Posts created: {{ stats.post_count }}</li>
|
<li>Posts created: {{ stats.post_count }}</li>
|
||||||
<li>Threads started: {{ stats.thread_count }}</li>
|
<li>Threads started: {{ stats.thread_count }}</li>
|
||||||
{% if stats.latest_thread_title %}
|
{% if stats.latest_thread_title %}
|
||||||
|
Loading…
Reference in New Issue
Block a user