summaryrefslogtreecommitdiffstats
path: root/welco
diff options
context:
space:
mode:
authorThomas NOEL <tnoel@entrouvert.com>2016-10-12 05:32:37 (GMT)
committerThomas NOEL <tnoel@entrouvert.com>2016-10-14 08:09:16 (GMT)
commit908d47ff09fbd11cbc4fc8ed38634db7074b04c3 (patch)
tree286c6fe79d748a36c32ba021ffa30a56f54981ec /welco
parenta217cce050d7d6559a21d12b9aae5681edb89355 (diff)
downloadwelco-908d47ff09fbd11cbc4fc8ed38634db7074b04c3.zip
welco-908d47ff09fbd11cbc4fc8ed38634db7074b04c3.tar.gz
welco-908d47ff09fbd11cbc4fc8ed38634db7074b04c3.tar.bz2
mails: add reference field, only for alfortville flavour (#13549)
Diffstat (limited to 'welco')
-rw-r--r--welco/contrib/alfortville/templates/alfortville/dg-table.html2
-rw-r--r--welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html2
-rw-r--r--welco/sources/mail/forms.py2
-rw-r--r--welco/sources/mail/migrations/0011_mail_reference.py19
-rw-r--r--welco/sources/mail/models.py3
-rw-r--r--welco/sources/mail/templates/welco/mail_home.html1
-rw-r--r--welco/sources/mail/templates/welco/mail_summary.html4
-rw-r--r--welco/sources/mail/views.py1
-rw-r--r--welco/static/css/style.css6
-rw-r--r--welco/static/js/welco.js4
10 files changed, 43 insertions, 1 deletions
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 @@
<thead>
<th>{% trans 'Scan Date' %}</th>
<th>{% trans 'Post Date' %}</th>
+ <th>{% trans 'Reference' %}</th>
<th>{% trans 'Subject' %}</th>
<th>{% trans 'User' %}</th>
<th>{% trans 'Category' %}</th>
@@ -30,6 +31,7 @@
<tr data-mail-id="{{object.id}}">
<td class="r">{{object.creation_timestamp|date:"d F Y"|lower}}</td>
<td class="r">{{object.post_date|date:"d F Y"|lower}}</td>
+ <td class="r">{{object.reference|default:'-'}}</td>
<td class="r">{{object.subject|default:'-'}}</td>
<td class="r">{{object.contact_name }}</td>
<td class="r">{{object.categories|join:", " }}</td>
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 @@
<thead>
<th>{% trans 'Scan Date' %}</th>
<th>{% trans 'Post Date' %}</th>
+ <th>{% trans 'Reference' %}</th>
<th>{% trans 'Subject' %}</th>
<th>{% trans 'Related Forms' %}</th>
<th>{% trans 'Status' %}</th>
@@ -23,6 +24,7 @@
<tr>
<td>{{object.creation_timestamp|date:"d F Y"|lower}}</td>
<td>{{object.post_date|default:'-'}}</td>
+ <td>{{object.reference|default:'-'}}</td>
<td>{{object.subject|default:'-'}}</td>
<td>{% for association in object.associations.all %}{{association.formdef_name}}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
<td>{% 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 @@
<p class="registered-mail-number">{% trans "Registered Mail Number:" %} {{object.registered_mail_number}}</p>
{% endif %}
+{% if object.reference %}
+<p class="reference">{% trans "Reference:" %} {{object.reference}}</p>
+{% endif %}
+
{% if object.subject %}
<p class="subject">{% trans "Subject:" %} {{object.subject}}</p>
{% 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..3e39b92 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: 6em;
+}
+
#source-mainarea input#id_subject {
- width: 40em;
+ width: 25em;
}
#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()) {