forked from CGM_Public/pretix_original
Teams: Improve handling of revoked keys and team deletion (Z#23163674) (#4414)
This commit is contained in:
@@ -102,16 +102,24 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for t in team.active_tokens %}
|
||||
{% for t in tokens %}
|
||||
<tr>
|
||||
<td>
|
||||
<td {% if not t.active %}class="text-muted"{% endif %}>
|
||||
{% if not t.active %}
|
||||
<del>
|
||||
{% endif %}
|
||||
{{ t.name }}
|
||||
{% if not t.active %}
|
||||
</del>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-right flip">
|
||||
<button type="submit" name="remove-token" value="{{ t.id }}"
|
||||
class="btn btn-danger btn-sm btn-block">
|
||||
<i class="fa fa-times"></i> {% trans "Remove" %}
|
||||
</button>
|
||||
{% if t.active %}
|
||||
<button type="submit" name="remove-token" value="{{ t.id }}"
|
||||
class="btn btn-danger btn-sm btn-block">
|
||||
<i class="fa fa-times"></i> {% trans "Remove" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -686,14 +686,24 @@ class TeamDeleteView(OrganizerDetailViewMixin, OrganizerPermissionRequiredMixin,
|
||||
try:
|
||||
self.object.log_action('pretix.team.deleted', user=self.request.user)
|
||||
self.object.delete()
|
||||
except ProtectedError:
|
||||
messages.error(
|
||||
self.request,
|
||||
_(
|
||||
'The team could not be deleted as some constraints (e.g. data created by '
|
||||
'plug-ins) do not allow it.'
|
||||
except ProtectedError as e:
|
||||
is_logs = any(isinstance(e, LogEntry) for e in e.protected_objects)
|
||||
if is_logs:
|
||||
messages.error(
|
||||
self.request,
|
||||
_(
|
||||
"The team could not be deleted because the team or one of its API tokens is part of "
|
||||
"historical audit logs."
|
||||
)
|
||||
)
|
||||
else:
|
||||
messages.error(
|
||||
self.request,
|
||||
_(
|
||||
'The team could not be deleted as some constraints (e.g. data created by '
|
||||
'plug-ins) do not allow it.'
|
||||
)
|
||||
)
|
||||
)
|
||||
return redirect(success_url)
|
||||
|
||||
messages.success(request, _('The selected team has been deleted.'))
|
||||
@@ -723,6 +733,7 @@ class TeamMemberView(OrganizerDetailViewMixin, OrganizerPermissionRequiredMixin,
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['add_form'] = self.add_form
|
||||
ctx['add_token_form'] = self.add_token_form
|
||||
ctx['tokens'] = self.object.tokens.order_by("-active", "name", "pk")
|
||||
return ctx
|
||||
|
||||
def _send_invite(self, instance):
|
||||
|
||||
Reference in New Issue
Block a user