fix role manage

This commit is contained in:
undefined committed 2020-04-27 19:07:56 +08:00
1 parent 15d43636c0
commit 42e534615e
34 files changed
+221 -314

No files matched your search

+2 -3
View File
@@ -1,7 +1,6 @@
{% macro render_item(icon_name, page_name, label=none) %}
{% macro render_item(icon_name, page_name, target_url, label=none) %}
<li class="menu__item" id="menu-item-{{ page_name }}">
{% set target_url = reverse_url(page_name, args) %}
<a href="{{ target_url }}" class="menu__link{% if handler.request.path_qs == target_url %} active{% endif %}">
<a href="{{ target_url }}" class="menu__link{% if handler.request.path == target_url %} active{% endif %}">
{% if icon_name %}
<span class="icon icon-{{ icon_name }}"></span>
{% endif %}
+14 -18
View File
@@ -7,10 +7,10 @@
<div class="section__body">
<ul class="supplementary list">
<li>
<a class="discussion-node-tag" href="{{ vj4.handler.discussion.node_url(handler, 'discussion_node', vj4.model.adaptor.discussion.node_id(ddoc)) }}">
{% if ddoc['parent_doc_type'] == vj4.model.document.TYPE_DISCUSSION_NODE %}
<a class="discussion-node-tag" href="/discuss/{{ ddoc.parentType }}/{{ ddoc.parentId }}">
{% if ddoc.parentType == 'node' %}
<span class="v-center icon icon-tag"></span>
{% elif ddoc['parent_doc_type'] == vj4.model.document.TYPE_CONTEST %}
{% elif ddoc.parentType == 'contest' %}
<span class="v-center icon icon-award"></span>
{% else %}
<span class="v-center icon icon-flag"></span>
@@ -19,19 +19,19 @@
</a>
</li>
<li>
{{ user.render_inline(udict[ddoc['owner']]) }}
{{ user.render_inline(udict[ddoc.owner]) }}
@
{{ datetime_span(ddoc['_id'].generationTime) }}
{{ datetime_span(ddoc['_id'].generationTime)|safe }}
</li>
</ul>
<div class="typo topic__content" data-emoji-enabled data-raw-url="{{ reverse_url('discussion_detail_raw', did=ddoc['_id']) }}">
{{ ddoc['content']|markdown }}
<div class="typo topic__content" data-emoji-enabled data-raw-url="/discuss/{{ ddoc._id }}/raw">
{{ ddoc['content']|markdown|safe }}
</div>
</div>
<ul class="section__footer supplementary dot list">
{% if handler.own(ddoc, perm.PERM_EDIT_DISCUSSION_SELF) or handler.hasPerm(perm.PERM_EDIT_DISCUSSION) %}
{% if ddoc.owner == handler.user._id or handler.hasPerm(perm.PERM_EDIT_DISCUSSION) %}
<li>
<a href="{{ reverse_url('discussion_edit', did=ddoc['doc_id']) }}"><span class="icon icon-edit"></span> {{ _('Edit') }}</a>
<a href="/discuss/{{ ddoc._id }}/edit"><span class="icon icon-edit"></span> {{ _('Edit') }}</a>
</li>
{% endif %}
<li>
@@ -48,7 +48,7 @@
</form></li>
{% endif %}
<li>
<a href="{{ reverse_url('about') }}#contact"><span class="icon icon-warning"></span> {{ _('Report') }}</a>
<a href="/wiki/about#contact"><span class="icon icon-warning"></span> {{ _('Report') }}</a>
</li>
</ul>
</div>
@@ -64,15 +64,11 @@
comment_ref = 'drid',
reply_ref = 'drrid',
comment_post_perm = perm.PERM_REPLY_DISCUSSION,
comment_edit_perm = perm.PERM_NONE if handler.own(ddoc, perm.PERM_EDIT_DISCUSSION_REPLY_SELF_DISCUSSION) else perm.PERM_EDIT_DISCUSSION_REPLY,
comment_edit_self_perm = perm.PERM_EDIT_DISCUSSION_REPLY_SELF,
comment_delete_perm = perm.PERM_NONE if handler.own(ddoc, perm.PERM_DELETE_DISCUSSION_REPLY_SELF_DISCUSSION) else perm.PERM_DELETE_DISCUSSION_REPLY,
comment_delete_self_perm = perm.PERM_DELETE_DISCUSSION_REPLY_SELF,
comment_edit_perm = perm.PERM_LOGGEDIN if ddoc.owner == handler.user._id else perm.PERM_EDIT_DISCUSSION_REPLY,
comment_delete_perm = perm.PERM_LOGGEDIN if ddoc.owner == handler.user._id else perm.PERM_DELETE_DISCUSSION_REPLY,
reply_post_perm = perm.PERM_REPLY_DISCUSSION,
reply_edit_perm = perm.PERM_NONE if handler.own(ddoc, perm.PERM_EDIT_DISCUSSION_REPLY_SELF_DISCUSSION) else perm.PERM_EDIT_DISCUSSION_REPLY,
reply_edit_self_perm = perm.PERM_EDIT_DISCUSSION_REPLY_SELF,
reply_delete_perm = perm.PERM_NONE if handler.own(ddoc, perm.PERM_DELETE_DISCUSSION_REPLY_SELF_DISCUSSION) else perm.PERM_DELETE_DISCUSSION_REPLY,
reply_delete_self_perm = perm.PERM_DELETE_DISCUSSION_REPLY_SELF
reply_edit_perm = perm.PERM_LOGGEDIN if ddoc.owner == handler.user._id else perm.PERM_EDIT_DISCUSSION_REPLY,
reply_delete_perm = perm.PERM_LOGGEDIN if ddoc.owner == handler.user._id else perm.PERM_DELETE_DISCUSSION_REPLY,
) }}
{{ paginator.render(page, pcount) }}
{% if drcount == 0 %}
+1 -1
View File
@@ -11,7 +11,7 @@
<button name="operation" value="update" type="submit" class="rounded primary button">
{{ _('Update') }} (Ctrl+Enter)
</button>
{% if handler.own(ddoc, perm.PERM_DELETE_DISCUSSION_SELF) or handler.hasPerm(perm.PERM_DELETE_DISCUSSION) %}
{% if ddoc.owner == handler.user._id or handler.hasPerm(perm.PERM_DELETE_DISCUSSION) %}
<button name="operation" value="delete" type="submit" class="rounded button">
{{ _('Delete') }}
</button>
+8 -9
View File
@@ -7,17 +7,17 @@
</div>
</div>
<div class="medium-3 columns">
{% if vnode['doc_type'] == vj4.model.document.TYPE_PROBLEM %}
{% with pdoc=vnode, owner_udoc=udict[vnode['owner']] %}
{% if vnode.parentType == 'problem' %}
{% set pdoc = vnode %}
{% set owner_udoc = udict[vnode.owner] %}
{% include "partials/problem_sidebar.html" %}
{% endwith %}
{% elif vnode['doc_type'] == vj4.model.document.TYPE_CONTEST %}
{% with tdoc=vnode, owner_udoc=udict[vnode['owner']] %}
{% elif vnode.parentType == 'contest' %}
{% set tdoc = vnode %}
{% set owner_udoc = udict[vnode.owner] %}
{% include "partials/contest_sidebar.html" %}
{% endwith %}
{% elif vnode['doc_type'] == vj4.model.document.TYPE_DISCUSSION_NODE %}
{% elif vnode.parentType == 'node' %}
<div class="section side">
{% if vnode['pic'] %}<div class="discussion-node__bg {{ vnode['pic'] }}"></div>{% endif %}
{% if vnode.pic %}<div class="discussion-node__bg {{ vnode.pic }}"></div>{% endif %}
<div class="section__header">
<h1 class="section__title">{{ vnode['title'] or _('Create Discussion') }}</h1>
</div>
@@ -38,7 +38,6 @@
</div>
</div>
{% endif %}
{% include 'discussion_nodes_widget.html' %}
</div>
</div>
{% endblock %}
-17
View File
@@ -1,17 +0,0 @@
<div class="section side">
<div class="section__header">
<h1 class="section__title">{{ _('Discussion Nodes') }}</h1>
</div>
<div class="section__body"><ul class="group-list">
{% for category, nodes in discussionNodes.items() %}
<li class="group-list__item">
<h2 class="section__title">{{ category }}</h2>
<ol class="chip-list">
{% for node in nodes %}
<li class="chip-list__item"><a class="typo-a" href="{{ reverse_url('discussion_node', doc_id=node['name']) }}">{{ node['name'] }}</a></li>
{% endfor %}
</ol>
</li>
{% endfor %}
</ul></div>
</div>
-26
View File
@@ -1,26 +0,0 @@
{% extends "layout/basic.html" %}
{% block content %}
<div class="domain_join__container">
<div class="row columns">
<div class="section">
<div class="section__header">
<h1 class="section__title">
{{ _('Join {0}').format(handler.domain['name']) }}
</h1>
</div>
<div class="section__body typo">
<p>{{ _('By clicking the button, you will become a member of the domain {0}.').format(handler.domain['name']) }}</p>
</div>
<div class="section__body typo">
<form method="post">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
{% if join_settings['method'] == vj4.constant.domain.JOIN_METHOD_CODE %}
{{ form.form_text(columns=None, label='Invitation Code', name='code', required=true, help_text='You need to enter the invitation code to join the domain.', value=code, autofocus=True) }}
{% endif %}
<button type="submit" class="primary rounded button">{{ _('Join') }}</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
+6 -5
View File
@@ -1,10 +1,11 @@
{% set page_name = "domain_manage_dashboard" %}
{% import "components/user.html" as user %}
{% extends "domain_base.html" %}
{% extends "manage_base.html" %}
{% block domain_content %}
{% if handler.domain['bulletin'] %}
{% if system.bio %}
<div class="section">
<div class="section__body typo">
{{ handler.domain['bulletin']|markdown }}
{{ system.bio|markdown|safe }}
</div>
</div>
{% endif %}
@@ -14,8 +15,8 @@
</div>
<div class="section__body typo">
<dl class="large horizontal">
<dt>{{ _('Gravatar') }}</dt><dd><img src="{{ handler.domain['gravatar']|gravatar_url }}" width="32" height="32"></dd>
<dt>{{ _('Name') }}</dt><dd>{{ handler.domain['name'] }}</dd>
<dt>{{ _('Gravatar') }}</dt><dd><img src="{{ system.gravatar|gravatar_url }}" width="32" height="32"></dd>
<dt>{{ _('Name') }}</dt><dd>{{ system.uname }}</dd>
</dl>
</div>
</div>
-22
View File
@@ -1,22 +0,0 @@
{% extends "domain_base.html" %}
{% block domain_content %}
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Initialize') }}</h1>
<div class="section__tools">
<form method="post">
<div class="row"><div class="columns">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
<button type="submit" class="rounded primary button">
<span class="icon icon-add"></span> {{ _('Initialize') }}
</button>
</div></div>
</form>
</div>
</div>
<div class="section__body">
</div>
</div>
{% include 'discussion_nodes_widget.html' %}
{% endblock %}
+24 -4
View File
@@ -1,11 +1,31 @@
{% extends "domain_base.html" %}
{% set page_name = "domain_manage_edit" %}
{% import "components/form.html" as form with context %}
{% extends "manage_base.html" %}
{% block domain_content %}
<div class="section">
<div class="section__body">
<form method="post">
{% with ddoc=handler.domain %}
{% include "partials/domain_edit_form.html" %}
{% endwith %}
{{ form.form_text({
label:'Name',
name:'uname',
value:system.uname,
autofocus:true,
required:true
}) }}
{{ form.form_text({
label:'Gravatar Email',
help_text:'Will be used as the system icon.',
name:'gravatar',
value:system.gravatar
}) }}
{{ form.form_textarea({
columns:12,
label:'Bulletin',
name:'bio',
value:system.bio,
markdown:true,
required:false
}) }}
<div class="row"><div class="columns">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
<button type="submit" class="rounded primary button">
+1 -1
View File
@@ -1,4 +1,4 @@
{% extends "domain_base.html" %}
{% extends "manage_base.html" %}
{% block domain_content %}
<form method="post">
<div class="section">
+20 -27
View File
@@ -1,4 +1,5 @@
{% extends "domain_base.html" %}
{% set page_name = "domain_manage_role" %}
{% extends "manage_base.html" %}
{% block domain_content %}
<div style="display: none" class="dialog__body--create-role">
<div>
@@ -42,12 +43,26 @@
</label>
</th>
<th class="col--id">{{ _('Role') }}</th>
<th class="col--description">{{ _('Description') }}</th>
<th class="col--users">{{ _('Users') }}</th>
</tr>
</thead>
<tbody>
{% for role, rd in vj4.model.builtin.BUILTIN_ROLE_DESCRIPTORS.items() %}
{% for role in roles %}
{% if role._id not in ['default', 'guest', 'admin'] %}
<tr data-role="{{ role._id }}">
<td class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" data-checkbox-group="role" data-checkbox-range>
</label>
</td>
<td class="col--id">
{{ _('User-defined role') }}: {{ role._id }}
</td>
<td class="col--users">
{{ role.count }}
</td>
</tr>
{% else %}
<tr>
<td class="col--checkbox">
<label class="compact checkbox">
@@ -55,32 +70,10 @@
</label>
</td>
<td class="col--id">
{{ role }}
</td>
<td class="col--description">
{{ _('Built-in') }}: {{ _(rd.description) }}
{{ _('Built-in') }}: {{ role._id }}
</td>
<td class="col--users">
{{ rucounts.get(role, '--') }}
</td>
</tr>
{% endfor %}
{% for role in roles %}
{% if role not in vj4.model.builtin.BUILTIN_ROLE_DESCRIPTORS %}
<tr data-role="{{ role }}">
<td class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" data-checkbox-group="role" data-checkbox-range>
</label>
</td>
<td class="col--id">
{{ role }}
</td>
<td class="col--description">
{{ _('User-defined role') }}
</td>
<td class="col--users">
{{ rucounts[role] }}
{{ role.count|default('--') }}
</td>
</tr>
{% endif %}
+1 -1
View File
@@ -1,4 +1,4 @@
{% extends "domain_base.html" %}
{% extends "manage_base.html" %}
{% block domain_content %}
<div style="display: none" class="dialog__body--add-user">
<div>
-36
View File
@@ -1,36 +0,0 @@
{% extends "layout/home_base.html" %}
{% block home_content %}
<div data-heading-extract-to="#menu-item-home_domain">
<div class="section">
<div class="section__header">
<h1 class="section__title" id="create" data-heading>{{ _('Create Domain') }}</h1>
</div>
<div class="section__body">
<blockquote class="note typo">
<p>{{ _('A domain ID cannot be changed after creation. It is supposed to be:') }}</p>
<ul>
<li>{{ _('Unique') }}</li>
<li>{{ _('At least 4 characters') }}</li>
<li>{{ _('Not wrapped with space') }}</li>
<li>{{ _('Not started with a number') }}</li>
<li>{{ _('Only A-Z, a-z, 0-9 and _ are accepted') }}</li>
</ul>
</blockquote>
<form method="post">
{% with ddoc={} %}
{% include "partials/domain_edit_form.html" %}
{% endwith %}
<div class="row"><div class="columns">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
<button type="submit" class="rounded primary button">
{{ _('Create') }}
</button>
<button type="button" class="rounded button" onclick="window.history.go(-1)">
{{ _('Cancel') }}
</button>
</div></div>
</form>
</div>
</div>
</div>
{% endblock %}
-1
View File
@@ -37,7 +37,6 @@
<!--[if lte IE 8]>
<script type="text/javascript" src="{{ static_url('shim.js') }}"></script>
<![endif]-->
<script type="text/javascript" src="{{ static_url('manifest.js') }}"></script>
<script type="text/javascript" src="{{ static_url('locale/{0}.js'.format(handler.user.lang)) }}"></script>
<script type="text/javascript" src="{{ static_url('vj4.js') }}"></script>
</body>
@@ -12,27 +12,20 @@
<span class="icon icon-info"></span> {{ _('Properties') }}
</div>
<ol class="menu collapsed">
{{ sidemenu.render_item(null, 'domain_manage_dashboard') }}
{% if handler.hasPerm(perm.PERM_EDIT_DESCRIPTION) %}
{{ sidemenu.render_item(null, 'domain_manage_edit') }}
{{ sidemenu.render_item(null, 'domain_manage_join_applications') }}
{{ sidemenu.render_item(null, 'domain_manage_discussion') }}
{% endif %}
<!-- Ranking Settings -->
{{ sidemenu.render_item(null, 'domain_manage_dashboard', '/manage/dashboard') }}
{{ sidemenu.render_item(null, 'domain_manage_edit', '/manage/edit') }}
</ol>
</li>
{% if handler.hasPerm(perm.PERM_EDIT_PERM) %}
<li class="menu__item">
<div class="menu__link expandable">
<span class="icon icon-user"></span> {{ _('Access Control') }}
</div>
<ol class="menu collapsed">
{{ sidemenu.render_item(null, 'domain_manage_role') }}
{{ sidemenu.render_item(null, 'domain_manage_user') }}
{{ sidemenu.render_item(null, 'domain_manage_permission') }}
{{ sidemenu.render_item(null, 'domain_manage_role', '/manage/role') }}
{{ sidemenu.render_item(null, 'domain_manage_user', '/manage/user') }}
{{ sidemenu.render_item(null, 'domain_manage_permission', '/manage/permission') }}
</ol>
</li>
{% endif %}
</ol>
</div>
</div></div>
+1 -9
View File
@@ -1,9 +1 @@
{% import "components/form.html" as form with context %}
{% if page_name == 'domain_manage_edit' %}
{{ form.form_text(label='ID', name='id', value=ddoc['_id'], disabled=true) }}
{% elif page_name == 'home_domain_create' %}
{{ form.form_text(label='ID', name='id', autofocus=true, required=true) }}
{% endif %}
{{ form.form_text(label='Name', name='name', value=ddoc['name']|default(''), autofocus=(page_name == 'domain_manage_edit'), required=true) }}
{{ form.form_text(label='Gravatar Email', help_text='Will be used as the domain icon.', name='gravatar', value=ddoc['gravatar']|default('')) }}
{{ form.form_textarea(columns=12, label='Bulletin', name='bulletin', value=ddoc['bulletin']|default(''), markdown=true, required=false) }}
+2 -2
View File
@@ -18,13 +18,13 @@
{{ nav_item('/t', 'training_main', 'training') }}
{% endif %}
{% if handler.hasPerm(perm.PERM_VIEW_DISCUSSION) %}
{{ nav_item('/d', 'discussion_main', 'discussion') }}
{{ nav_item('/discuss', 'discussion_main', 'discussion') }}
{% endif %}
{% if handler.hasPerm(perm.PERM_VIEW_CONTEST) %}
{{ nav_item('/c', 'contest_main', 'contest') }}
{% endif %}
{% if handler.hasPerm(perm.PERM_EDIT_DESCRIPTION) or handler.hasPerm(perm.PERM_EDIT_PERM) %}
{{ nav_item('/d', 'domain_manage', 'domain_manage') }}
{{ nav_item('/manage', 'domain_manage', 'domain_manage') }}
{% endif %}
</ol>
<ol class="nav__list nav__list--secondary clearfix">