2020-07-01 10:26:07 +00:00
|
|
|
"""passbook Token administration"""
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
from django.urls import reverse_lazy
|
2020-09-11 21:21:11 +00:00
|
|
|
from django.utils.translation import gettext as _
|
2020-07-01 22:13:33 +00:00
|
|
|
from django.views.generic import ListView
|
2020-07-01 10:26:07 +00:00
|
|
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
|
|
|
|
2020-10-03 17:32:01 +00:00
|
|
|
from passbook.admin.views.utils import (
|
|
|
|
DeleteMessageView,
|
|
|
|
SearchListMixin,
|
|
|
|
UserPaginateListMixin,
|
|
|
|
)
|
2020-07-01 10:26:07 +00:00
|
|
|
from passbook.core.models import Token
|
|
|
|
|
|
|
|
|
2020-09-25 23:56:28 +00:00
|
|
|
class TokenListView(
|
2020-10-03 17:32:01 +00:00
|
|
|
LoginRequiredMixin,
|
|
|
|
PermissionListMixin,
|
|
|
|
UserPaginateListMixin,
|
|
|
|
SearchListMixin,
|
|
|
|
ListView,
|
2020-09-25 23:56:28 +00:00
|
|
|
):
|
2020-07-01 10:26:07 +00:00
|
|
|
"""Show list of all tokens"""
|
|
|
|
|
|
|
|
model = Token
|
|
|
|
permission_required = "passbook_core.view_token"
|
|
|
|
ordering = "expires"
|
|
|
|
template_name = "administration/token/list.html"
|
2020-10-03 17:32:01 +00:00
|
|
|
search_fields = [
|
2020-10-05 20:40:30 +00:00
|
|
|
"identifier",
|
2020-10-03 17:32:01 +00:00
|
|
|
"intent",
|
|
|
|
"user__username",
|
|
|
|
"description",
|
|
|
|
]
|
2020-07-01 10:26:07 +00:00
|
|
|
|
|
|
|
|
2020-07-01 22:13:33 +00:00
|
|
|
class TokenDeleteView(LoginRequiredMixin, PermissionRequiredMixin, DeleteMessageView):
|
2020-07-01 10:26:07 +00:00
|
|
|
"""Delete token"""
|
|
|
|
|
|
|
|
model = Token
|
|
|
|
permission_required = "passbook_core.delete_token"
|
|
|
|
|
|
|
|
template_name = "generic/delete.html"
|
|
|
|
success_url = reverse_lazy("passbook_admin:tokens")
|
|
|
|
success_message = _("Successfully deleted Token")
|