Add permissions to the page

This commit is contained in:
2021-02-14 22:28:34 +01:00
parent 72be8e693a
commit 0553aaa935
14 changed files with 671 additions and 297 deletions
+5 -5
View File
@@ -11,13 +11,13 @@
<div class="admin">
<nav>
<ol>
<li><a href="/admin/index/">Liste</a></li>
<li><a href="/admin/submit/">Hinzufügen</a></li>
<li><a href="/admin/signup/">Einladen</a></li>
<li><a href="/admin/view/users/">Benutzer</a></li>
<li><a href="/admin/index/">Link Liste</a></li>
<li><a href="/admin/submit/">Link Hinzufügen</a></li>
{% if user.role == 2 %}<li><a href="/admin/signup/">Einladen</a></li>
<li><a href="/admin/view/users/">Benutzer</a></li>{% endif %}
<li style="float:right"><a href="/admin/logout/">Abmelden</a></li>
<li style="float:right">
<div class="willkommen">Herzlich willkommen {{ name }}</div>
<div class="willkommen">Herzlich willkommen {{ user.username }}</div>
</li>
</ol>
</nav>
+7 -4
View File
@@ -24,9 +24,9 @@
</th>
</tr>
{% for links_user in links_per_users %}
{% set l = links_user[0] %}
{% set u = links_user[1] %}
{% set c = links_user[2] %}
{% set l = links_user.link %}
{% set u = links_user.user %}
{% set c = links_user.clicks %}
<tr>
<td>
<a href="/admin/view/link/{{l.code}}"><span>{{l.code}}</span>
@@ -37,9 +37,12 @@
</a>
</td>
<td>
{% if user.role == 2 or user.id == u.id %}
<a href="/admin/view/profile/{{u.id}}"><small>{{ u.username }}</small>
</a>
{% else %}
<small>{{ u.username }}</small>
{% endif %}
</td>
<td>
{{ c.count }}
+4 -1
View File
@@ -14,7 +14,8 @@
</tr>
<tr>
<td>Kurzlink:</td>
<td><a href="https://fhs.li/{{ link.code }}">https://fhs.li/{{ link.code }}</a></td>
<td><a href="{{ protocol }}://{{ host }}/{{ link.code }}">{{ protocol }}://{{ host }}/{{ link.code }}</a>
</td>
</tr>
<tr>
<td>Ziel:</td>
@@ -30,8 +31,10 @@
</td>
</tr>
</table>
{% if user.role == 2 or user.id == link.author %}
<div class="actions">
<a class="button" href="/admin/edit/link/{{ link.code }}">Editieren</a>
</div>
{% endif %}
</div>
{% endblock %}
+14 -4
View File
@@ -2,24 +2,34 @@
{% block admin %}
<div class="center">
<h1>Profil von {{user.username}}</h1>
<h1>Profil von {{viewed_user.username}}</h1>
<form action="" method="POST">
<div>
<label for="username">Benutzername:</label>
<input type="text" name="username" value="{{ user.username }}" readonly>
<input type="text" name="username" value="{{ viewed_user.username }}" readonly>
</div>
<div>
<label for="email">E-mail:</label>
<input type="email" name="email" value="{{ user.email }}" readonly>
<input type="email" name="email" value="{{ viewed_user.email }}" readonly>
</div>
{% if user.role == 2 or user.id == viewed_user.id %}
<div>
<label for="password">Passwort:</label>
<input type="password" name="password" value="verschlüsselt" readonly>
</div>
{% endif %}
</form>
{% if user.role == 2 or user.id == viewed_user.id %}
<div class="actions">
<a class="button" href="/admin/edit/profile/{{ user.id }}">Editieren</a>
<a class="button" href="/admin/edit/profile/{{ viewed_user.id }}">Editieren</a>
{% if user.role == 2 and viewed_user.role == 1 %}
<a class="button" href="/admin/edit/set_admin/{{ viewed_user.id }}">Zum Admin machen</a>
{% endif %}
{% if user.role == 2 and viewed_user.role == 2 %}
<a class="button" href="/admin/edit/set_admin/{{ viewed_user.id }}">Zum Normalo machen</a>
{% endif %}
</div>
{% endif %}
<h2>&nbsp;</h2>
</div>
{% endblock %}