+{% csrf_token %}
+
+
{%else %}
{% trans 'There is currently no mail in this list.' %}
diff --git a/welco/contrib/alfortville/urls.py b/welco/contrib/alfortville/urls.py
index 6d22acd..648f512 100644
--- a/welco/contrib/alfortville/urls.py
+++ b/welco/contrib/alfortville/urls.py
@@ -18,11 +18,13 @@ from django.conf.urls import patterns, url
from .views import (dgs, dga, copies, copies_ajax, table_info, table_avis,
table_mandatory_avis, table_waiting, count_dgs, count_dga, count_info,
- count_avis, count_mandatory_avis)
+ count_avis, count_mandatory_avis, dgs_qualif_many, dga_qualif_many)
urlpatterns = patterns('',
url(r'^dgs/(?P
table/)?$', dgs, name='alfortville-dgs'),
url(r'^dga/(?Ptable/)?$', dga, name='alfortville-dga'),
+ url(r'^dgs/table/qualif-many$', dgs_qualif_many, name='alfortville-dgs-qualif-many'),
+ url(r'^dga/table/qualif-many$', dga_qualif_many, name='alfortville-dga-qualif-many'),
url(r'^copies/(?P\w+)/$', copies, name='alfortville-copies'),
url(r'^ajax/copies/(?P\w+)/$', copies_ajax, name='alfortville-copies-ajax'),
url(r'^table/info/$', table_info, name='alfortville-table-info'),
diff --git a/welco/contrib/alfortville/views.py b/welco/contrib/alfortville/views.py
index 4076d8f..1823fe7 100644
--- a/welco/contrib/alfortville/views.py
+++ b/welco/contrib/alfortville/views.py
@@ -15,9 +15,12 @@
# along with this program. If not, see .
import json
+import logging
+from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
+from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
@@ -102,6 +105,50 @@ class Dga(DgHomeScreen):
dga = login_required(Dga.as_view())
+class QualifMixin(object):
+ def get(self, request, *args, **kwargs):
+ return HttpResponseRedirect(self.get_redirect_url())
+
+ def post(self, request, *args, **kwargs):
+ source_pks = request.POST.getlist('pks')
+ logger = logging.getLogger(__name__)
+ validation_steps = settings.VALIDATION_STEPS.get('mail')
+ mail_content_type = ContentType.objects.get_for_model(Mail)
+ allowed_mails = [str(x.id) for x in self.source_klass(request).get_queryset()]
+ mail_ids = set(source_pks).intersection(set(allowed_mails))
+ for mail in Mail.objects.filter(id__in=mail_ids):
+ if mail.status:
+ mail.status = validation_steps[
+ validation_steps.index(mail.status)+1]
+ else:
+ mail.status = validation_steps[0]
+ if mail.status == validation_steps[-1]:
+ for association in Association.objects.filter(
+ source_type=mail_content_type,
+ source_pk=mail.id):
+ try:
+ association.push(request)
+ except Exception, e:
+ logger.exception('error pushing mail')
+ continue
+ mail.save()
+ return HttpResponseRedirect(self.get_redirect_url())
+
+
+class DgaQualifMany(QualifMixin, Dga):
+ def get_redirect_url(self):
+ return reverse('alfortville-dga', kwargs={'table': 'table/'})
+
+dga_qualif_many = login_required(DgaQualifMany.as_view())
+
+
+class DgsQualifMany(QualifMixin, Dgs):
+ def get_redirect_url(self):
+ return reverse('alfortville-dgs', kwargs={'table': 'table/'})
+
+dgs_qualif_many = login_required(DgsQualifMany.as_view())
+
+
class Copies(DetailView):
model = Mail
template_name = 'alfortville/copies.html'
diff --git a/welco/static/css/style.css b/welco/static/css/style.css
index 6b5bff7..1845e8e 100644
--- a/welco/static/css/style.css
+++ b/welco/static/css/style.css
@@ -695,3 +695,13 @@ div.add-formdef-reference button.add {
ul.select-formdata li li:hover {
background: #eee;
}
+
+div#content .cell > div#dg-transmit {
+ margin: 2ex 0;
+ display: block;
+ text-align: right;
+}
+
+div#content .cell > div#dg-transmit button {
+ margin-right: 1ex;
+}