From 577aa2b6ecba5d68e8d87dacd2be0595d4959539 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Wed, 12 Oct 2016 07:32:37 +0200 Subject: [PATCH] mails: add reference field, only for alfortville flavour (#13549) --- .../alfortville/templates/alfortville/dg-table.html | 2 ++ .../templates/alfortville/mail-table-waiting.html | 2 ++ welco/sources/mail/forms.py | 2 ++ welco/sources/mail/migrations/0011_mail_reference.py | 19 +++++++++++++++++++ welco/sources/mail/models.py | 3 +++ welco/sources/mail/templates/welco/mail_home.html | 1 + welco/sources/mail/templates/welco/mail_summary.html | 4 ++++ welco/sources/mail/views.py | 1 + welco/static/css/style.css | 6 +++++- welco/static/js/welco.js | 4 ++++ 10 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 welco/sources/mail/migrations/0011_mail_reference.py diff --git a/welco/contrib/alfortville/templates/alfortville/dg-table.html b/welco/contrib/alfortville/templates/alfortville/dg-table.html index c2cc936..61a433c 100644 --- a/welco/contrib/alfortville/templates/alfortville/dg-table.html +++ b/welco/contrib/alfortville/templates/alfortville/dg-table.html @@ -19,6 +19,7 @@ {% trans 'Scan Date' %} {% trans 'Post Date' %} + {% trans 'Reference' %} {% trans 'Subject' %} {% trans 'User' %} {% trans 'Category' %} @@ -30,6 +31,7 @@ {{object.creation_timestamp|date:"d F Y"|lower}} {{object.post_date|date:"d F Y"|lower}} + {{object.reference|default:'-'}} {{object.subject|default:'-'}} {{object.contact_name }} {{object.categories|join:", " }} diff --git a/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html b/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html index b131b74..7b3f2dc 100644 --- a/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html +++ b/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html @@ -14,6 +14,7 @@ {% trans 'Scan Date' %} {% trans 'Post Date' %} + {% trans 'Reference' %} {% trans 'Subject' %} {% trans 'Related Forms' %} {% trans 'Status' %} @@ -23,6 +24,7 @@ {{object.creation_timestamp|date:"d F Y"|lower}} {{object.post_date|default:'-'}} + {{object.reference|default:'-'}} {{object.subject|default:'-'}} {% for association in object.associations.all %}{{association.formdef_name}}{% if not forloop.last %}, {% endif %}{% endfor %} {% if object.status == 'done-qualif' %}En attente de validation DGS diff --git a/welco/sources/mail/forms.py b/welco/sources/mail/forms.py index f550445..a00f435 100644 --- a/welco/sources/mail/forms.py +++ b/welco/sources/mail/forms.py @@ -21,9 +21,11 @@ from django.conf import settings class MailQualificationForm(forms.Form): post_date = forms.DateTimeField(label=_('Post Date (*)'), required=False) registered_mail_number = forms.CharField(label=_('Registered Mail Number'), required=False) + reference = forms.CharField(label=_('Reference'), required=False, widget=forms.HiddenInput) subject = forms.CharField(label=_('Subject'), required=False, widget=forms.HiddenInput) def __init__(self, *args, **kwargs): super(MailQualificationForm, self).__init__(*args, **kwargs) if 'alfortville' in getattr(settings, 'FLAVOURS', []): + self.fields['reference'].widget = forms.TextInput() self.fields['subject'].widget = forms.TextInput() diff --git a/welco/sources/mail/migrations/0011_mail_reference.py b/welco/sources/mail/migrations/0011_mail_reference.py new file mode 100644 index 0000000..eaf5414 --- /dev/null +++ b/welco/sources/mail/migrations/0011_mail_reference.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mail', '0010_mail_subject'), + ] + + operations = [ + migrations.AddField( + model_name='mail', + name='reference', + field=models.CharField(max_length=30, null=True, verbose_name='Reference'), + ), + ] diff --git a/welco/sources/mail/models.py b/welco/sources/mail/models.py index 56cf1a8..cb3480d 100644 --- a/welco/sources/mail/models.py +++ b/welco/sources/mail/models.py @@ -42,6 +42,7 @@ class Mail(models.Model): note = models.TextField(_('Note'), null=True) # used only if settings.FLAVOURS contains 'alfortville' + reference = models.CharField(_('Reference'), null=True, max_length=30) subject = models.CharField(_('Subject'), null=True, max_length=200) scanner_category = models.CharField(max_length=100, blank=True, null=True) @@ -66,6 +67,7 @@ class Mail(models.Model): 'registered_mail_number': self.registered_mail_number, } if 'alfortville' in getattr(settings, 'FLAVOURS', []): + data['reference'] = self.reference data['subject'] = self.subject return self.get_qualification_form_class()(data) @@ -120,6 +122,7 @@ class Mail(models.Model): 'registered_mail_number': self.registered_mail_number, } if 'alfortville' in getattr(settings, 'FLAVOURS', []): + context['reference'] = self.reference context['subject'] = self.subject return context diff --git a/welco/sources/mail/templates/welco/mail_home.html b/welco/sources/mail/templates/welco/mail_home.html index c29dfc9..b8571cb 100644 --- a/welco/sources/mail/templates/welco/mail_home.html +++ b/welco/sources/mail/templates/welco/mail_home.html @@ -11,6 +11,7 @@ data-pdf-href="{{ mail.content.url }}" data-post-date="{{ mail.post_date|date:"d/m/Y" }}" data-registered-mail-number="{{ mail.registered_mail_number|default:"" }}" + data-reference="{{ mail.reference|default:"" }}" data-subject="{{ mail.subject|default:"" }}" >{{ mail.creation_timestamp|date:"d/m/Y" }} {{mail.contact_name}} diff --git a/welco/sources/mail/templates/welco/mail_summary.html b/welco/sources/mail/templates/welco/mail_summary.html index 0e6d9b2..c401312 100644 --- a/welco/sources/mail/templates/welco/mail_summary.html +++ b/welco/sources/mail/templates/welco/mail_summary.html @@ -7,6 +7,10 @@

{% trans "Registered Mail Number:" %} {{object.registered_mail_number}}

{% endif %} +{% if object.reference %} +

{% trans "Reference:" %} {{object.reference}}

+{% endif %} + {% if object.subject %}

{% trans "Subject:" %} {{object.subject}}

{% endif %} diff --git a/welco/sources/mail/views.py b/welco/sources/mail/views.py index c7322d0..7acbb89 100644 --- a/welco/sources/mail/views.py +++ b/welco/sources/mail/views.py @@ -88,6 +88,7 @@ def qualification_save(request, *args, **kwargs): if form.is_valid(): mail.post_date = form.cleaned_data['post_date'] mail.registered_mail_number = form.cleaned_data['registered_mail_number'] + mail.reference = form.cleaned_data['reference'] mail.subject = form.cleaned_data['subject'] mail.save() return HttpResponseRedirect(reverse('qualif-zone') + diff --git a/welco/static/css/style.css b/welco/static/css/style.css index 0647e7f..080c48b 100644 --- a/welco/static/css/style.css +++ b/welco/static/css/style.css @@ -480,8 +480,12 @@ form#note textarea { padding: 0.5ex 0.5ex; } +#source-mainarea input#id_reference { + width: 10em; +} + #source-mainarea input#id_subject { - width: 40em; + width: 30em; } #source-mainarea button { diff --git a/welco/static/js/welco.js b/welco/static/js/welco.js index fb2f806..549ef97 100644 --- a/welco/static/js/welco.js +++ b/welco/static/js/welco.js @@ -79,6 +79,7 @@ $(function() { $(this).addClass('active'); $('#id_post_date').val($(this).data('post-date')); $('#id_registered_mail_number').val($(this).data('registered-mail-number')); + $('#id_reference').val($(this).data('reference')); $('#id_subject').val($(this).data('subject')); var source_pk = $('div.source .active[data-source-pk]').data('source-pk'); $('#postit > div.content').data('url', $('#postit > div.content').data('base-url') + '?mail=' + source_pk); @@ -213,12 +214,14 @@ $(function() { $('.document').delegate('button.save', 'click', function() { var post_date = $('#id_post_date').val(); var registered_mail_number = $('#id_registered_mail_number').val(); + var reference = $('#id_reference').val(); var subject = $('#id_subject').val(); var source_type = $('div.source div[data-source-type]').data('source-type'); var source_pk = $('div.source .active[data-source-pk]').data('source-pk'); $.ajax({url: $(this).data('action-url'), data: {post_date: post_date, registered_mail_number: registered_mail_number, + reference: reference, subject: subject, source_type: source_type, source_pk: source_pk}, @@ -227,6 +230,7 @@ $(function() { success: function(data) { $('div.source .active').data('post-date', post_date); $('div.source .active').data('registered-mail-number', registered_mail_number); + $('div.source .active').data('reference', reference); $('div.source .active').data('subject', subject); $('#source-mainarea form').effect('highlight'); if ($('#id_post_date').length && !$('#id_post_date').val()) { -- 2.9.3