fmartingr
/
shelfzilla
Archived
1
0
Fork 0

Public user profiles now working. Basically the same as the one we had but with modified urls and some behaviour is changed.

This commit is contained in:
Felipe Martín 2014-08-24 18:03:44 +02:00
parent 6569d3ce96
commit 6340b1bb74
11 changed files with 74 additions and 65 deletions

View File

@ -1,17 +1,17 @@
from django.conf.urls import patterns, url
from .views import LoginView, LogoutView, ProfileView
from .views import LoginView, LogoutView,UserProfileView
urlpatterns = patterns(
'',
url(r'^login/$', LoginView.as_view(), name="login"),
url(r'^logout/$', LogoutView.as_view(), name="logout"),
url(
r'^profile/$',
ProfileView.as_view(),
r'^user/(?P<username>[\w\d\-\.]+)/$',
UserProfileView.as_view(),
name="profile"),
url(
r'^profile/(?P<section>\w+)/$',
ProfileView.as_view(),
r'^user/(?P<username>[\w\d\-\.]+)/(?P<section>\w+)/$',
UserProfileView.as_view(),
name="profile"),
)

View File

@ -1,6 +1,6 @@
from django.views.generic import View
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.auth import logout
from django.utils.translation import ugettext as _
from django.http import HttpResponseRedirect, Http404
@ -62,25 +62,22 @@ class LogoutView(View):
return HttpResponseRedirect('/')
class ProfileView(View):
class UserProfileView(View):
tempalte = 'users/profile.html'
template_section = 'users/profile/{}.html'
def get(self, request, section='summary'):
if request.user.is_authenticated():
data = {
'item': User.objects.get(pk=request.user.pk)
}
if section != 'summary':
template = self.template_section.format(section)
else:
template = self.tempalte
data = self.get_context_from_section(request, section, data)
ctx = RequestContext(request, data)
return render_to_response(template, context_instance=ctx)
def get(self, request, username, section='summary'):
data = {
'item': get_object_or_404(User, username=username)
}
if section != 'summary':
template = self.template_section.format(section)
else:
raise Http404
template = self.tempalte
data = self.get_context_from_section(request, section, data)
ctx = RequestContext(request, data)
return render_to_response(template, context_instance=ctx)
def get_summary(self, request, context):
context['SUMMARY'] = 'Y'

View File

@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-08-24 17:18+0200\n"
"PO-Revision-Date: 2014-08-24 17:18+0200\n"
"POT-Creation-Date: 2014-08-24 18:02+0200\n"
"PO-Revision-Date: 2014-08-24 18:02+0200\n"
"Last-Translator: Felipe Martin <fmartingr@me.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
@ -76,13 +76,13 @@ msgstr "Avanzado"
#: apps/manga/admin.py:78 apps/manga/models.py:118 apps/manga/models.py:119
#: themes/bootflat/templates/_layout.html:33
#: themes/bootflat/templates/manga/publishers/detail.html:18
#: themes/bootflat/templates/manga/publishers/detail.html:24
#: themes/bootflat/templates/manga/series/list.html:4
msgid "Series"
msgstr "Series"
#: apps/manga/admin.py:93 apps/manga/admin.py:121 apps/manga/models.py:150
#: themes/bootflat/templates/manga/publishers/detail.html:21
#: themes/bootflat/templates/manga/publishers/detail.html:27
msgid "Volumes"
msgstr "Volúmenes"
@ -177,7 +177,7 @@ msgid "wants"
msgstr "quiere"
#: apps/manga/views/search.py:11 apps/manga/views/search.py:13
#: themes/bootflat/templates/_layout.html:71
#: themes/bootflat/templates/_layout.html:72
#: themes/bootflat/templates/_admin/volumes/includes/cover.html:6
#: themes/bootflat/templates/_admin/volumes/includes/cover.html:15
msgid "Search"
@ -227,7 +227,7 @@ msgstr "Has accedido correctamente."
msgid "Logged out successfully"
msgstr "Sesión finalizada."
#: settings/base.py:121
#: settings/base.py:124
msgid "Spanish"
msgstr "Español"
@ -251,25 +251,18 @@ msgstr ""
msgid "Toggle navigation"
msgstr "Mostrar/Ocultar navegación"
#: themes/bootflat/templates/_layout.html:48
#: themes/bootflat/templates/_layout.html:42
#: themes/bootflat/templates/_layout.html:50
#: themes/bootflat/templates/users/profile-pjax.html:4
#: themes/bootflat/templates/users/profile.html:4
msgid "Profile"
msgstr "Perfil"
#: themes/bootflat/templates/_layout.html:51
msgid "My collection"
msgstr "Mi colección"
#: themes/bootflat/templates/_layout.html:52
msgid "My wishlist"
msgstr "Mi lista de deseados"
#: themes/bootflat/templates/_layout.html:55
msgid "Logout"
msgstr "Cerrar sesión"
#: themes/bootflat/templates/_layout.html:61
#: themes/bootflat/templates/_layout.html:62
msgid "Log in"
msgstr "Entrar"
@ -324,22 +317,23 @@ msgstr "Buscando..."
msgid "No results"
msgstr "Sin resultados"
#: themes/bootflat/templates/manga/publishers/detail.html:14
#: themes/bootflat/templates/manga/publishers/detail.html:43
#: themes/bootflat/templates/manga/publishers/detail.html:10
#: themes/bootflat/templates/manga/series/detail.html:10
#: themes/bootflat/templates/manga/series/includes/volume.html:42
msgid "Edit in admin"
msgstr "Editar en el admin"
#: themes/bootflat/templates/manga/publishers/detail.html:20
#: themes/bootflat/templates/manga/publishers/detail.html:49
#: themes/bootflat/templates/manga/series/detail.html:25
#: themes/bootflat/templates/manga/series/includes/volume.html:25
msgid "Requires review"
msgstr "Requiere revisión"
#: themes/bootflat/templates/manga/publishers/detail.html:25
#: themes/bootflat/templates/manga/publishers/detail.html:31
msgid "Homepage"
msgstr "Página principal"
#: themes/bootflat/templates/manga/series/detail.html:10
#: themes/bootflat/templates/manga/series/includes/volume.html:42
msgid "Edit in admin"
msgstr "Editar en el admin"
#: themes/bootflat/templates/manga/series/detail.html:29
msgid "Status"
msgstr "Estado"
@ -375,17 +369,21 @@ msgstr "Entrar"
#: themes/bootflat/templates/users/profile.html:30
#: themes/bootflat/templates/users/profile/collection.html:4
msgid "Collection"
msgstr "Mi colección"
msgstr "Colección"
#: themes/bootflat/templates/users/profile.html:34
#: themes/bootflat/templates/users/profile/wishlist.html:4
msgid "Wishlist"
msgstr "Lista de deseados"
#: themes/bootflat/templates/users/profile.html:44
#: themes/bootflat/templates/users/profile.html:46
msgid "Edit my profile"
msgstr "Editar mi perfil"
#: themes/bootflat/templates/users/profile.html:50
msgid "My preferences"
msgstr "Mis preferencias"
#: themes/bootflat/templates/users/profile/achievements.html:4
msgid "Achievements"
msgstr "Logros"
@ -398,6 +396,12 @@ msgstr "Volúmenes"
msgid "Volumes wishlisted"
msgstr "Deseados"
#~ msgid "My collection"
#~ msgstr "Mi colección"
#~ msgid "My wishlist"
#~ msgstr "Mi lista de deseados"
#~ msgid "all"
#~ msgstr "todos"

View File

@ -39,18 +39,18 @@
{% endif %}
<ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %}
<li><a href="{% url 'profile' %}" title="{% trans "Profile" %}">
<li><a href="{% url 'profile' user.username %}" title="{% trans "Profile" %}">
<img src="{{ user.avatar }}" class="avatar img-rounded"/>
{{ user.username }}</a>
</li>
{% if user.is_superuser %}
<li><a data-pjax-unnav href="/admin/" title="Admin"><i class="glyphicon glyphicon-tower"></i></a></li>
{% endif %}
<li><a data-pjax-unnav href="{% url 'profile' %}" data-pjax
<!-- <li><a data-pjax-unnav href="{% url 'profile' user.username %}" data-pjax
title="{% trans "Profile" %}">
<i class="glyphicon glyphicon-user"></i>
</a>
</li>
</li> -->
<li><a data-pjax-unnav href="{% url "logout" %}"
title="{% trans "Logout" %}">
<i class="glyphicon glyphicon-off"></i>

View File

@ -69,8 +69,8 @@
{% for user in TOP_5_COLLECTORS %}
<li class="list-group-item list-group-users">
<strong>#{{ forloop.counter }}</strong>
<img src="{{ user.avatar }}" class="avatar img-rounded"/>
{{ user.username }}
<a href="{% url 'profile' user.username %}"><img src="{{ user.avatar }}" class="avatar img-rounded"/>
{{ user.username }}</a>
<span class="pull-right">
<i>{% blocktrans with count=user.have_volumes.count %}{{ count }} volumes{% endblocktrans %}</i>
</span>

View File

@ -1,7 +1,7 @@
{% extends '_layout.html'|pjax:request %}
{% load i18n %}
{% block page_title %}{{ block.super }} | {% trans "Profile" %}{% endblock %}
{% block page_title %}{{ block.super }} | {{ item.username }} | {% trans "Profile" %}{% endblock %}
{% block main_content %}
{% block profile_content %}{% endblock %}

View File

@ -1,7 +1,7 @@
{% extends '_layout.html'|pjax:request %}
{% load i18n %}
{% block page_title %}{{ block.super }} | {% trans "Profile" %}{% endblock %}
{% block page_title %}{{ block.super }} | {{ item.username }} | {% trans "Profile" %}{% endblock %}
{% block main_content %}
<div class="container">
@ -23,24 +23,32 @@
<img src="{{ item.avatar }}" class="max-width-100" />
</div>
<div class="list-group">
<a data-pjax-nav href="{% url 'profile' %}" data-pjax class="list-group-item active">
<a data-pjax-nav href="{% url 'profile' item.username %}" data-pjax class="list-group-item active">
{% trans "Summary" %}</a>
{% if user.have_volumes.count > 0 %}
<a data-pjax-nav href="{% url 'profile' 'collection' %}" data-pjax="profile" class="list-group-item">
<a data-pjax-nav href="{% url 'profile' item.username 'collection' %}" data-pjax="profile" class="list-group-item">
{% trans "Collection" %}</a>
{% endif %}
{% if user.wishlisted_volumes.count > 0 %}
<a data-pjax-nav href="{% url 'profile' 'wishlist' %}" data-pjax="profile" class="list-group-item">
<a data-pjax-nav href="{% url 'profile' item.username 'wishlist' %}" data-pjax="profile" class="list-group-item">
{% trans "Wishlist" %}</a>
{% endif %}
{% comment %}
<a data-pjax-nav href="{% url 'profile' 'achievements' %}" data-pjax="profile" class="list-group-item">
<a data-pjax-nav href="{% url 'profile' item.username 'achievements' %}" data-pjax="profile" class="list-group-item">
{% trans "Achievements" %}</a>
{% endcomment %}
</div>
</div>
<div>
<button class="btn btn-info btn-block">{% trans "Edit my profile" %}</button>
{% if request.user.pk == item.pk %}
<button class="btn btn-info btn-block">
{% trans "Edit my profile" %}
</button>
<button class="btn btn-info btn-block">
<i class="fa fa-cog"></i>
{% trans "My preferences" %}
</button>
{% endif %}
</div>
</div>
<div class="col-sm-9" data-pjax-container="profile">

View File

@ -5,9 +5,9 @@
{% block profile_content %}
<div class="row">
{% for owned_volume in user.have_volumes.all %}
{% for owned_volume in item.have_volumes.all %}
<div class="col-sm-3" data-pjax-container="v{{ volume.pk }}">
{% include "manga/series/includes/volume.html" with volume=owned_volume.volume user=user %}
{% include "manga/series/includes/volume.html" with volume=owned_volume.volume user=item %}
</div>
{% if forloop.counter|divisibleby:4 %}
</div>

View File

@ -9,13 +9,13 @@
<div class="row text-center">
<div class="col-sm-6">
<div class="well">
<h2 class="no-margin-top">{{ user.have_volumes.count }}</h2>
<h2 class="no-margin-top">{{ item.have_volumes.count }}</h2>
{% trans "Volumes owned" %}
</div>
</div>
<div class="col-sm-6">
<div class="well">
<h2 class="no-margin-top">{{ user.wishlisted_volumes.count }}</h2>
<h2 class="no-margin-top">{{ item.wishlisted_volumes.count }}</h2>
{% trans "Volumes wishlisted" %}
</div>
</div>

View File

@ -5,9 +5,9 @@
{% block profile_content %}
<div class="row">
{% for wishlisted_volume in user.wishlisted_volumes.all %}
{% for wishlisted_volume in item.wishlisted_volumes.all %}
<div class="col-sm-3" data-pjax-container="v{{ wishlisted_volume.volume.pk }}">
{% include "manga/series/includes/volume.html" with volume=wishlisted_volume.volume user=user %}
{% include "manga/series/includes/volume.html" with volume=wishlisted_volume.volume user=item %}
</div>
{% if forloop.counter|divisibleby:4 %}
</div>