mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-22 15:21:01 +00:00
Add moderation/admin separation
This commit is contained in:
parent
0c4eb74165
commit
39013e0bb5
8 changed files with 53 additions and 38 deletions
|
@ -93,14 +93,12 @@ td a {
|
||||||
--color-text-dull: #99a;
|
--color-text-dull: #99a;
|
||||||
--color-text-main: #fff;
|
--color-text-main: #fff;
|
||||||
--color-text-link: rgb(176, 194, 206);
|
--color-text-link: rgb(176, 194, 206);
|
||||||
--color-text-error: #f44336;
|
|
||||||
|
|
||||||
--color-input-border: #000;
|
--color-input-border: #000;
|
||||||
--color-input-border-active: #444b5d;
|
--color-input-border-active: #444b5d;
|
||||||
--color-button-main: #444b5d;
|
--color-button-main: #444b5d;
|
||||||
--color-button-main-hover: #515d7c;
|
--color-button-main-hover: #515d7c;
|
||||||
--color-button-disabled: #7c9c97;
|
--color-button-disabled: #7c9c97;
|
||||||
--color-bg3: #444b5d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
@ -281,6 +279,14 @@ nav a.selected:hover {
|
||||||
border-left: 3px solid transparent;
|
border-left: 3px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav a.danger {
|
||||||
|
color: var(--color-text-duller);
|
||||||
|
}
|
||||||
|
|
||||||
|
nav a.danger:hover {
|
||||||
|
color: var(--color-text-dull);
|
||||||
|
}
|
||||||
|
|
||||||
nav a i {
|
nav a i {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
|
@ -13,23 +13,8 @@
|
||||||
<a href="/auth/logout/">
|
<a href="/auth/logout/">
|
||||||
<i class="fa-solid fa-right-from-bracket" title="Logout"></i> Logout
|
<i class="fa-solid fa-right-from-bracket" title="Logout"></i> Logout
|
||||||
</a>
|
</a>
|
||||||
{% if request.user.admin %}
|
{% if request.user.moderator or request.user.admin %}
|
||||||
<h3>Administration</h3>
|
<h3>Moderation</h3>
|
||||||
<a href="{% url "admin_basic" %}" {% if section == "basic" %}class="selected"{% endif %} title="Basic">
|
|
||||||
<i class="fa-solid fa-book"></i> Basic
|
|
||||||
</a>
|
|
||||||
<a href="{% url "admin_policies" %}" {% if section == "policies" %}class="selected"{% endif %} title="Policies">
|
|
||||||
<i class="fa-solid fa-file-lines"></i> Policies
|
|
||||||
</a>
|
|
||||||
<a href="{% url "admin_domains" %}" {% if section == "domains" %}class="selected"{% endif %} title="Domains">
|
|
||||||
<i class="fa-solid fa-globe"></i> Domains
|
|
||||||
</a>
|
|
||||||
<a href="{% url "admin_federation" %}" {% if section == "federation" %}class="selected"{% endif %} title="Federation">
|
|
||||||
<i class="fa-solid fa-diagram-project"></i> Federation
|
|
||||||
</a>
|
|
||||||
<a href="{% url "admin_users" %}" {% if section == "users" %}class="selected"{% endif %} title="Users">
|
|
||||||
<i class="fa-solid fa-users"></i> Users
|
|
||||||
</a>
|
|
||||||
<a href="{% url "admin_identities" %}" {% if section == "identities" %}class="selected"{% endif %} title="Identities">
|
<a href="{% url "admin_identities" %}" {% if section == "identities" %}class="selected"{% endif %} title="Identities">
|
||||||
<i class="fa-solid fa-id-card"></i> Identities
|
<i class="fa-solid fa-id-card"></i> Identities
|
||||||
</a>
|
</a>
|
||||||
|
@ -42,10 +27,28 @@
|
||||||
<a href="{% url "admin_reports" %}" {% if section == "reports" %}class="selected"{% endif %} title="Reports">
|
<a href="{% url "admin_reports" %}" {% if section == "reports" %}class="selected"{% endif %} title="Reports">
|
||||||
<i class="fa-solid fa-flag"></i> Reports
|
<i class="fa-solid fa-flag"></i> Reports
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{% url "admin_federation" %}" {% if section == "federation" %}class="selected"{% endif %} title="Federation">
|
||||||
|
<i class="fa-solid fa-diagram-project"></i> Federation
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if request.user.admin %}
|
||||||
|
<h3>Administration</h3>
|
||||||
|
<a href="{% url "admin_basic" %}" {% if section == "basic" %}class="selected"{% endif %} title="Basic">
|
||||||
|
<i class="fa-solid fa-book"></i> Basic
|
||||||
|
</a>
|
||||||
|
<a href="{% url "admin_policies" %}" {% if section == "policies" %}class="selected"{% endif %} title="Policies">
|
||||||
|
<i class="fa-solid fa-file-lines"></i> Policies
|
||||||
|
</a>
|
||||||
|
<a href="{% url "admin_domains" %}" {% if section == "domains" %}class="selected"{% endif %} title="Domains">
|
||||||
|
<i class="fa-solid fa-globe"></i> Domains
|
||||||
|
</a>
|
||||||
|
<a href="{% url "admin_users" %}" {% if section == "users" %}class="selected"{% endif %} title="Users">
|
||||||
|
<i class="fa-solid fa-users"></i> Users
|
||||||
|
</a>
|
||||||
<a href="{% url "admin_stator" %}" {% if section == "stator" %}class="selected"{% endif %} title="Stator">
|
<a href="{% url "admin_stator" %}" {% if section == "stator" %}class="selected"{% endif %} title="Stator">
|
||||||
<i class="fa-solid fa-clock-rotate-left"></i> Stator
|
<i class="fa-solid fa-clock-rotate-left"></i> Stator
|
||||||
</a>
|
</a>
|
||||||
<a href="/djadmin" title="">
|
<a href="/djadmin" title="Django Admin" class="danger">
|
||||||
<i class="fa-solid fa-gear"></i> Django Admin
|
<i class="fa-solid fa-gear"></i> Django Admin
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -29,5 +29,11 @@ def identity_required(function):
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
|
def moderator_required(function):
|
||||||
|
return user_passes_test(
|
||||||
|
lambda user: user.is_authenticated and (user.admin or user.moderator)
|
||||||
|
)(function)
|
||||||
|
|
||||||
|
|
||||||
def admin_required(function):
|
def admin_required(function):
|
||||||
return user_passes_test(lambda user: user.is_authenticated and user.admin)(function)
|
return user_passes_test(lambda user: user.is_authenticated and user.admin)(function)
|
||||||
|
|
|
@ -4,11 +4,11 @@ from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.generic import FormView, ListView
|
from django.views.generic import FormView, ListView
|
||||||
|
|
||||||
from users.decorators import admin_required
|
from users.decorators import moderator_required
|
||||||
from users.models import Domain
|
from users.models import Domain
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class FederationRoot(ListView):
|
class FederationRoot(ListView):
|
||||||
|
|
||||||
template_name = "admin/federation.html"
|
template_name = "admin/federation.html"
|
||||||
|
@ -33,7 +33,7 @@ class FederationRoot(ListView):
|
||||||
return domains
|
return domains
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class FederationEdit(FormView):
|
class FederationEdit(FormView):
|
||||||
|
|
||||||
template_name = "admin/federation_edit.html"
|
template_name = "admin/federation_edit.html"
|
||||||
|
|
|
@ -4,10 +4,10 @@ from django.utils.decorators import method_decorator
|
||||||
from django.views.generic import FormView, TemplateView
|
from django.views.generic import FormView, TemplateView
|
||||||
|
|
||||||
from activities.models import Hashtag, HashtagStates
|
from activities.models import Hashtag, HashtagStates
|
||||||
from users.decorators import admin_required
|
from users.decorators import moderator_required
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class Hashtags(TemplateView):
|
class Hashtags(TemplateView):
|
||||||
|
|
||||||
template_name = "admin/hashtags.html"
|
template_name = "admin/hashtags.html"
|
||||||
|
@ -19,7 +19,7 @@ class Hashtags(TemplateView):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class HashtagCreate(FormView):
|
class HashtagCreate(FormView):
|
||||||
|
|
||||||
template_name = "admin/hashtag_create.html"
|
template_name = "admin/hashtag_create.html"
|
||||||
|
@ -68,7 +68,7 @@ class HashtagCreate(FormView):
|
||||||
return redirect(Hashtag.urls.root)
|
return redirect(Hashtag.urls.root)
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class HashtagEdit(FormView):
|
class HashtagEdit(FormView):
|
||||||
|
|
||||||
template_name = "admin/hashtag_edit.html"
|
template_name = "admin/hashtag_edit.html"
|
||||||
|
@ -106,7 +106,7 @@ class HashtagEdit(FormView):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class HashtagDelete(TemplateView):
|
class HashtagDelete(TemplateView):
|
||||||
|
|
||||||
template_name = "admin/hashtag_delete.html"
|
template_name = "admin/hashtag_delete.html"
|
||||||
|
|
|
@ -4,11 +4,11 @@ from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.generic import FormView, ListView
|
from django.views.generic import FormView, ListView
|
||||||
|
|
||||||
from users.decorators import admin_required
|
from users.decorators import moderator_required
|
||||||
from users.models import Identity, IdentityStates
|
from users.models import Identity, IdentityStates
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class IdentitiesRoot(ListView):
|
class IdentitiesRoot(ListView):
|
||||||
|
|
||||||
template_name = "admin/identities.html"
|
template_name = "admin/identities.html"
|
||||||
|
@ -46,7 +46,7 @@ class IdentitiesRoot(ListView):
|
||||||
return identities
|
return identities
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class IdentityEdit(FormView):
|
class IdentityEdit(FormView):
|
||||||
|
|
||||||
template_name = "admin/identity_edit.html"
|
template_name = "admin/identity_edit.html"
|
||||||
|
|
|
@ -3,11 +3,11 @@ from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.generic import FormView, ListView
|
from django.views.generic import FormView, ListView
|
||||||
|
|
||||||
from users.decorators import admin_required
|
from users.decorators import moderator_required
|
||||||
from users.models import Invite
|
from users.models import Invite
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class InvitesRoot(ListView):
|
class InvitesRoot(ListView):
|
||||||
|
|
||||||
template_name = "admin/invites.html"
|
template_name = "admin/invites.html"
|
||||||
|
@ -23,7 +23,7 @@ class InvitesRoot(ListView):
|
||||||
return Invite.objects.order_by("created")
|
return Invite.objects.order_by("created")
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class InviteCreate(FormView):
|
class InviteCreate(FormView):
|
||||||
|
|
||||||
template_name = "admin/invite_create.html"
|
template_name = "admin/invite_create.html"
|
||||||
|
@ -47,7 +47,7 @@ class InviteCreate(FormView):
|
||||||
return redirect(invite.urls.admin)
|
return redirect(invite.urls.admin)
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class InviteView(FormView):
|
class InviteView(FormView):
|
||||||
|
|
||||||
template_name = "admin/invite_view.html"
|
template_name = "admin/invite_view.html"
|
||||||
|
|
|
@ -4,11 +4,11 @@ from django.utils import timezone
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.generic import FormView, ListView
|
from django.views.generic import FormView, ListView
|
||||||
|
|
||||||
from users.decorators import admin_required
|
from users.decorators import moderator_required
|
||||||
from users.models import Identity, Report
|
from users.models import Identity, Report
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class ReportsRoot(ListView):
|
class ReportsRoot(ListView):
|
||||||
|
|
||||||
template_name = "admin/reports.html"
|
template_name = "admin/reports.html"
|
||||||
|
@ -32,7 +32,7 @@ class ReportsRoot(ListView):
|
||||||
return reports
|
return reports
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(admin_required, name="dispatch")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
class ReportView(FormView):
|
class ReportView(FormView):
|
||||||
|
|
||||||
template_name = "admin/report_view.html"
|
template_name = "admin/report_view.html"
|
||||||
|
|
Loading…
Reference in a new issue