admin: add invite administration
This commit is contained in:
		@ -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' %}">
 | 
			
		||||
    <a href="{% url 'passbook_admin:rules' %}">{% trans 'Rules' %}</a>
 | 
			
		||||
  </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>
 | 
			
		||||
    <a href="#">{% trans 'Users' %}</a>
 | 
			
		||||
  </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"""
 | 
			
		||||
from django.urls import path
 | 
			
		||||
 | 
			
		||||
from passbook.admin.views import (applications, overview, providers, rules,
 | 
			
		||||
                                  sources)
 | 
			
		||||
from passbook.admin.views import (applications, invites, overview, providers,
 | 
			
		||||
                                  rules, sources)
 | 
			
		||||
 | 
			
		||||
urlpatterns = [
 | 
			
		||||
    path('', overview.AdministrationOverviewView.as_view(), name='overview'),
 | 
			
		||||
@ -34,5 +34,10 @@ urlpatterns = [
 | 
			
		||||
         providers.ProviderUpdateView.as_view(), name='provider-update'),
 | 
			
		||||
    path('providers/<int:pk>/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'))
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										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 New Issue
	
	Block a user