summaryrefslogtreecommitdiffstats
path: root/users/views/admin/__init__.py
blob: 5ace04d79c9a188d91eabedb3b29b208ce90d852 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from django import forms
from django.utils.decorators import method_decorator
from django.views.generic import FormView, RedirectView, TemplateView

from users.decorators import admin_required
from users.models import Identity
from users.views.admin.domains import (  # noqa
    DomainCreate,
    DomainDelete,
    DomainEdit,
    Domains,
)
from users.views.admin.federation import FederationEdit, FederationRoot  # noqa
from users.views.admin.hashtags import (  # noqa
    HashtagCreate,
    HashtagDelete,
    HashtagEdit,
    Hashtags,
)
from users.views.admin.settings import (  # noqa
    BasicSettings,
    PoliciesSettings,
    TuningSettings,
)
from users.views.admin.stator import Stator  # noqa
from users.views.admin.users import UserEdit, UsersRoot  # noqa


@method_decorator(admin_required, name="dispatch")
class AdminRoot(RedirectView):
    pattern_name = "admin_basic"


@method_decorator(admin_required, name="dispatch")
class Identities(TemplateView):

    template_name = "admin/identities.html"

    def get_context_data(self):
        return {
            "identities": Identity.objects.order_by("username"),
            "section": "identities",
        }


@method_decorator(admin_required, name="dispatch")
class Invites(FormView):

    template_name = "admin/invites.html"
    extra_context = {"section": "invites"}

    class form_class(forms.Form):
        note = forms.CharField()

    def get_context_data(self, *args, **kwargs):
        context = super().get_context_data(*args, **kwargs)
        return context