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/settings.py b/welco/settings.py index 619823d..bae82dc 100644 --- a/welco/settings.py +++ b/welco/settings.py @@ -193,6 +193,10 @@ COUNTER_LINKS = [ {'label': 'Wikipedia', 'url': 'https://fr.wikipedia.org'} ] +# enable/disable specific features +# ex: FLAVOURS = ['alfortville'] +FLAVOURS = [] + local_settings_file = os.environ.get('WELCO_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py')) if os.path.exists(local_settings_file): diff --git a/welco/sources/mail/forms.py b/welco/sources/mail/forms.py index ef74d2a..7b5da7d 100644 --- a/welco/sources/mail/forms.py +++ b/welco/sources/mail/forms.py @@ -16,7 +16,14 @@ from django import forms from django.utils.translation import ugettext_lazy as _ +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) + 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['subject'].widget = forms.TextInput() 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..56cf1a8 100644 --- a/welco/sources/mail/models.py +++ b/welco/sources/mail/models.py @@ -17,6 +17,7 @@ import re import subprocess +from django.conf import settings from django.contrib.contenttypes.fields import GenericRelation from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse @@ -40,6 +41,9 @@ class Mail(models.Model): null=True, max_length=50) note = models.TextField(_('Note'), null=True) + # used only if settings.FLAVOURS contains 'alfortville' + subject = models.CharField(_('Subject'), null=True, max_length=200) + scanner_category = models.CharField(max_length=100, blank=True, null=True) # common to all source types: @@ -57,9 +61,13 @@ class Mail(models.Model): return MailQualificationForm def get_qualification_form(self): - return self.get_qualification_form_class()({ + data = { 'post_date': self.post_date, - 'registered_mail_number': self.registered_mail_number}) + 'registered_mail_number': self.registered_mail_number, + } + if 'alfortville' in getattr(settings, 'FLAVOURS', []): + data['subject'] = self.subject + return self.get_qualification_form_class()(data) @classmethod def get_qualification_form_submit_url(cls): @@ -106,11 +114,14 @@ class Mail(models.Model): return categories.keys() def get_source_context(self, request): - return { + context = { 'channel': 'mail', 'post_date': self.post_date and self.post_date.strftime('%Y-%m-%d'), 'registered_mail_number': self.registered_mail_number, } + if 'alfortville' in getattr(settings, 'FLAVOURS', []): + context['subject'] = self.subject + return context @receiver(post_save, sender=Mail) diff --git a/welco/sources/mail/templates/welco/mail_home.html b/welco/sources/mail/templates/welco/mail_home.html index 5f07939..c29dfc9 100644 --- a/welco/sources/mail/templates/welco/mail_home.html +++ b/welco/sources/mail/templates/welco/mail_home.html @@ -10,7 +10,8 @@
  • {{ mail.creation_timestamp|date:"d/m/Y" }} {{mail.contact_name}} {% for association in mail.associations.all %} @@ -31,6 +32,7 @@ {% if reject_url %} {% endif %} +