deactivate the current change set
This commit is contained in:
parent
d918868b6f
commit
0723992ae1
3 changed files with 38 additions and 7 deletions
|
@ -195,6 +195,9 @@ form button.invisiblesubmit {
|
|||
.tooltip {
|
||||
font-size:16px;
|
||||
}
|
||||
h4 {
|
||||
margin-top:20px;
|
||||
}
|
||||
|
||||
/* responsiveness */
|
||||
#responsive_switch {
|
||||
|
|
|
@ -1,14 +1,36 @@
|
|||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
|
||||
{% include 'editor/fragment_modal_close.html' %}
|
||||
<h3>
|
||||
<i class="glyphicon glyphicon-user"></i> {{ user.username }}
|
||||
{% if request.user == user %}
|
||||
<small class="text-success">{% trans "That\'s you!" %}</small>
|
||||
{% endif %}
|
||||
</h3>
|
||||
{% bootstrap_messages %}
|
||||
{% if request.user == user %}
|
||||
<h4 class="text-success">{% trans "That\'s you!" %}</h4>
|
||||
{% if request.changeset.pk %}
|
||||
{% with changeset_title=changeset.title changeset_id=request.changeset.pk %}
|
||||
{% url 'editor.changeset.detail' pk=request.changeset.pk as changeset_url %}
|
||||
<p>
|
||||
{% if changeset_title %}
|
||||
{% blocktrans %}Your active change set is <a href="{{ changeset_url }}">{{ changeset_title }}</a>.{% endblocktrans %}
|
||||
{% else %}
|
||||
{% blocktrans %}Your active change set is <a href="{{ changeset_url }}">#{{ changeset_id }} (untitled)</a>.{% endblocktrans %}
|
||||
{% endif %}
|
||||
<br>{% blocktrans %}Deactivate it if you want to create a new one.{% endblocktrans %}
|
||||
</p>
|
||||
<form method="post" action="{{ request.path }}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-xs btn-default" name="deactivate_changeset" value="1">{% trans 'Deactivate change set' %}</button>
|
||||
</form>
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
{% trans 'You have currently no active change set.' %}<br>
|
||||
{% trans 'Just edit something to create one.' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<h4>{% trans 'Recent change sets' %}</h4>
|
||||
{% include 'editor/fragment_changesets.html' %}
|
||||
{% include 'editor/fragment_changesets.html' with changesets=recent_changesets %}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.contrib import messages
|
||||
from django.contrib.auth.models import User
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from c3nav.editor.models import ChangeSet
|
||||
from c3nav.editor.views.base import sidebar_view
|
||||
|
@ -11,11 +13,15 @@ def user_detail(request, pk):
|
|||
if str(pk) != str(user.pk):
|
||||
user = get_object_or_404(User, pk=pk)
|
||||
|
||||
qs = ChangeSet.objects.filter(author=user).order_by('-last_update')[:10]
|
||||
if request.method == 'POST':
|
||||
if request.POST.get('deactivate_changeset') == '1' and request.user == user and 'changeset' in request.session:
|
||||
request.session.pop('changeset', None)
|
||||
messages.success(request, _('You deactivated your current changeset.'))
|
||||
return redirect(request.path)
|
||||
|
||||
ctx = {
|
||||
'user': user,
|
||||
'changesets': qs,
|
||||
'recent_changesets': ChangeSet.objects.filter(author=user).order_by('-last_update')[:10],
|
||||
}
|
||||
|
||||
return render(request, 'editor/user.html', ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue