admin: add invite administration
This commit is contained in:
parent
64c8458c90
commit
89c2b8d49c
|
@ -20,6 +20,9 @@
|
||||||
<li class="{% is_active 'passbook_admin:rules' 'passbook_admin:rule-create' 'passbook_admin:rule-update' 'passbook_admin:rule-delete' 'passbook_admin:rule-test' %}">
|
<li class="{% is_active 'passbook_admin:rules' 'passbook_admin:rule-create' 'passbook_admin:rule-update' 'passbook_admin:rule-delete' 'passbook_admin:rule-test' %}">
|
||||||
<a href="{% url 'passbook_admin:rules' %}">{% trans 'Rules' %}</a>
|
<a href="{% url 'passbook_admin:rules' %}">{% trans 'Rules' %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="{% is_active 'passbook_admin:invites' 'passbook_admin:invite-create' 'passbook_admin:invite-update' 'passbook_admin:invite-delete' 'passbook_admin:invite-test' %}">
|
||||||
|
<a href="{% url 'passbook_admin:invites' %}">{% trans 'Invites' %}</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#">{% trans 'Users' %}</a>
|
<a href="#">{% trans 'Users' %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
39
passbook/admin/templates/administration/invite/list.html
Normal file
39
passbook/admin/templates/administration/invite/list.html
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{% extends "administration/base.html" %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
{% load utils %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% title %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
<h1>{% trans "Invites" %}</h1>
|
||||||
|
<a href="{% url 'passbook_admin:invite-create' %}" class="btn btn-primary">
|
||||||
|
{% trans 'Create...' %}
|
||||||
|
</a>
|
||||||
|
<hr>
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{% trans 'Name' %}</th>
|
||||||
|
<th>{% trans 'Provider' %}</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for invite in object_list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ invite.name }}</td>
|
||||||
|
<td>{{ invite.provider }}</td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-default btn-sm" href="{% url 'passbook_admin:invite-update' pk=invite.uuid %}?back={{ request.get_full_path }}">{% trans 'Edit' %}</a>
|
||||||
|
<a class="btn btn-default btn-sm" href="{% url 'passbook_admin:invite-delete' pk=invite.uuid %}?back={{ request.get_full_path }}">{% trans 'Delete' %}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -1,8 +1,8 @@
|
||||||
"""passbook URL Configuration"""
|
"""passbook URL Configuration"""
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from passbook.admin.views import (applications, overview, providers, rules,
|
from passbook.admin.views import (applications, invites, overview, providers,
|
||||||
sources)
|
rules, sources)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', overview.AdministrationOverviewView.as_view(), name='overview'),
|
path('', overview.AdministrationOverviewView.as_view(), name='overview'),
|
||||||
|
@ -34,5 +34,10 @@ urlpatterns = [
|
||||||
providers.ProviderUpdateView.as_view(), name='provider-update'),
|
providers.ProviderUpdateView.as_view(), name='provider-update'),
|
||||||
path('providers/<int:pk>/delete/',
|
path('providers/<int:pk>/delete/',
|
||||||
providers.ProviderDeleteView.as_view(), name='provider-delete'),
|
providers.ProviderDeleteView.as_view(), name='provider-delete'),
|
||||||
|
# Invites
|
||||||
|
path('invites/', invites.InviteListView.as_view(), name='invites'),
|
||||||
|
path('invites/create/', invites.InviteCreateView.as_view(), name='invite-create'),
|
||||||
|
path('invites/<uuid:pk>/update/', invites.InviteUpdateView.as_view(), name='invite-update'),
|
||||||
|
path('invites/<uuid:pk>/delete/', invites.InviteDeleteView.as_view(), name='invite-delete'),
|
||||||
# path('api/v1/', include('passbook.admin.api.v1.urls'))
|
# path('api/v1/', include('passbook.admin.api.v1.urls'))
|
||||||
]
|
]
|
||||||
|
|
43
passbook/admin/views/invites.py
Normal file
43
passbook/admin/views/invites.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
"""passbook Invite administration"""
|
||||||
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
|
||||||
|
|
||||||
|
from passbook.admin.mixins import AdminRequiredMixin
|
||||||
|
from passbook.core.forms.invites import InviteForm
|
||||||
|
from passbook.core.models import Invite
|
||||||
|
|
||||||
|
|
||||||
|
class InviteListView(AdminRequiredMixin, ListView):
|
||||||
|
"""Show list of all invites"""
|
||||||
|
|
||||||
|
model = Invite
|
||||||
|
template_name = 'administration/invite/list.html'
|
||||||
|
|
||||||
|
|
||||||
|
class InviteCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
|
||||||
|
"""Create new Invite"""
|
||||||
|
|
||||||
|
template_name = 'generic/create.html'
|
||||||
|
success_url = reverse_lazy('passbook_admin:invites')
|
||||||
|
success_message = _('Successfully created Invite')
|
||||||
|
form_class = InviteForm
|
||||||
|
|
||||||
|
|
||||||
|
class InviteUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView):
|
||||||
|
"""Update invite"""
|
||||||
|
|
||||||
|
model = Invite
|
||||||
|
template_name = 'generic/update.html'
|
||||||
|
success_url = reverse_lazy('passbook_admin:invites')
|
||||||
|
success_message = _('Successfully updated Invite')
|
||||||
|
form_class = InviteForm
|
||||||
|
|
||||||
|
class InviteDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView):
|
||||||
|
"""Delete invite"""
|
||||||
|
|
||||||
|
model = Invite
|
||||||
|
template_name = 'generic/delete.html'
|
||||||
|
success_url = reverse_lazy('passbook_admin:invites')
|
||||||
|
success_message = _('Successfully updated Invite')
|
14
passbook/core/forms/invites.py
Normal file
14
passbook/core/forms/invites.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
"""passbook core invite form"""
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
from passbook.core.models import Invite
|
||||||
|
|
||||||
|
|
||||||
|
class InviteForm(forms.ModelForm):
|
||||||
|
"""InviteForm"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
|
||||||
|
model = Invite
|
||||||
|
fields = '__all__'
|
Reference in a new issue