more stuff for not applying changesets when they have problems
This commit is contained in:
parent
ad252bf6c6
commit
a88f8cea34
3 changed files with 7 additions and 3 deletions
|
@ -167,7 +167,7 @@ class ChangeSet(models.Model):
|
||||||
return self.can_edit(request) and self.state == 'unproposed'
|
return self.can_edit(request) and self.state == 'unproposed'
|
||||||
|
|
||||||
def can_propose(self, request):
|
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):
|
def can_unpropose(self, request):
|
||||||
return self.author_id == request.user.pk and self.state in ('proposed', 'reproposed')
|
return self.author_id == request.user.pk and self.state in ('proposed', 'reproposed')
|
||||||
|
|
|
@ -143,7 +143,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if can_end_review %}
|
{% if can_end_review %}
|
||||||
<button type="submit" class="btn btn-danger" name="reject" value="1">{% trans 'Reject' %}</button>
|
<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 %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if can_start_review %}
|
{% if can_start_review %}
|
||||||
|
|
|
@ -185,6 +185,10 @@ def changeset_detail(request, pk):
|
||||||
messages.error(request, _('You cannot accept and apply these changes.'))
|
messages.error(request, _('You cannot accept and apply these changes.'))
|
||||||
return redirect(reverse('editor.changesets.detail', kwargs={'pk': changeset.pk}))
|
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':
|
if request.POST.get('apply_confirm') == '1':
|
||||||
changeset.apply(request.user)
|
changeset.apply(request.user)
|
||||||
messages.success(request, _('You accepted and applied these changes.'))
|
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_unpropose': changeset.can_unpropose(request),
|
||||||
'can_start_review': changeset.can_start_review(request),
|
'can_start_review': changeset.can_start_review(request),
|
||||||
'can_end_review': changeset.can_end_review(request),
|
'can_end_review': changeset.can_end_review(request),
|
||||||
'can_apply': changeset.can_apply(request),
|
|
||||||
'can_unreject': changeset.can_unreject(request),
|
'can_unreject': changeset.can_unreject(request),
|
||||||
|
'can_apply': changeset.can_apply(request),
|
||||||
'active': active,
|
'active': active,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue