admin: set invitation’s created_by properly, remove edit of invite
This commit is contained in:
parent
6bcb5ef8ef
commit
57f285ae54
|
@ -17,18 +17,17 @@
|
|||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans 'Name' %}</th>
|
||||
<th>{% trans 'Provider' %}</th>
|
||||
<th>{% trans 'Expiry' %}</th>
|
||||
<th>{% trans 'Link' %}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for invitation in object_list %}
|
||||
<tr>
|
||||
<td>{{ invitation.name }}</td>
|
||||
<td>{{ invitation.provider }}</td>
|
||||
<td>{{ invitation.expires|default:"Never" }}</td>
|
||||
<td><pre>test</pre></td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-sm" href="{% url 'passbook_admin:invitation-update' pk=invitation.uuid %}?back={{ request.get_full_path }}">{% trans 'Edit' %}</a>
|
||||
<a class="btn btn-default btn-sm" href="{% url 'passbook_admin:invitation-delete' pk=invitation.uuid %}?back={{ request.get_full_path }}">{% trans 'Delete' %}</a>
|
||||
</td>
|
||||
</tr>
|
|
@ -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/<uuid:pk>/update/',
|
||||
invitations.InviteUpdateView.as_view(), name='invitation-update'),
|
||||
path('invitations/<uuid:pk>/delete/',
|
||||
invitations.InviteDeleteView.as_view(), name='invitation-delete'),
|
||||
# path('api/v1/', include('passbook.admin.api.v1.urls'))
|
||||
|
|
|
@ -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"""
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
|
|
Reference in New Issue