From 26667258c060a912e01a152b3208f24b61f55bd6 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Tue, 14 Jun 2016 15:34:04 +0200 Subject: [PATCH] mails: add subject field (#11289) --- .../alfortville/templates/alfortville/dg-table.html | 4 ++++ .../templates/alfortville/mail-table-waiting.html | 2 ++ welco/sources/mail/forms.py | 2 ++ welco/sources/mail/migrations/0010_mail_subject.py | 19 +++++++++++++++++++ welco/sources/mail/models.py | 5 ++++- 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 | 4 ++++ welco/static/js/welco.js | 4 ++++ 10 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 welco/sources/mail/migrations/0010_mail_subject.py diff --git a/welco/contrib/alfortville/templates/alfortville/dg-table.html b/welco/contrib/alfortville/templates/alfortville/dg-table.html index e11f5fb..73a7c46 100644 --- a/welco/contrib/alfortville/templates/alfortville/dg-table.html +++ b/welco/contrib/alfortville/templates/alfortville/dg-table.html @@ -18,6 +18,8 @@ + + @@ -27,6 +29,8 @@ {% for object in mails %} + + diff --git a/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html b/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html index 8e3911f..b131b74 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 @@ + @@ -22,6 +23,7 @@ +
{% trans 'Scan Date' %}{% trans 'Post Date' %}{% trans 'Subject' %} {% trans 'User' %} {% trans 'Category' %} {% trans 'Related Forms' %}
{{object.creation_timestamp|date:"d F Y"|lower}}{{object.post_date|date:"d F Y"|lower}}{{object.subject|default:'-'}} {{object.contact_name }} {{object.categories|join:", " }} {% for association in object.associations.all %}{{association.formdef_name}}{% if not forloop.last %}, {% endif %}{% endfor %}
{% trans 'Scan Date' %} {% trans 'Post Date' %}{% trans 'Subject' %} {% trans 'Related Forms' %} {% trans 'Status' %}
{{object.creation_timestamp|date:"d F Y"|lower}} {{object.post_date|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 {% elif object.status == 'done-dgs' %}En attente de validation DGA diff --git a/welco/sources/mail/forms.py b/welco/sources/mail/forms.py index ef74d2a..b76d964 100644 --- a/welco/sources/mail/forms.py +++ b/welco/sources/mail/forms.py @@ -18,5 +18,7 @@ from django import forms from django.utils.translation import ugettext_lazy as _ class MailQualificationForm(forms.Form): + subject = forms.CharField(label='', required=False, + widget=forms.TextInput(attrs={'placeholder': _('Subject')})) post_date = forms.DateTimeField(label=_('Post Date (*)'), required=False) registered_mail_number = forms.CharField(label=_('Registered Mail Number'), required=False) diff --git a/welco/sources/mail/migrations/0010_mail_subject.py b/welco/sources/mail/migrations/0010_mail_subject.py new file mode 100644 index 0000000..e7642f2 --- /dev/null +++ b/welco/sources/mail/migrations/0010_mail_subject.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', '0009_mail_scanner_category'), + ] + + operations = [ + migrations.AddField( + model_name='mail', + name='subject', + field=models.CharField(max_length=200, null=True, verbose_name='Subject'), + ), + ] diff --git a/welco/sources/mail/models.py b/welco/sources/mail/models.py index 64e5c6b..c013304 100644 --- a/welco/sources/mail/models.py +++ b/welco/sources/mail/models.py @@ -38,6 +38,7 @@ class Mail(models.Model): post_date = models.DateField(_('Post Date'), null=True) registered_mail_number = models.CharField(_('Registered Mail Number'), null=True, max_length=50) + subject = models.CharField(_('Subject'), null=True, max_length=200) note = models.TextField(_('Note'), null=True) scanner_category = models.CharField(max_length=100, blank=True, null=True) @@ -59,7 +60,8 @@ class Mail(models.Model): def get_qualification_form(self): return self.get_qualification_form_class()({ 'post_date': self.post_date, - 'registered_mail_number': self.registered_mail_number}) + 'registered_mail_number': self.registered_mail_number, + 'subject': self.subject}) @classmethod def get_qualification_form_submit_url(cls): @@ -110,6 +112,7 @@ class Mail(models.Model): 'channel': 'mail', 'post_date': self.post_date and self.post_date.strftime('%Y-%m-%d'), 'registered_mail_number': self.registered_mail_number, + 'subject': self.subject, } diff --git a/welco/sources/mail/templates/welco/mail_home.html b/welco/sources/mail/templates/welco/mail_home.html index 5f07939..764979f 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="{% firstof mail.registered_mail_number %}" + data-subject="{% firstof mail.subject %}" >{{ mail.creation_timestamp|date:"d/m/Y" }} {{mail.contact_name}} {% for association in mail.associations.all %} diff --git a/welco/sources/mail/templates/welco/mail_summary.html b/welco/sources/mail/templates/welco/mail_summary.html index 7ba521a..0e6d9b2 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.subject %} +

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

+{% endif %} +

diff --git a/welco/sources/mail/views.py b/welco/sources/mail/views.py index c420b0b..7d924c2 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.subject = form.cleaned_data['subject'] mail.save() return HttpResponseRedirect(reverse('qualif-zone') + '?source_type=%s&source_pk=%s' % (request.POST['source_type'], diff --git a/welco/static/css/style.css b/welco/static/css/style.css index 1845e8e..2a98090 100644 --- a/welco/static/css/style.css +++ b/welco/static/css/style.css @@ -474,6 +474,10 @@ form#note textarea { padding: 0.5ex 0.5ex; } +#source-mainarea input#id_subject { + width: 40em; +} + #source-mainarea button { position: relative; top: -2px; diff --git a/welco/static/js/welco.js b/welco/static/js/welco.js index de70454..32cd7ce 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_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); $('#postit').trigger('welco:load-mail-note'); @@ -212,11 +213,13 @@ $(function() { $('.document').delegate('button.save', 'click', function() { var post_date = $('#id_post_date').val(); var registered_mail_number = $('#id_registered_mail_number').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, + subject: subject, source_type: source_type, source_pk: source_pk}, method: 'POST', @@ -224,6 +227,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('subject', subject); $('#source-mainarea form').effect('highlight'); if ($('#id_post_date').length && !$('#id_post_date').val()) { $('div.qualif button.done').attr('disabled', 'disabled'); -- 2.8.1