From 57f285ae54e9eee8031269d293df228ab44b94db Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 10 Dec 2018 14:38:44 +0100 Subject: [PATCH] =?UTF-8?q?admin:=20set=20invitation=E2=80=99s=20created?= =?UTF-8?q?=5Fby=20properly,=20remove=20edit=20of=20invite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../administration/{invite => invitation}/list.html | 9 ++++----- passbook/admin/urls.py | 2 -- passbook/admin/views/invitations.py | 13 ++++--------- passbook/core/forms/invitations.py | 11 ++++++++++- 4 files changed, 18 insertions(+), 17 deletions(-) rename passbook/admin/templates/administration/{invite => invitation}/list.html (70%) diff --git a/passbook/admin/templates/administration/invite/list.html b/passbook/admin/templates/administration/invitation/list.html similarity index 70% rename from passbook/admin/templates/administration/invite/list.html rename to passbook/admin/templates/administration/invitation/list.html index ae7b7d46b..d3ab34faf 100644 --- a/passbook/admin/templates/administration/invite/list.html +++ b/passbook/admin/templates/administration/invitation/list.html @@ -17,18 +17,17 @@ - - + + {% for invitation in object_list %} - - + + diff --git a/passbook/admin/urls.py b/passbook/admin/urls.py index 300db95ae..2133b1bce 100644 --- a/passbook/admin/urls.py +++ b/passbook/admin/urls.py @@ -37,8 +37,6 @@ urlpatterns = [ # Invitations path('invitations/', invitations.InviteListView.as_view(), name='invitations'), path('invitations/create/', invitations.InviteCreateView.as_view(), name='invitation-create'), - path('invitations//update/', - invitations.InviteUpdateView.as_view(), name='invitation-update'), path('invitations//delete/', invitations.InviteDeleteView.as_view(), name='invitation-delete'), # path('api/v1/', include('passbook.admin.api.v1.urls')) diff --git a/passbook/admin/views/invitations.py b/passbook/admin/views/invitations.py index e4a50a899..a34f47854 100644 --- a/passbook/admin/views/invitations.py +++ b/passbook/admin/views/invitations.py @@ -24,15 +24,10 @@ class InviteCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView): success_message = _('Successfully created Invite') form_class = InviteForm - -class InviteUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView): - """Update invitation""" - - model = Invite - template_name = 'generic/update.html' - success_url = reverse_lazy('passbook_admin:invitations') - success_message = _('Successfully updated Invite') - form_class = InviteForm + def get_initial(self): + return { + 'created_by': self.request.user + } class InviteDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView): """Delete invitation""" diff --git a/passbook/core/forms/invitations.py b/passbook/core/forms/invitations.py index 0a23b1792..d6118da6e 100644 --- a/passbook/core/forms/invitations.py +++ b/passbook/core/forms/invitations.py @@ -11,4 +11,13 @@ class InviteForm(forms.ModelForm): class Meta: model = Invite - fields = '__all__' + fields = ['created_by', 'expires', 'fixed_username', 'fixed_email'] + labels = { + 'fixed_username': "Force user's username (optional)", + 'fixed_email': "Force user's email (optional)", + } + widgets = { + 'created_by': forms.Select(attrs={'disabled': 'disabled'}), + 'fixed_username': forms.TextInput(), + 'fixed_email': forms.TextInput(), + }
{% trans 'Name' %}{% trans 'Provider' %}{% trans 'Expiry' %}{% trans 'Link' %}
{{ invitation.name }}{{ invitation.provider }}{{ invitation.expires|default:"Never" }}
test
- {% trans 'Edit' %} {% trans 'Delete' %}