first user view
This commit is contained in:
parent
bce6c23c91
commit
23091755d3
4 changed files with 48 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
<li><a href="{{ request.changeset.get_absolute_url }}">{{ request.changeset.count_display }}</a></li>
|
||||
{% if request.user.is_authenticated %}
|
||||
<li class="logged_in_user">
|
||||
<a>{{ request.user.username }}</a>
|
||||
<a href="{% url 'editor.users.detail' pk=request.user.pk %}">{{ request.user.username }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="login_logout">
|
||||
|
|
22
src/c3nav/editor/templates/editor/user.html
Normal file
22
src/c3nav/editor/templates/editor/user.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% 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>
|
||||
|
||||
<h4>{% trans 'Change sets' %}</h4>
|
||||
<table class="table table-condensed itemtable">
|
||||
{% for changeset in changesets %}
|
||||
<tr>
|
||||
<td>#{{ changeset.pk }}: {% if changeset.title %}{{ changeset.title }}{% else %}<em>{% trans '(no title)' %}</em>{% endif %}</td>
|
||||
<td><a href="{% url 'editor.changesets.detail' pk=changeset.pk %}">{% trans 'Details' %}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
|
||||
|
|
@ -4,6 +4,7 @@ from django.conf.urls import url
|
|||
from c3nav.editor.views.changes import changeset_detail, changeset_edit
|
||||
from c3nav.editor.views.edit import edit, level_detail, list_objects, main_index, space_detail
|
||||
from c3nav.editor.views.login import login_view, logout_view
|
||||
from c3nav.editor.views.users import user_detail
|
||||
|
||||
|
||||
def add_editor_urls(model_name, parent_model_name=None, with_list=True, explicit_edit=False):
|
||||
|
@ -38,6 +39,7 @@ urlpatterns = [
|
|||
kwargs={'model': 'Level'}),
|
||||
url(r'^changesets/(?P<pk>[0-9]+)/$', changeset_detail, name='editor.changesets.detail'),
|
||||
url(r'^changesets/(?P<pk>[0-9]+)/edit$', changeset_edit, name='editor.changesets.edit'),
|
||||
url(r'^users/(?P<pk>[0-9]+)/$', user_detail, name='editor.users.detail'),
|
||||
url(r'^login$', login_view, name='editor.login'),
|
||||
url(r'^logout$', logout_view, name='editor.logout'),
|
||||
]
|
||||
|
|
23
src/c3nav/editor/views/users.py
Normal file
23
src/c3nav/editor/views/users.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from django.contrib.auth.models import User
|
||||
from django.db.models import Max
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
|
||||
from c3nav.editor.models import ChangeSet
|
||||
from c3nav.editor.views.base import sidebar_view
|
||||
|
||||
|
||||
@sidebar_view
|
||||
def user_detail(request, pk):
|
||||
user = request.user
|
||||
if str(pk) != str(user.pk):
|
||||
user = get_object_or_404(User, pk=pk)
|
||||
|
||||
qs = ChangeSet.objects.filter(author=user)
|
||||
qs = qs.annotate(last_change_cache=Max('changed_objects_set__last_update')).order_by('-last_change_cache')
|
||||
|
||||
ctx = {
|
||||
'user': user,
|
||||
'changesets': qs,
|
||||
}
|
||||
|
||||
return render(request, 'editor/user.html', ctx)
|
Loading…
Add table
Add a link
Reference in a new issue