apply changes (ui, not yet applying them)
This commit is contained in:
parent
455d9a199b
commit
9d194e6de6
3 changed files with 23 additions and 6 deletions
|
@ -365,7 +365,11 @@ class ChangeSet(models.Model):
|
|||
self.save()
|
||||
|
||||
def apply(self, user):
|
||||
pass
|
||||
update = self.updates.create(user=user, state='applied')
|
||||
self.state = 'applied'
|
||||
self.last_state_update = update
|
||||
self.last_update = update
|
||||
self.save()
|
||||
|
||||
def activate(self, request):
|
||||
request.session['changeset'] = self.pk
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% include 'editor/fragment_modal_close.html' %}
|
||||
<h3>{% trans 'Restore original state' %}</h3>
|
||||
<h3>{% trans 'Apply these changes' %}</h3>
|
||||
<form action="{{ request.path }}" method="post">
|
||||
{% csrf_token %}
|
||||
<p>{% trans 'Do you really want to restore the original state before this change?' %}</p>
|
||||
<input type="hidden" name="restore" value="{{ pk }}">
|
||||
<p>{% trans 'Do you really want to apply these changes?' %}</p>
|
||||
<input type="hidden" name="apply" value="1">
|
||||
{% buttons %}
|
||||
<button class="invisiblesubmit" type="submit"></button>
|
||||
<a class="btn btn-default" href="{{ request.path }}">
|
||||
{% trans 'Cancel' %}
|
||||
</a>
|
||||
<button type="submit" name="restore_confirm" value="1" class="btn btn-primary pull-right">
|
||||
{% trans 'Restore' %}
|
||||
<button type="submit" name="apply_confirm" value="1" class="btn btn-success pull-right">
|
||||
{% trans 'Apply' %}
|
||||
</button>
|
||||
{% endbuttons %}
|
||||
</form>
|
||||
|
|
|
@ -124,6 +124,19 @@ def changeset_detail(request, pk):
|
|||
|
||||
return redirect(reverse('editor.changesets.detail', kwargs={'pk': changeset.pk}))
|
||||
|
||||
elif request.POST.get('apply') == '1':
|
||||
with changeset.lock_to_edit() as changeset:
|
||||
if not changeset.can_end_review(request):
|
||||
messages.error(request, _('You cannot apply these changes.'))
|
||||
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 applied these changes.'))
|
||||
return redirect(reverse('editor.changesets.detail', kwargs={'pk': changeset.pk}))
|
||||
|
||||
return render(request, 'editor/changeset_apply.html', {})
|
||||
|
||||
elif request.POST.get('delete') == '1':
|
||||
if not changeset.can_delete(request):
|
||||
raise PermissionDenied
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue