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