Commit 319477b1b546c221948e505168ec1356a5c4d619

Authored by Zambom
1 parent 8e93a82c

Adding notification meta datepicker

amadeus/static/css/themes/green.css
... ... @@ -455,6 +455,11 @@ a.add-row {
455 455 background-color: initial !important;
456 456 }
457 457  
  458 +.popover {
  459 + background: #FFF;
  460 + color: #333;
  461 +}
  462 +
458 463 @media(max-width: 768px) {
459 464 .navbar .navbar-nav .dropdown .dropdown-menu li > a {
460 465 color: #333333 !important;
... ...
categories/migrations/0009_auto_20170130_1828.py 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2017-01-30 21:28
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.conf import settings
  6 +from django.db import migrations, models
  7 +
  8 +
  9 +class Migration(migrations.Migration):
  10 +
  11 + dependencies = [
  12 + ('categories', '0008_auto_20170126_1953'),
  13 + ]
  14 +
  15 + operations = [
  16 + migrations.AlterField(
  17 + model_name='category',
  18 + name='coordinators',
  19 + field=models.ManyToManyField(blank=True, related_name='Coordenadores', to=settings.AUTH_USER_MODEL),
  20 + ),
  21 + ]
... ...
links/migrations/0001_initial.py 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2017-01-30 21:28
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.db import migrations, models
  6 +import django.db.models.deletion
  7 +import django.utils.timezone
  8 +
  9 +
  10 +class Migration(migrations.Migration):
  11 +
  12 + initial = True
  13 +
  14 + dependencies = [
  15 + ('topics', '0007_auto_20170123_1911'),
  16 + ]
  17 +
  18 + operations = [
  19 + migrations.CreateModel(
  20 + name='Link',
  21 + fields=[
  22 + ('resource_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='topics.Resource')),
  23 + ('description', models.TextField(blank=True, verbose_name='simpler_description')),
  24 + ('link_url', models.URLField(verbose_name='Link_URL')),
  25 + ('initial_view', models.BooleanField(default=False, verbose_name='Initial View')),
  26 + ('initial_view_date', models.DateField(default=django.utils.timezone.now, verbose_name='Initial View Date')),
  27 + ('end_view', models.BooleanField(default=False, verbose_name='Initial View')),
  28 + ('end_view_date', models.DateField(default=django.utils.timezone.now, verbose_name='Initial View Date')),
  29 + ],
  30 + options={
  31 + 'verbose_name_plural': 'Links',
  32 + 'verbose_name': 'Link',
  33 + },
  34 + bases=('topics.resource',),
  35 + ),
  36 + ]
... ...
notifications/migrations/0002_auto_20170130_1828.py 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2017-01-30 21:28
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.db import migrations, models
  6 +
  7 +
  8 +class Migration(migrations.Migration):
  9 +
  10 + dependencies = [
  11 + ('notifications', '0001_initial'),
  12 + ]
  13 +
  14 + operations = [
  15 + migrations.AlterField(
  16 + model_name='notification',
  17 + name='meta',
  18 + field=models.DateTimeField(blank=True, null=True, verbose_name='Meta'),
  19 + ),
  20 + ]
... ...
notifications/models.py
... ... @@ -5,7 +5,7 @@ from users.models import User
5 5 from pendencies.models import Pendencies
6 6  
7 7 class Notification(models.Model):
8   - meta = models.DateField(_('Meta'), null = True, blank = True)
  8 + meta = models.DateTimeField(_('Meta'), null = True, blank = True)
9 9 task = models.ForeignKey(Pendencies, verbose_name = _('Task'), related_name = 'notification_pendencies')
10 10 user = models.ForeignKey(User, verbose_name = _('User'), related_name = 'notification_user')
11 11 level = models.IntegerField(_('Type'), choices = ((1, _('Type 1-A')), (2, _('Type 1-B')), (3, _('Type 2')), (4, _('Type 3'))))
... ...
notifications/templates/notifications/_history.html
... ... @@ -62,6 +62,9 @@
62 62 </tr>
63 63 {% endfor %}
64 64 {% else %}
  65 + <tr>
  66 + <td colspan="6" class="text-center">{% trans 'No results found' %}</td>
  67 + </tr>
65 68 {% endif %}
66 69 </tbody>
67 70 </table>
... ...
notifications/templates/notifications/_view.html
... ... @@ -42,7 +42,7 @@
42 42 </div>
43 43 </div>
44 44 <div class="row text-center">
45   - <a href="" class="btn btn-success btn-raised">
  45 + <a href="{% url notification.task.resource.access_link notification.task.resource.slug %}" class="btn btn-success btn-raised" {% if notification.task.resource.show_window %}target="_blank"{% endif %}>
46 46 {% if notification.level == 4 %}
47 47 {% trans 'Access the task' %}
48 48 {% else %}
... ... @@ -52,16 +52,83 @@
52 52  
53 53 {% if notification.level < 3 %}
54 54 <button class="btn btn-default no_button">{% trans 'or' %}</button>
55   - <a href="" class="btn btn-default btn-raised">
  55 + <button class="btn btn-default btn-raised" data-toggle="popover" data-trigger="focus" data-placement="right">
56 56 {% if notification.level == 1 %}
57 57 {% trans 'Define goal to realization' %}
58 58 {% else %}
59 59 {% trans 'Define new goal' %}
60 60 {% endif %}
61   - </a>
  61 + </button>
  62 +
  63 + <div class="popover">
  64 + <div class="popover-content">
  65 + <form role="form" method="post">
  66 + {% csrf_token %}
  67 + <div style="overflow:hidden;">
  68 + <div class="form-group">
  69 + <div class="row">
  70 + <div class="col-md-12">
  71 + <div class="datetimepicker"></div>
  72 + <input type="hidden" class="meta" name="meta" />
  73 + <input type="hidden" name="id" value="{{ notification.id }}">
  74 + </div>
  75 + </div>
  76 + </div>
  77 + </div>
  78 + </form>
  79 + </div>
  80 + <div class="popover-footer">
  81 + <button type="button" class="btn btn-raised btn-sm btn-primary save pull-left">
  82 + {% trans 'Save Goal' %}
  83 + </button>
  84 + <button type="button" class="btn btn-default btn-sm btn-raised cancel pull-right">
  85 + {% trans 'Cancel' %}
  86 + </button>
  87 + </div>
  88 + </div>
62 89 {% endif %}
63 90 </div>
64 91 </div>
65 92 </div>
66 93 </div>
67   -</div>
68 94 \ No newline at end of file
  95 +</div>
  96 +<script>
  97 +$(document).ready(function(){
  98 + var locale = navigator.language || navigator.userLanguage;
  99 +
  100 + $('[data-toggle="popover"]').popover({
  101 + html: true,
  102 + content: function () {
  103 + return $(".popover").html();
  104 + }
  105 + }).on('shown.bs.popover', function (e) {
  106 + if($(this).is(e.target)){
  107 + var popover = $(this),
  108 + datetime = popover.parent().find('.datetimepicker'),
  109 + form = popover.parent().find('form'),
  110 + cancel = popover.parent().find('.cancel'),
  111 + save = popover.parent().find('.save');
  112 +
  113 + if (typeof(datetime.data("DateTimePicker")) != "undefined") {
  114 + datetime.data("DateTimePicker").destroy();
  115 + }
  116 +
  117 + datetime.datetimepicker({
  118 + locale: locale,
  119 + inline: true,
  120 + sideBySide: false
  121 + });
  122 +
  123 + cancel.on("click", function () {
  124 + popover.popover('hide');
  125 + });
  126 +
  127 + save.on("click", function () {
  128 + var field = form.find('.meta');
  129 + field.val(datetime.data('date'));
  130 + console.log(form.serialize());
  131 + });
  132 + }
  133 + });
  134 +});
  135 +</script>
69 136 \ No newline at end of file
... ...
notifications/utils.py
... ... @@ -28,6 +28,7 @@ def set_notifications():
28 28 for user in users:
29 29 prev_notify = Notification.objects.filter(user = user, task = pendency).order_by("-creation_date")
30 30 notify_type = 1
  31 + meta = None
31 32  
32 33 if prev_notify.count() > 0:
33 34 last_notify = prev_notify[0]
... ... @@ -36,9 +37,10 @@ def set_notifications():
36 37 continue
37 38  
38 39 if last_notify.meta:
39   - if last_notify.creation_date < date.today() < last_notify.meta:
  40 + if last_notify.creation_date < date.today() < last_notify.meta.date():
40 41 continue
41 42  
  43 + meta = last_notify.meta
42 44 notify_type = 2
43 45  
44 46 has_action = Log.objects.filter(user_id = user.id, action = pend_action, resource = resource_type, context__contains = {resource_key: resource_id}, datetime__date__gte = subject_begin_date).exists()
... ... @@ -51,12 +53,12 @@ def set_notifications():
51 53 if pendency.limit_date:
52 54 if timezone.now() > pendency.limit_date:
53 55 notify_type = 4
54   -
55 56  
56 57 notification = Notification()
57 58 notification.user = user
58 59 notification.level = notify_type
59 60 notification.task = pendency
  61 + notification.meta = meta
60 62  
61 63 notification.save()
62 64  
... ...
subjects/migrations/0014_auto_20170130_1828.py 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2017-01-30 21:28
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.db import migrations, models
  6 +
  7 +
  8 +class Migration(migrations.Migration):
  9 +
  10 + dependencies = [
  11 + ('subjects', '0013_auto_20170120_1610'),
  12 + ]
  13 +
  14 + operations = [
  15 + migrations.AlterField(
  16 + model_name='subject',
  17 + name='tags',
  18 + field=models.ManyToManyField(blank=True, to='subjects.Tag', verbose_name='tags'),
  19 + ),
  20 + ]
... ...
topics/templates/topics/list.html
... ... @@ -34,7 +34,7 @@
34 34 </div>
35 35 </div>
36 36 </div>
37   - <div id="{{topic.slug}}" class="panel-collapse collapse category-panel-content">
  37 + <div id="{{topic.slug}}" class="panel-collapse collapse category-panel-content topic-panel">
38 38 <input type="hidden" class="id_inp" name="id" value="{{ topic.id }}" />
39 39 <input type="hidden" class="order_inp" name="order" value="{{ topic.order }}" />
40 40  
... ...