alfortville: add listings for avis/info mails
This commit is contained in:
parent
30b36c9cc9
commit
e03b92f99c
|
@ -0,0 +1,60 @@
|
|||
{% extends "welco/base.html" %}
|
||||
{% load i18n static %}
|
||||
|
||||
{% block bodyargs %}class="mail-table"{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="source-mail all">
|
||||
<div class="cell document top">
|
||||
<h2>{{title}}</h2>
|
||||
<div>
|
||||
<div class="mails">
|
||||
<ul>
|
||||
{% for object in objects %}
|
||||
<li
|
||||
data-object-pk="{{object.id}}"
|
||||
data-pdf-href="{{object.qualif.source.content.url}}">
|
||||
{{object.qualif.source.creation_timestamp}}
|
||||
{% for formdata in object.qualif.formdatas.all %}
|
||||
<br/><span data-formdata-url="{{formdata.url}}">{{formdata.formdef.name}}</span>
|
||||
{% endfor %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<iframe id="pdf-viewer" src="{% url 'mail-viewer' %}" style="width: 100%;
|
||||
height: 100%; border: 0;">
|
||||
</iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cell formdata-links">
|
||||
</div>
|
||||
|
||||
<div class="cell">
|
||||
</div>
|
||||
|
||||
<div class="cell mark-as-seen">
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="object-pk"></input>
|
||||
<button>{% trans 'Mark as Seen' %}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('[data-pdf-href]').on('welco:mail-selected', function() {
|
||||
$('input[name="object-pk"]').val($(this).data('object-pk'));
|
||||
$('.formdata-links').empty();
|
||||
$(this).find('[data-formdata-url]').each(function(idx, elem) {
|
||||
$('<a href="' + $(elem).data('formdata-url') + '">' + $(elem).text() + '</a>').appendTo($('.formdata-links'));
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
|
@ -16,10 +16,12 @@
|
|||
|
||||
from django.conf.urls import patterns, url
|
||||
|
||||
from .views import dgs, copies, copies_ajax
|
||||
from .views import dgs, copies, copies_ajax, table_info, table_avis
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url('^dgs/$', dgs, name='alfortville-dgs'),
|
||||
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'),
|
||||
url('^table/avis/$', table_avis, name='alfortville-table-avis'),
|
||||
)
|
||||
|
|
|
@ -19,6 +19,7 @@ import json
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.template import RequestContext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.generic import TemplateView, DetailView
|
||||
|
||||
from .models import Inbox
|
||||
|
@ -116,3 +117,42 @@ def copies_ajax(request, *args, **kwargs):
|
|||
info = ', '.join(info)
|
||||
json.dump({'info': info, 'avis': avis}, response, indent=2)
|
||||
return response
|
||||
|
||||
|
||||
class MailTable(TemplateView):
|
||||
template_name = 'alfortville/mail-table.html'
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super(MailTable, self).get_context_data(**kwargs)
|
||||
params = {}
|
||||
if self.request.session.get('mellon_session'):
|
||||
mellon = self.request.session['mellon_session']
|
||||
params['NameID'] = mellon['name_id_content']
|
||||
|
||||
user_roles = [x['slug'] for x in get_wcs_data('api/user/', params=params).get('user_roles')]
|
||||
|
||||
context['objects'] = Inbox.objects.filter(
|
||||
role_slug__in=user_roles, qualif__triaged=True,
|
||||
qualif__formdatas__isnull=False, done=False)
|
||||
|
||||
context['title'] = self.title
|
||||
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
Inbox.objects.filter(id__in=request.POST.getlist('object-pk')).update(done=True)
|
||||
return HttpResponseRedirect('.')
|
||||
|
||||
|
||||
class TableAvis(MailTable):
|
||||
subtype = Inbox.AVIS
|
||||
title = _('Avis Copies')
|
||||
|
||||
table_avis = TableAvis.as_view()
|
||||
|
||||
|
||||
class TableInfo(MailTable):
|
||||
subtype = Inbox.INFO
|
||||
title = _('Info Copies')
|
||||
|
||||
table_info = TableInfo.as_view()
|
||||
|
|
|
@ -21,7 +21,7 @@ from django.db.models.signals import post_save
|
|||
from django.dispatch import receiver
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from welco.utils import get_wcs_formdef_details, push_wcs_formdata
|
||||
from welco.utils import get_wcs_formdef_details, push_wcs_formdata, get_wcs_services
|
||||
|
||||
|
||||
class FormdefReference(models.Model):
|
||||
|
@ -35,6 +35,16 @@ class FormdefReference(models.Model):
|
|||
class FormdataReference(models.Model):
|
||||
reference = models.CharField(max_length=250)
|
||||
|
||||
def formdef(self):
|
||||
return FormdefReference.objects.get(
|
||||
reference=self.reference.rsplit(':', 1)[0])
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
site, formdef, formdata = self.reference.split(':')
|
||||
wcs_site = get_wcs_services().get(site)
|
||||
return '%s%s/%s' % (wcs_site.get('url'), formdef, formdata)
|
||||
|
||||
|
||||
class Association(models.Model):
|
||||
source_type = models.ForeignKey(ContentType)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
body.mail-table div#main-content,
|
||||
body.dgs-home div#main-content,
|
||||
body.welco-home div#main-content {
|
||||
width: 100%;
|
||||
|
@ -6,11 +7,13 @@ body.welco-home 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 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body.mail-table div#content,
|
||||
body.dgs-home div#content,
|
||||
body.welco-home div#content {
|
||||
margin: 0;
|
||||
|
@ -46,6 +49,14 @@ body.welco-home div#content {
|
|||
height: 50%;
|
||||
}
|
||||
|
||||
.mail-table .cell {
|
||||
height: 10%;
|
||||
}
|
||||
|
||||
.mail-table .cell.top {
|
||||
height: 90%;
|
||||
}
|
||||
|
||||
div#content .cell h2 {
|
||||
font-size: 100%;
|
||||
padding-left: 1ex;
|
||||
|
@ -328,3 +339,15 @@ button#create-new-contact {
|
|||
td.datetime {
|
||||
width: 15em;
|
||||
}
|
||||
|
||||
.mark-as-seen button {
|
||||
position: absolute;
|
||||
bottom: 1ex;
|
||||
right: 1ex;
|
||||
}
|
||||
|
||||
.formdata-links a {
|
||||
margin: 1em;
|
||||
padding-top: 1em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ $(function() {
|
|||
$('#pdf-viewer').data('current-pdf-href', new_pdf);
|
||||
$('#pdf-viewer')[0].contentWindow.postMessage(new_pdf,
|
||||
window.location.protocol + '//' + window.location.host);
|
||||
$(this).trigger('welco:mail-selected');
|
||||
}
|
||||
});
|
||||
$('.mails ul li[data-pdf-href]').on('click', function() {
|
||||
|
|
Loading…
Reference in New Issue