summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2016-03-22 12:25:48 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2016-03-22 12:25:48 (GMT)
commitc009f039897bc9ac82482f7dd07be3b673a3fa91 (patch)
tree52a0921f75b7551b5d9ed868bf71bb14e8a89d85
parent42e4c24cc19c56b7d05af1cba13c0d465e641f3c (diff)
downloadwelco-c009f039897bc9ac82482f7dd07be3b673a3fa91.zip
welco-c009f039897bc9ac82482f7dd07be3b673a3fa91.tar.gz
welco-c009f039897bc9ac82482f7dd07be3b673a3fa91.tar.bz2
alfortville: dg summary table (#10089)
-rw-r--r--welco/contrib/alfortville/urls.py4
-rw-r--r--welco/contrib/alfortville/views.py28
-rw-r--r--welco/qualif/models.py4
-rw-r--r--welco/sources/counter/views.py3
-rw-r--r--welco/sources/mail/models.py9
-rw-r--r--welco/sources/mail/views.py8
-rw-r--r--welco/sources/phone/views.py3
-rw-r--r--welco/static/css/style.css4
-rw-r--r--welco/static/js/welco.js6
-rw-r--r--welco/views.py2
10 files changed, 59 insertions, 12 deletions
diff --git a/welco/contrib/alfortville/urls.py b/welco/contrib/alfortville/urls.py
index 2d0a9d0..e261fc1 100644
--- a/welco/contrib/alfortville/urls.py
+++ b/welco/contrib/alfortville/urls.py
@@ -21,8 +21,8 @@ from .views import (dgs, dga, copies, copies_ajax, table_info, table_avis,
count_avis, count_mandatory_avis)
urlpatterns = patterns('',
- url('^dgs/$', dgs, name='alfortville-dgs'),
- url('^dga/$', dga, name='alfortville-dga'),
+ url(r'^dgs/(?P<table>table/)?$', dgs, name='alfortville-dgs'),
+ url(r'^dga/(?P<table>table/)?$', dga, name='alfortville-dga'),
url('^copies/(?P<pk>\w+)/$', copies, name='alfortville-copies'),
url('^ajax/copies/(?P<pk>\w+)/$', copies_ajax, name='alfortville-copies-ajax'),
url('^table/info/$', table_info, name='alfortville-table-info'),
diff --git a/welco/contrib/alfortville/views.py b/welco/contrib/alfortville/views.py
index 77c7544..9df3fad 100644
--- a/welco/contrib/alfortville/views.py
+++ b/welco/contrib/alfortville/views.py
@@ -28,12 +28,17 @@ from hobo.agent.common.models import Role
from .models import Inbox
from welco.sources.mail.models import Mail
-from welco.sources.mail.views import Home as MailHome
+from welco.sources.mail.views import Home as MailOriginalHome
from welco.qualif.models import Association
from welco.utils import get_wcs_data, get_wcs_options, response_for_json
from welco.views import HomeMail as HomeScreen
+class MailHome(MailOriginalHome):
+ def get_template(self):
+ return super(MailHome, self).get_template()
+
+
class DgsMailHome(MailHome):
display_filter = True
allow_reject = False
@@ -41,8 +46,23 @@ class DgsMailHome(MailHome):
def get_queryset(self):
return Mail.objects.filter(status='done-qualif')
-class Dgs(HomeScreen):
+
+class DgHomeScreen(HomeScreen):
+ def get_template_names(self):
+ if self.kwargs.get('table') == 'table/':
+ return ['alfortville/dg-table.html']
+ return [self.template_name]
+
+ def get_context_data(self, **kwargs):
+ context = super(DgHomeScreen, self).get_context_data(**kwargs)
+ context['home_screen_title'] = self.home_screen_title
+ context['mails'] = context['source'].get_queryset()
+ return context
+
+
+class Dgs(DgHomeScreen):
source_klass = DgsMailHome
+ home_screen_title = _('DGS Validation')
def check_user_ok(self):
return 'DGS' in [x.name for x in self.request.user.groups.all()]
@@ -71,9 +91,9 @@ class DgaMailHome(MailHome):
return Mail.objects.filter(status='done-dgs',
associations__formdef_reference__in=formdef_references)
-
-class Dga(HomeScreen):
+class Dga(DgHomeScreen):
source_klass = DgaMailHome
+ home_screen_title = _('DGA Validation')
def check_user_ok(self):
user_roles = [x.name for x in self.request.user.groups.all()]
diff --git a/welco/qualif/models.py b/welco/qualif/models.py
index 7962b26..58339f5 100644
--- a/welco/qualif/models.py
+++ b/welco/qualif/models.py
@@ -48,6 +48,10 @@ class Association(models.Model):
return get_wcs_formdef_details(self.formdef_reference).get('title')
@property
+ def formdef_category(self):
+ return get_wcs_formdef_details(self.formdef_reference).get('category')
+
+ @property
def formdata_url(self):
site, formdef = self.formdef_reference.split(':')
wcs_site = get_wcs_services().get(site)
diff --git a/welco/sources/counter/views.py b/welco/sources/counter/views.py
index 8cbf695..c0790b3 100644
--- a/welco/sources/counter/views.py
+++ b/welco/sources/counter/views.py
@@ -31,8 +31,9 @@ from .models import CounterPresence
class Home(object):
source_key = 'counter'
- def __init__(self, request):
+ def __init__(self, request, **kwargs):
self.request = request
+ self.kwargs = kwargs
def render(self):
zone = CounterZone()
diff --git a/welco/sources/mail/models.py b/welco/sources/mail/models.py
index 0c7d731..be6a393 100644
--- a/welco/sources/mail/models.py
+++ b/welco/sources/mail/models.py
@@ -86,6 +86,15 @@ class Mail(models.Model):
def html_note(self):
return re.sub(r'[\r?\n]+', '<br><br>', self.note, re.DOTALL)
+ def categories(self):
+ categories = {}
+ for association in self.associations.all():
+ if association.formdef_category:
+ categories[association.formdef_category] = True
+ if not categories:
+ return '-'
+ return categories.keys()
+
@receiver(post_save, sender=Mail)
def create_thumbnail(sender, instance, created, **kwargs):
diff --git a/welco/sources/mail/views.py b/welco/sources/mail/views.py
index 1c1cff5..b8b2cbb 100644
--- a/welco/sources/mail/views.py
+++ b/welco/sources/mail/views.py
@@ -58,12 +58,16 @@ class Home(object):
display_filter = False
allow_reject = True
- def __init__(self, request):
+ def __init__(self, request, **kwargs):
self.request = request
+ self.kwargs = kwargs
def get_queryset(self):
return Mail.objects.exclude(status__startswith='done-')
+ def get_template(self):
+ return 'welco/mail_home.html'
+
def render(self):
context = RequestContext(self.request)
context['mails'] = self.get_queryset().order_by('creation_timestamp')
@@ -73,7 +77,7 @@ class Home(object):
if self.allow_reject:
context['reject_url'] = reverse('mail-reject')
context['display_filter'] = self.display_filter
- tmpl = template.loader.get_template('welco/mail_home.html')
+ tmpl = template.loader.get_template(self.get_template())
return tmpl.render(context)
diff --git a/welco/sources/phone/views.py b/welco/sources/phone/views.py
index 13d15ee..056e5b1 100644
--- a/welco/sources/phone/views.py
+++ b/welco/sources/phone/views.py
@@ -32,8 +32,9 @@ from .models import PhoneCall, PhoneLine
class Home(object):
source_key = 'phone'
- def __init__(self, request):
+ def __init__(self, request, **kwargs):
self.request = request
+ self.kwargs = kwargs
def render(self):
zone = PhoneZone()
diff --git a/welco/static/css/style.css b/welco/static/css/style.css
index d2da836..be35234 100644
--- a/welco/static/css/style.css
+++ b/welco/static/css/style.css
@@ -7,6 +7,10 @@ body.welco-home div#main-content {
height: calc(100vh - 8em);
}
+body.mail-dg-table div#main-content {
+ height: calc(100vh - 8em);
+}
+
body.mail-table div#more-user-links,
body.dgs-home div#more-user-links,
body.welco-home div#more-user-links {
diff --git a/welco/static/js/welco.js b/welco/static/js/welco.js
index 2fd0722..1d740ef 100644
--- a/welco/static/js/welco.js
+++ b/welco/static/js/welco.js
@@ -301,7 +301,11 @@ $(function() {
});
$('#pdf-viewer').on('load', function() {
- $('.mails ul li[data-pdf-href]:first-child').trigger('click');
+ if (window.location.search) {
+ $('.mails ul li[data-pdf-href][data-source-pk=' + window.location.search.substr(1) + ']').trigger('click');
+ } else {
+ $('.mails ul li[data-pdf-href]:first-child').trigger('click');
+ }
});
$(document).on('gadjo:dialog-done welco:load-mail-note', function(ev) {
diff --git a/welco/views.py b/welco/views.py
index c4e242d..a8fc4d7 100644
--- a/welco/views.py
+++ b/welco/views.py
@@ -113,7 +113,7 @@ class ChannelHome(TemplateView):
if not self.check_user_ok():
raise PermissionDenied()
context = super(ChannelHome, self).get_context_data(**kwargs)
- context['source'] = self.source_klass(self.request)
+ context['source'] = self.source_klass(self.request, **kwargs)
context['kb'] = KbHomeZone(self.request)
context['contacts'] = ContactsHomeZone(self.request)
context['channels'] = []