From 5d7ec0415983cdf5f9fedc22de5c91b438c41a8e Mon Sep 17 00:00:00 2001 From: Zambom Date: Thu, 13 Apr 2017 20:59:14 -0300 Subject: [PATCH] Pendencies adjusts (part 2) --- amadeus/settings.py | 4 ++-- chat/migrations/0004_merge_20170413_2034.py | 16 ++++++++++++++++ news/migrations/0002_auto_20170413_2034.py | 26 ++++++++++++++++++++++++++ notifications/migrations/0003_notification_aware.py | 20 ++++++++++++++++++++ notifications/migrations/0004_remove_notification_aware.py | 19 +++++++++++++++++++ notifications/templates/notifications/_ajax_history.html | 8 +++++++- notifications/templates/notifications/_history.html | 8 +++++++- notifications/templatetags/notification_filters.py | 15 ++++++++++++--- notifications/utils.py | 5 +++++ 9 files changed, 114 insertions(+), 7 deletions(-) create mode 100644 chat/migrations/0004_merge_20170413_2034.py create mode 100644 news/migrations/0002_auto_20170413_2034.py create mode 100644 notifications/migrations/0003_notification_aware.py create mode 100644 notifications/migrations/0004_remove_notification_aware.py diff --git a/amadeus/settings.py b/amadeus/settings.py index 1245bc2..652ccb6 100644 --- a/amadeus/settings.py +++ b/amadeus/settings.py @@ -209,8 +209,8 @@ CRON_CLASSES = [ ] CRONJOBS = [ - ('1 */12 * * *', 'notifications.cron.notification_cron'), - ('1 */12 * * *', 'goals.cron.setgoals_cron') + ('0 0 * * *', 'notifications.cron.notification_cron'), + ('0 0 * * *', 'goals.cron.setgoals_cron') ] CHANNEL_LAYERS = { diff --git a/chat/migrations/0004_merge_20170413_2034.py b/chat/migrations/0004_merge_20170413_2034.py new file mode 100644 index 0000000..1544f63 --- /dev/null +++ b/chat/migrations/0004_merge_20170413_2034.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-04-13 23:34 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('chat', '0003_auto_20170407_2251'), + ('chat', '0003_auto_20170407_2154'), + ] + + operations = [ + ] diff --git a/news/migrations/0002_auto_20170413_2034.py b/news/migrations/0002_auto_20170413_2034.py new file mode 100644 index 0000000..6b1e427 --- /dev/null +++ b/news/migrations/0002_auto_20170413_2034.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-04-13 23:34 +from __future__ import unicode_literals + +from django.db import migrations, models +import news.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('news', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='news', + name='image', + field=models.ImageField(blank=True, upload_to='news/', validators=[news.models.validate_img_extension], verbose_name='News Image'), + ), + migrations.AlterField( + model_name='news', + name='title', + field=models.CharField(max_length=200, unique=True, verbose_name='Title'), + ), + ] diff --git a/notifications/migrations/0003_notification_aware.py b/notifications/migrations/0003_notification_aware.py new file mode 100644 index 0000000..e8ad4f1 --- /dev/null +++ b/notifications/migrations/0003_notification_aware.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-04-13 23:34 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('notifications', '0002_auto_20170130_1828'), + ] + + operations = [ + migrations.AddField( + model_name='notification', + name='aware', + field=models.BooleanField(default=False, verbose_name='Aware'), + ), + ] diff --git a/notifications/migrations/0004_remove_notification_aware.py b/notifications/migrations/0004_remove_notification_aware.py new file mode 100644 index 0000000..05c3fe4 --- /dev/null +++ b/notifications/migrations/0004_remove_notification_aware.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-04-13 23:40 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('notifications', '0003_notification_aware'), + ] + + operations = [ + migrations.RemoveField( + model_name='notification', + name='aware', + ), + ] diff --git a/notifications/templates/notifications/_ajax_history.html b/notifications/templates/notifications/_ajax_history.html index dae0518..2754611 100644 --- a/notifications/templates/notifications/_ajax_history.html +++ b/notifications/templates/notifications/_ajax_history.html @@ -44,6 +44,11 @@ + + {% trans 'Aware' %} + + + {% trans 'Observation' %} @@ -58,12 +63,13 @@ {{ notification.task.get_action_display }} {{ notification.task.end_date|date:"SHORT_DATE_FORMAT"|default:_('Not Informed') }} {{ notification.level|warning_msg }} + {{ notification.viewed|viewed_msg }} {{ notification|observation }} {% endfor %} {% else %} - {% trans 'No results found' %} + {% trans 'No results found' %} {% endif %} diff --git a/notifications/templates/notifications/_history.html b/notifications/templates/notifications/_history.html index 38c9471..d37d273 100644 --- a/notifications/templates/notifications/_history.html +++ b/notifications/templates/notifications/_history.html @@ -43,6 +43,11 @@ + + {% trans 'Aware' %} + + + {% trans 'Observation' %} @@ -57,12 +62,13 @@ {{ notification.task.get_action_display }} {{ notification.task.end_date|date:"SHORT_DATE_FORMAT"|default:_('Not Informed') }} {{ notification.level|warning_msg }} + {{ notification.viewed|viewed_msg }} {{ notification|observation }} {% endfor %} {% else %} - {% trans 'No results found' %} + {% trans 'No results found' %} {% endif %} diff --git a/notifications/templatetags/notification_filters.py b/notifications/templatetags/notification_filters.py index d9369b5..83755c6 100644 --- a/notifications/templatetags/notification_filters.py +++ b/notifications/templatetags/notification_filters.py @@ -34,6 +34,15 @@ def warning_msg(level): return msg +@register.filter(name = 'viewed_msg') +def viewed_msg(aware): + if aware: + msg = _('Yes') + else: + msg = _('No') + + return msg + @register.filter(name = 'done_percent') def done_percent(notification): users = get_resource_users(notification.task.resource) @@ -117,12 +126,12 @@ def observation(notification): if notification.level == 1: if notification.meta: - msg = _('Goal defined to task realization: %s')%(formats.date_format(notification.meta, "SHORT_DATETIME_FORMAT")) + msg = _('Goal defined to task realization: %s')%(formats.date_format(notification.meta.astimezone(timezone.get_current_timezone()), "SHORT_DATETIME_FORMAT")) elif notification.level == 2: if notification.meta: if notification.meta < timezone.now(): - msg = _('Goal defined to task realization: %s')%(formats.date_format(notification.meta, "SHORT_DATETIME_FORMAT")) + msg = _('Goal defined to task realization: %s')%(formats.date_format(notification.meta.astimezone(timezone.get_current_timezone()), "SHORT_DATETIME_FORMAT")) else: - msg = _('New goal defined to task realization: %s')%(formats.date_format(notification.meta, "SHORT_DATETIME_FORMAT")) + msg = _('New goal defined to task realization: %s')%(formats.date_format(notification.meta.astimezone(timezone.get_current_timezone()), "SHORT_DATETIME_FORMAT")) return msg \ No newline at end of file diff --git a/notifications/utils.py b/notifications/utils.py index 128e9c6..d13dacc 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -94,6 +94,11 @@ def get_order_by(order): return ["-level"] else: return ["level"] + elif "aware" in order: + if "-" in order: + return ["-viewed"] + else: + return ["viewed"] elif "obs" in order: if "-" in order: return ["-meta"] -- libgit2 0.21.2