From f77d87b3bb28d58eaba0bc66f7ff06d28c9d9434 Mon Sep 17 00:00:00 2001 From: Matheus Fernandes Date: Tue, 27 Oct 2015 14:22:23 -0200 Subject: [PATCH] Updated search presentation --- colab/accounts/templates/accounts/user_search_preview.html | 17 +++++++++++------ colab/accounts/templatetags/date_format.py | 20 ++++++++++++++++++++ colab/search/templates/message-preview.html | 1 - colab/search/templatetags/search_preview_templates.py | 3 ++- colab/super_archives/templates/superarchives/thread_search_preview.html | 13 ++++++------- 5 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 colab/accounts/templatetags/date_format.py diff --git a/colab/accounts/templates/accounts/user_search_preview.html b/colab/accounts/templates/accounts/user_search_preview.html index ddbb3ec..213ca18 100644 --- a/colab/accounts/templates/accounts/user_search_preview.html +++ b/colab/accounts/templates/accounts/user_search_preview.html @@ -1,7 +1,12 @@ -{% load i18n tz highlight gravatar %} +{% load i18n tz highlight gravatar date_format %} -
-{% gravatar result.email 50 %} {{ result.name }} -Data joined: {{ result.date_joined }}
-Registred in: User
-
+
+
+ {% gravatar result.email 50 %} +
+
+ {{ result.name }}
+ {% trans "Date joined" %}: {% date_format result.date_joined %}
+ {% trans "Registred in" %}: {% trans "User" %}
+
+
\ No newline at end of file diff --git a/colab/accounts/templatetags/date_format.py b/colab/accounts/templatetags/date_format.py new file mode 100644 index 0000000..cf00865 --- /dev/null +++ b/colab/accounts/templatetags/date_format.py @@ -0,0 +1,20 @@ +from django import template +from django.utils.translation import ugettext as _ +register = template.Library() + + +@register.simple_tag(takes_context=True) +def date_format(context, date): + formatted_date = _('%(m)s %(d)s %(y)s' % {'m': date.strftime('%B'), + 'd': date.day, + 'y': date.year}) + return formatted_date + + +@register.simple_tag(takes_context=True) +def datetime_format(context, date): + formatted_date = date_format(context, date) + formatted_time = _('%(hour)s:%(min)s' % {'hour': date.hour, + 'min': date.strftime('%I')}) + formatted_datetime = _('%s at %s' % (formatted_date, formatted_time)) + return formatted_datetime diff --git a/colab/search/templates/message-preview.html b/colab/search/templates/message-preview.html index c4fca7a..fa01003 100644 --- a/colab/search/templates/message-preview.html +++ b/colab/search/templates/message-preview.html @@ -1,4 +1,3 @@ {% load i18n tz highlight search_preview_templates %} - {% get_search_preview_templates result as template_target %} {% include template_target %} diff --git a/colab/search/templatetags/search_preview_templates.py b/colab/search/templatetags/search_preview_templates.py index 99deea4..d43c1c0 100644 --- a/colab/search/templatetags/search_preview_templates.py +++ b/colab/search/templatetags/search_preview_templates.py @@ -3,6 +3,7 @@ from django import template register = template.Library() + @register.assignment_tag def get_search_preview_templates(model_indexed): app_type = model_indexed.type @@ -13,6 +14,6 @@ def get_search_preview_templates(model_indexed): elif app_type in "thread": app_name = "superarchives" else: - app_name, app_type = app_type.split("_",1) + app_name, app_type = app_type.split("_", 1) return "{}/{}_search_preview.html".format(app_name, app_type) diff --git a/colab/super_archives/templates/superarchives/thread_search_preview.html b/colab/super_archives/templates/superarchives/thread_search_preview.html index c07c6a8..54571a5 100644 --- a/colab/super_archives/templates/superarchives/thread_search_preview.html +++ b/colab/super_archives/templates/superarchives/thread_search_preview.html @@ -1,9 +1,8 @@ -{% load i18n tz highlight %} +{% load i18n tz highlight date_format %} -
-

{{ result.title }}

-{{ result.latest_description|truncatewords:"85" }} -
-{{ result.modified_by }} - {{ result.modified |date:"d \d\e F \d\e Y" }} -
+
+ {% datetime_format result.modified %} - {{ result.modified_by }}
+

{{ result.title }}

+ + {{ result.latest_description|truncatewords:"85" }}
-- libgit2 0.21.2