Profile views

This commit is contained in:
Felipe Martín 2015-09-10 22:31:55 +02:00
parent 8332888d5c
commit 11863b5023
11 changed files with 200 additions and 23 deletions

View File

View File

View File

@ -0,0 +1,20 @@
# coding: utf-8
# django
from django.conf.urls import url, patterns
from django.utils.translation import ugettext_lazy as _
# home
from .views import ProfileView
urlpatterns = patterns(
'',
url(_(r'^profile/(?P<username>[\w\d\-]+)/$'),
ProfileView.as_view(),
name='main'),
url(_(r'^profile/(?P<username>[\w\d\-]+)/(?P<type>\w+)/(?P<relation>\w+)/$'),
ProfileView.as_view(),
name='main-filter'),
)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
from django.contrib.auth import get_user_model
from django.views.generic.base import View
from django.shortcuts import render, get_object_or_404
from amiibofindr.apps.amiibo.models import UserAmiibo, AmiiboFigure, AmiiboCard
class ProfileView(View):
template = 'profile/main.html'
types = {
'figures': ('figure', AmiiboFigure),
'cards': ('card', AmiiboCard),
}
relations = ('own', 'want', 'trade', )
def get(self, request, username, type='figures', relation='own'):
user = get_object_or_404(get_user_model(), username=username)
relation_filter = {relation: True}
amiibo_pks = UserAmiibo.objects.filter(
user=user,
_amiibo__type=self.types[type][0],
**relation_filter
).values_list('_amiibo__id', flat=True)
amiibo_list = self.types[type][1].objects.filter(pk__in=amiibo_pks)
return render(request, self.template, {
'this_user': user,
'amiibo_list': amiibo_list,
'type': type,
'relation': relation
})

View File

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-10 21:36+0200\n"
"PO-Revision-Date: 2015-09-10 21:38+0200\n"
"POT-Creation-Date: 2015-09-10 22:30+0200\n"
"PO-Revision-Date: 2015-09-10 22:30+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
@ -210,6 +210,14 @@ msgstr ""
msgid "^amiibo/(?P<amiibo>\\d+)/(?P<action>[\\w\\+\\-\\=]+)$"
msgstr "^amiibo/(?P<amiibo>\\d+)/(?P<action>[\\w\\+\\-\\=]+)$"
#: apps/profile/urls.py:13
msgid "^profile/(?P<username>[\\w\\d\\-]+)/$"
msgstr "^perfil/(?P<username>[\\w\\d\\-]+)/$"
#: apps/profile/urls.py:16
msgid "^profile/(?P<username>[\\w\\d\\-]+)/(?P<type>\\w+)/(?P<relation>\\w+)/$"
msgstr "^perfil/(?P<username>[\\w\\d\\-]+)/(?P<type>\\w+)/(?P<relation>\\w+)/$"
#: templates/404.html:10
msgid "Not found!"
msgstr "No encontrado."
@ -248,51 +256,57 @@ msgstr ""
msgid "all"
msgstr "todas"
#: templates/_layout.html:36 templates/_layout.html.py:104
#: templates/_layout.html:36 templates/_layout.html.py:105
#: templates/profile/main.html:35
msgid "Figures"
msgstr "Figuras"
#: templates/_layout.html:39 templates/_layout.html.py:51
#: templates/_layout.html:106 templates/_layout.html.py:115
#: templates/_layout.html:39 templates/_layout.html.py:50
#: templates/_layout.html:107 templates/_layout.html.py:116
msgid "All"
msgstr "Todas"
#: templates/_layout.html:48 templates/_layout.html.py:113
#: templates/_layout.html:47 templates/_layout.html.py:114
#: templates/profile/main.html:36
msgid "Cards"
msgstr "Tarjetas"
#: templates/_layout.html:63 templates/_layout.html.py:90
#: templates/_layout.html:62 templates/_layout.html.py:90
msgid "My public profile"
msgstr "Mi perfil público"
#: templates/_layout.html:63 templates/_layout.html.py:91
#: templates/account/password_reset_from_key.html:49
msgid "Change password"
msgstr "Cambiar contraseña"
#: templates/_layout.html:64 templates/_layout.html.py:91
#: templates/_layout.html:64 templates/_layout.html.py:92
msgid "Emails"
msgstr "Emails"
#: templates/_layout.html:66 templates/_layout.html.py:92
#: templates/_layout.html:66 templates/_layout.html.py:93
msgid "Log out"
msgstr "Cerrar sesión"
#: templates/_layout.html:70 templates/_layout.html.py:98
#: templates/home/home.html:66
#: templates/_layout.html:70 templates/_layout.html.py:99
#: templates/home/home.html:74
msgid "Login"
msgstr "Iniciar sesión"
#: templates/_layout.html:71 templates/_layout.html.py:99
#: templates/home/home.html:64
#: templates/_layout.html:71 templates/_layout.html.py:100
#: templates/home/home.html:72
msgid "Register"
msgstr "Registrarse"
#: templates/_layout.html:143
#: templates/_layout.html:144
msgid "Select desired currency"
msgstr "Seleccionar moneda"
#: templates/_layout.html:148
#: templates/_layout.html:149
msgid "No convert"
msgstr "Sin conversión"
#: templates/_layout.html:152
#: templates/_layout.html:153
msgid "Language"
msgstr "Idioma"
@ -632,7 +646,7 @@ msgid "I want this"
msgstr "Lo quiero"
#: templates/amiibo/amiibo-figure.html:56
#: templates/amiibo/amiibo-figure.html:66 templates/home/home.html:65
#: templates/amiibo/amiibo-figure.html:66 templates/home/home.html:73
msgid "or"
msgstr "o"
@ -753,10 +767,24 @@ msgstr ""
"precios, e iremos añadiendo más y más."
#: templates/home/home.html:53
msgid "Public profiles"
msgstr "Perfiles públicos"
#: templates/home/home.html:54
msgid ""
"You will get a unique URL where you have all you collected, wanted and "
"traded amiibo. For free! This way you will never forget what you have "
"available."
msgstr ""
"Dispondrás de una dirección web única para ti donde estarán visibles los "
"amiibo que quieres, tienes e intercambias. ¡Gratis! De esta manera nunca "
"olvidaras lo que tienes."
#: templates/home/home.html:61
msgid "EUR, GBP, JPY, USD..."
msgstr "EUR, GBP, JPY, USD..."
#: templates/home/home.html:54
#: templates/home/home.html:62
msgid ""
"Because not everyone can do math to convert from currencies on the fly, you "
"can select your desired currency to get an approximate conversion in real "
@ -766,11 +794,11 @@ msgstr ""
"monedas extranjeras puedes seleccionar tu preferida para ver todos los "
"precios con ella, ¡así de fácil!"
#: templates/home/home.html:58
#: templates/home/home.html:66
msgid "And the most important reason of all?"
msgstr "¿Y cual es la razón más importante de todas?"
#: templates/home/home.html:60
#: templates/home/home.html:68
msgid ""
"We are collectors too! We like amiibo and we do this for fun on our spare "
"time."
@ -778,11 +806,11 @@ msgstr ""
"¡Nosotros también somos coleccionistas! Nos gustan los amiibo y hacemos esto "
"por diversión en nuestro tiempo libre."
#: templates/home/home.html:61
#: templates/home/home.html:69
msgid "We'd like to continue with this journey, and you to be helping us."
msgstr "Nos gustaría seguir con ello, ¡y que tu te apuntes!"
#: templates/home/home.html:69
#: templates/home/home.html:77
msgid ""
"And remember that we all make this better. You want your favourite shop "
"added? We're missing some HUGE feature you'd like to see? Just want to get "
@ -792,6 +820,35 @@ msgstr ""
"favorita añadida? ¿Nos falta algo muy importante que te hará la vida mas "
"fácil? ¿Solo quieres hablar un rato? ¡Contacta con nosotros!"
#: templates/profile/main.html:11
#, python-format
msgid "Here you can browse over %(username)s's collection"
msgstr "Aquí puedes ver la colección de %(username)s"
#: templates/profile/main.html:19
msgid "Want everyone to see your collection? Spread the word!"
msgstr "¿Quieres presumir de colección? ¡Difunde la palabra!"
#: templates/profile/main.html:21
msgid "Look at my amiibo collection!"
msgstr "¡Mira mi colección de #amiibo!"
#: templates/profile/main.html:28
msgid "Have it"
msgstr "Lo tiene"
#: templates/profile/main.html:29
msgid "Want it"
msgstr "Lo quiere"
#: templates/profile/main.html:30
msgid "Trade it"
msgstr "Lo cambia"
#: templates/profile/main.html:48
msgid "Oooops, seems this user have nothing for that."
msgstr "Ups, ¡parece que no tiene nada por aquí!"
#: templates/socialaccount/connections.html:5
#: templates/socialaccount/connections.html:10
msgid "Account Connections"

View File

@ -58,6 +58,7 @@ INSTALLED_APPS = (
'amiibofindr.apps.amiibo',
'amiibofindr.apps.shop',
'amiibofindr.apps.home',
'amiibofindr.apps.profile',
'amiibofindr.apps.notifications',
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -42,7 +42,6 @@
<a class="item" href="{{ col.get_absolute_url_figures }}">{{ col.name }}</a>
{% endfor %}
</div>
</div>
<div class="ui dropdown item">
{% trans "Cards" %}
@ -60,6 +59,7 @@
<i class="icon user"></i> {{ user_display }}
<i class="dropdown icon"></i>
<div class="menu">
<a class="item" href="{% url 'profile:main' user.username %}">{% trans "My public profile" %}</a>
<a class="item" href="{% url 'account_change_password' %}">{% trans "Change password" %}</a>
<a class="item" href="{% url 'account_email' %}">{% trans "Emails" %}</a>
<div class="ui divider"></div>
@ -87,6 +87,7 @@
<div class="ui item">
{{ user_display }}
<div class="menu">
<a class="item" href="{% url 'profile:main' user.username %}">{% trans "My public profile" %}</a>
<a class="item" href="{% url 'account_change_password' %}">{% trans "Change password" %}</a>
<a class="item" href="{% url 'account_email' %}">{% trans "Emails" %}</a>
<a class="item" href="{% url 'account_logout' %}">{% trans "Log out" %}</a>

View File

@ -38,6 +38,14 @@
<p>{% blocktrans %}When logged in, you will see what amiibo you have, want or want to trade. Even when on lists or looking another person's amiibo list.{% endblocktrans %}
</div>
<div class="four wide column middle aligned">
<img src="{% static 'images/home/publicprofile.es.png' %}" class="ui circular bordered image">
</div>
<div class="four wide column">
<h2>{% trans 'Public profiles' %}</h2>
<p>{% blocktrans %}You will get a unique URL where you have all you collected, wanted and traded amiibo. For free! This way you will never forget what you have available.{% endblocktrans %}
</div>
<div class="four wide column middle aligned">
<img src="{% static 'images/home/buy.es.png' %}" class="ui circular bordered image">
</div>

View File

@ -0,0 +1,53 @@
{% extends "_layout.html" %}
{% load i18n %}
{% block main_content %}
<div class="ui page stackable grid">
<div class="sixteen wide column">
<h2 class="ui center aligned icon header">
<i class="circular users icon"></i>
{{ this_user.username }}
<div class="sub header">
{% blocktrans with username=this_user.username trimmed %}
Here you can browse over {{ username }}'s collection
{% endblocktrans %}
</div>
</h2>
{% if user.pk == this_user.pk %}
<div class="ui text-center">
<p>
{% trans "Want everyone to see your collection? Spread the word!" %}
</p>
<a href="https://twitter.com/share?text={% trans "Look at my amiibo collection!" %}" class="twitter-share-button" data-via="amiibofindr">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>
{% endif %}
</div>
<div class="eight wide column">
<div class="ui three item menu">
<a href="{% url 'profile:main-filter' this_user.username type 'own' %}" class="item {% if relation == 'own' %}active{% endif %}">{% trans "Have it" %}</a>
<a href="{% url 'profile:main-filter' this_user.username type 'want' %}" class="item {% if relation == 'want' %}active{% endif %}">{% trans "Want it" %}</a>
<a href="{% url 'profile:main-filter' this_user.username type 'trade'%}" class="item {% if relation == 'trade' %}active{% endif %}">{% trans "Trade it" %}</a>
</div>
</div>
<div class="eight wide column">
<div class="ui two item menu">
<a href="{% url 'profile:main-filter' this_user.username 'figures' relation %}" class="item {% if type == 'figures' %}active{% endif %}">{% trans "Figures" %}</a>
<a href="{% url 'profile:main-filter' this_user.username 'cards' relation %}" class="item {% if type == 'cards' %}active{% endif %}">{% trans "Cards" %}</a>
</div>
</div>
<div class="sixteen wide column">
{% if amiibo_list %}
<div class="ui {% if show == "cards" %}eight{% else %}five{% endif %} doubling cards" data-component="collectionList">
{% for amiibo in amiibo_list %}
{% include "amiibo/widgets/amiibo-card.html" with amiibo=amiibo %}
{% endfor %}
</div>
{% else %}
<div class="ui message info text-center">
{% trans "Oooops, seems this user have nothing for that." %}
</div>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -36,6 +36,7 @@ urlpatterns += i18n_patterns(
url(_(r'^account/'), include('allauth.urls')),
url(r'', include('amiibofindr.apps.amiibo.urls', namespace='amiibo')),
url(r'', include('amiibofindr.apps.home.urls', namespace='home')),
url(r'', include('amiibofindr.apps.profile.urls', namespace='profile')),
)
if settings.DEBUG: