fix: Don't offer already-disabled API keys for disablement (#5262)

* fix: Don't offer already-disabled API keys for disablement

Fixes #3441

* Remove test class
This commit is contained in:
Lars Eggert 2023-03-02 18:18:51 +02:00 committed by GitHub
parent 5fc93bb8ca
commit 276dd08794
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -777,7 +777,7 @@ def apikey_create(request):
@person_required
def apikey_disable(request):
person = request.user.person
choices = [ (k.hash(), str(k)) for k in person.apikeys.all() ]
choices = [ (k.hash(), str(k)) for k in person.apikeys.exclude(valid=False) ]
#
class KeyDeleteForm(forms.Form):
hash = forms.ChoiceField(label='Key', choices=choices)

View file

@ -37,9 +37,9 @@
<td>{{ key.created }}</td>
<td>{{ key.latest }}</td>
<td>{{ key.count }}</td>
<td>{{ key.valid }}</td>
<td class="{{ key.valid|yesno:'text-success,text-danger'}}">{{ key.valid }}</td>
<td>
<code>{{ key.hash }}</code>
<code {% if not key.valid %}class="text-decoration-line-through"{% endif %}>{{ key.hash }}</code>
</td>
<td >
{% if key.valid %}
@ -63,4 +63,4 @@
{% endblock %}
{% block js %}
<script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}
{% endblock %}