Feat: Profile timeline
This commit is contained in:
parent
223eca0259
commit
8ad0e87c18
|
@ -249,6 +249,17 @@ class UserHaveVolume(models.Model):
|
|||
volume = models.ForeignKey(Volume, related_name='owned_by')
|
||||
date = models.DateTimeField(_('Date'), auto_now_add=True)
|
||||
|
||||
_timeline_message = _('%(volume)s added to collection')
|
||||
_event_type = 'have'
|
||||
|
||||
@property
|
||||
def event_type(self):
|
||||
return self._event_type
|
||||
|
||||
@property
|
||||
def timeline_message(self):
|
||||
return self._timeline_message % {'volume': self.volume}
|
||||
|
||||
def __unicode__(self):
|
||||
return "{} {} {}".format(
|
||||
self.user.username,
|
||||
|
@ -266,6 +277,17 @@ class UserWishlistVolume(models.Model):
|
|||
volume = models.ForeignKey(Volume, related_name='wishlisted_by')
|
||||
date = models.DateTimeField(_('Date'), auto_now_add=True)
|
||||
|
||||
_timeline_message = _('%(volume)s wishlisted')
|
||||
_event_type = 'wishlist'
|
||||
|
||||
@property
|
||||
def event_type(self):
|
||||
return self._event_type
|
||||
|
||||
@property
|
||||
def timeline_message(self):
|
||||
return self._timeline_message % {'volume': self.volume}
|
||||
|
||||
def __unicode__(self):
|
||||
return "{} {} {}".format(
|
||||
self.user.username,
|
||||
|
@ -283,6 +305,17 @@ class UserReadVolume(models.Model):
|
|||
volume = models.ForeignKey(Volume, related_name='read_by')
|
||||
date = models.DateTimeField(_('Date'), auto_now_add=True)
|
||||
|
||||
_timeline_message = _('%(volume)s marked as read')
|
||||
_event_type = 'read'
|
||||
|
||||
@property
|
||||
def event_type(self):
|
||||
return self._event_type
|
||||
|
||||
@property
|
||||
def timeline_message(self):
|
||||
return self._timeline_message % {'volume': self.volume}
|
||||
|
||||
def __unicode__(self):
|
||||
return "{} {} {}".format(
|
||||
self.user.username,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from itertools import chain
|
||||
from django.views.generic import View
|
||||
from django.template import RequestContext
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
|
@ -9,7 +10,9 @@ from django.contrib.auth import login
|
|||
|
||||
from .forms import LoginForm
|
||||
from .models import User
|
||||
from shelfzilla.apps.manga.models import UserReadVolume
|
||||
from shelfzilla.apps.manga.models import (
|
||||
UserReadVolume, UserHaveVolume, UserWishlistVolume
|
||||
)
|
||||
|
||||
|
||||
class LoginView(View):
|
||||
|
@ -83,8 +86,16 @@ class UserProfileView(View):
|
|||
return render_to_response(template, context_instance=ctx)
|
||||
|
||||
def get_summary(self, request, context, user):
|
||||
context['timeline'] = UserReadVolume.objects.filter(user=user).\
|
||||
order_by('-date')
|
||||
owned_list = UserHaveVolume.objects.filter(user=user)
|
||||
wishlisted_list = UserWishlistVolume.objects.filter(user=user)
|
||||
read_list = UserReadVolume.objects.filter(user=user)
|
||||
|
||||
timeline = sorted(
|
||||
chain(owned_list, wishlisted_list, read_list),
|
||||
key=lambda model: model.date,
|
||||
reverse=True
|
||||
)[:20]
|
||||
context['timeline'] = timeline
|
||||
return context
|
||||
|
||||
def get_context_from_section(self, request, section, context, user):
|
||||
|
|
Binary file not shown.
|
@ -8,8 +8,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-09-08 17:46+0200\n"
|
||||
"PO-Revision-Date: 2014-09-08 17:46+0200\n"
|
||||
"POT-Creation-Date: 2014-09-09 01:10+0200\n"
|
||||
"PO-Revision-Date: 2014-09-09 01:11+0200\n"
|
||||
"Last-Translator: Felipe Martin <fmartingr@me.com>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -219,19 +219,34 @@ msgstr "Idioma"
|
|||
msgid "Languages"
|
||||
msgstr "Idiomas"
|
||||
|
||||
#: apps/manga/models.py:250 apps/manga/models.py:267 apps/manga/models.py:284
|
||||
#: apps/manga/models.py:250 apps/manga/models.py:273 apps/manga/models.py:296
|
||||
msgid "Date"
|
||||
msgstr "Fecha"
|
||||
|
||||
#: apps/manga/models.py:255
|
||||
#: apps/manga/models.py:252
|
||||
#, python-format
|
||||
msgid "%(volume)s added to collection"
|
||||
msgstr "%(volume)s añadido a la colección"
|
||||
|
||||
#: apps/manga/models.py:261
|
||||
msgid "have"
|
||||
msgstr "tiene"
|
||||
|
||||
#: apps/manga/models.py:272
|
||||
#: apps/manga/models.py:275
|
||||
#, python-format
|
||||
msgid "%(volume)s wishlisted"
|
||||
msgstr "%(volume)s añadido a deseados"
|
||||
|
||||
#: apps/manga/models.py:284
|
||||
msgid "wants"
|
||||
msgstr "quiere"
|
||||
|
||||
#: apps/manga/models.py:289
|
||||
#: apps/manga/models.py:298
|
||||
#, python-format
|
||||
msgid "%(volume)s marked as read"
|
||||
msgstr "%(volume)s marcado como leído"
|
||||
|
||||
#: apps/manga/models.py:307
|
||||
msgid "have read"
|
||||
msgstr "ha leído"
|
||||
|
||||
|
@ -286,11 +301,11 @@ msgstr "Esta cuenta está desactivada."
|
|||
msgid "User with those credentials was not found."
|
||||
msgstr "No se ha encontrado un usuario con esos credenciales."
|
||||
|
||||
#: apps/users/views.py:40
|
||||
#: apps/users/views.py:44
|
||||
msgid "Logged in successfully."
|
||||
msgstr "Has accedido correctamente."
|
||||
|
||||
#: apps/users/views.py:59
|
||||
#: apps/users/views.py:63
|
||||
msgid "Logged out successfully"
|
||||
msgstr "Sesión finalizada."
|
||||
|
||||
|
@ -462,16 +477,20 @@ msgstr "Mis preferencias"
|
|||
msgid "Achievements"
|
||||
msgstr "Logros"
|
||||
|
||||
#: themes/bootflat/templates/users/profile/summary.html:14
|
||||
#: themes/bootflat/templates/users/profile/summary.html:11
|
||||
msgid "Today"
|
||||
msgstr "Hoy"
|
||||
|
||||
#: themes/bootflat/templates/users/profile/summary.html:17
|
||||
#, python-format
|
||||
msgid "(%(count)s read)"
|
||||
msgstr "(%(count)s leídos)"
|
||||
|
||||
#: themes/bootflat/templates/users/profile/summary.html:16
|
||||
#: themes/bootflat/templates/users/profile/summary.html:19
|
||||
msgid "Volumes owned"
|
||||
msgstr "Volúmenes"
|
||||
|
||||
#: themes/bootflat/templates/users/profile/summary.html:22
|
||||
#: themes/bootflat/templates/users/profile/summary.html:26
|
||||
msgid "Volumes wishlisted"
|
||||
msgstr "Deseados"
|
||||
|
||||
|
|
|
@ -6,56 +6,56 @@
|
|||
{% endcomment %}
|
||||
|
||||
{% block profile_content %}
|
||||
<div class="row text-center">
|
||||
<div class="col-sm-6">
|
||||
<div class="well">
|
||||
<h2 class="no-margin-top">
|
||||
{{ item.have_volumes.count }}
|
||||
<small>{% blocktrans with count=item.read_volumes.count %}({{ count }} read){% endblocktrans %}</small>
|
||||
</h2>
|
||||
{% trans "Volumes owned" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="well">
|
||||
<h2 class="no-margin-top">{{ item.wishlisted_volumes.count }}</h2>
|
||||
{% trans "Volumes wishlisted" %}
|
||||
</div>
|
||||
</div>
|
||||
{% comment %}
|
||||
<div class="col-sm-3">
|
||||
<div class="well">
|
||||
<h2 class="no-margin-top">--</h2>
|
||||
Other
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div class="well">
|
||||
<h2 class="no-margin-top">--</h2>
|
||||
Other
|
||||
</div>
|
||||
</div>
|
||||
{% endcomment %}
|
||||
</div>
|
||||
<div class="well">
|
||||
<p>Interesting. No, wait, the other thing: tedious. What are you hacking off? Is it my torso?! 'It is!' My precious torso! Yes, if you make it look like an electrical fire. When you do things right, people won't be sure you've done anything at all. Take me to your leader! Ven ve voke up, ve had zese wodies.</p>
|
||||
</div>
|
||||
|
||||
<div class="timeline">
|
||||
<dl>
|
||||
{% for event in timeline %}
|
||||
<dt>{{ event.date }}</dt>
|
||||
<dd class="pos-right clearfix">
|
||||
<div class="circ"></div>
|
||||
<div class="time">Apr 14</div>
|
||||
<div class="events">
|
||||
<div class="events-body">
|
||||
<h4 class="events-heading">Marked as read</h4>
|
||||
{% include "manga/series/includes/volume.html" with volume=event.volume user=user show_publisher=True type='slim' %}
|
||||
<dl class="text-center">
|
||||
<dt>{% trans "Today" %}</dt>
|
||||
<dd class="pos-left">
|
||||
<div class="circ"></div>
|
||||
<div class="events">
|
||||
<h2 class="no-margin-top">
|
||||
{{ item.have_volumes.count }}
|
||||
<small>{% blocktrans with count=item.read_volumes.count %}({{ count }} read){% endblocktrans %}</small>
|
||||
</h2>
|
||||
<p>{% trans "Volumes owned" %}</p>
|
||||
</div>
|
||||
</dd>
|
||||
<dd class="pos-right clearfix">
|
||||
<div class="circ"></div>
|
||||
<div class="events">
|
||||
<h2 class="no-margin-top">{{ item.wishlisted_volumes.count }}</h2>
|
||||
<p>{% trans "Volumes wishlisted" %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
{% endfor %}
|
||||
<dl>
|
||||
{% regroup timeline by date|date:'F, Y' as timeline_dates %}
|
||||
{% for dates in timeline_dates %}
|
||||
<dt>{{ dates.grouper }}</dt>
|
||||
{% regroup dates.list by date|date:'d' as month_events %}
|
||||
{% for day in month_events %}
|
||||
<dd class="pos-right clearfix">
|
||||
<div class="circ"></div>
|
||||
<div class="time">{{ day.grouper }}</div>
|
||||
<div class="events">
|
||||
{% for event in day.list %}
|
||||
<div class="events-body">
|
||||
<h4 class="events-heading">
|
||||
{% if event.event_type == 'read' %}
|
||||
<i class="glyphicon glyphicon-eye-open"></i>
|
||||
{% elif event.event_type == 'have' %}
|
||||
<i class="glyphicon glyphicon-ok"></i>
|
||||
{% elif event.event_type == 'wishlist' %}
|
||||
<i class="glyphicon glyphicon-star"></i>
|
||||
{% endif %}
|
||||
{{ event.timeline_message }}
|
||||
</h4>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</dd>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
<dt>...</dt>
|
||||
</dl>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
Reference in New Issue