more stuff for not applying changesets when they have problems

This commit is contained in:
Laura Klünder 2024-12-02 13:40:53 +01:00
parent ad252bf6c6
commit a88f8cea34
3 changed files with 7 additions and 3 deletions

View file

@ -167,7 +167,7 @@ class ChangeSet(models.Model):
return self.can_edit(request) and self.state == 'unproposed'
def can_propose(self, request):
return self.can_edit(request) and not self.proposed and self.changes
return self.can_edit(request) and not self.proposed and self.changes and not self.problems.any
def can_unpropose(self, request):
return self.author_id == request.user.pk and self.state in ('proposed', 'reproposed')

View file

@ -143,7 +143,7 @@
{% endif %}
{% if can_end_review %}
<button type="submit" class="btn btn-danger" name="reject" value="1">{% trans 'Reject' %}</button>
<button type="submit" {% if not can_apply %}disabled="disabled" {% endif %}class="btn btn-success" name="apply" value="1">{% trans 'Accept' %}</button>
<button type="submit" {% if can_apply %}disabled="disabled" {% endif %}class="btn btn-success" name="apply" value="1">{% trans 'Accept' %}</button>
{% endif %}
{% endif %}
{% if can_start_review %}

View file

@ -185,6 +185,10 @@ def changeset_detail(request, pk):
messages.error(request, _('You cannot accept and apply these changes.'))
return redirect(reverse('editor.changesets.detail', kwargs={'pk': changeset.pk}))
if not changeset.can_apply(request):
messages.error(request, _('You cannot apply this changeset cause it has problems.'))
return redirect(reverse('editor.changesets.detail', kwargs={'pk': changeset.pk}))
if request.POST.get('apply_confirm') == '1':
changeset.apply(request.user)
messages.success(request, _('You accepted and applied these changes.'))
@ -219,8 +223,8 @@ def changeset_detail(request, pk):
'can_unpropose': changeset.can_unpropose(request),
'can_start_review': changeset.can_start_review(request),
'can_end_review': changeset.can_end_review(request),
'can_apply': changeset.can_apply(request),
'can_unreject': changeset.can_unreject(request),
'can_apply': changeset.can_apply(request),
'active': active,
}