alfortville: redo "pening mails" screen (#8716)

This commit is contained in:
Frédéric Péters 2015-11-30 16:44:03 +01:00
parent 818c1d0e8b
commit 780d3ba642
3 changed files with 31 additions and 73 deletions

View File

@ -5,73 +5,41 @@
{% block content %}
<div class="source-mail all">
<div class="cell document top">
{% if objects %}
<div class="source-mail all">
<div class="cell document top">
<h2>{% trans 'Mails waiting for validation' %}</h2>
<h2>{% trans 'Pending Mails' %}</h2>
<div>
<div class="mails">
<ul>
<table class="main">
<thead>
<th>{% trans 'Scan Date' %}</th>
<th>{% trans 'Post Date' %}</th>
<th>{% trans 'Mail Number' %}</th>
<th>{% trans 'Related Forms' %}</th>
<th>{% trans 'Status' %}</th>
</thead>
<tbody>
{% for object in objects %}
<li
data-mail-id="{{object.id}}"
data-mail-status="{{object.status}}"
data-pdf-href="{{object.content.url}}">
{{object.creation_timestamp}}
{% for association in object.associations.all %}
<br/><span data-formdata-url="{{association.formdata_url}}">{{association.formdef_name}}</span>
{% endfor %}
</li>
<tr>
<td>{{object.creation_timestamp|date:"d F Y"|lower}}</td>
<td>{{object.post_date|default:'-'}}</td>
<td>{{object.mail_number|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
{% elif object.status == 'done-dgs' %}En attente de validation DGA
{% else %}En attente de qualification
{% endif %}</td>
</tr>
{% endfor %}
</ul>
</tbody>
</table>
</div>
<iframe id="pdf-viewer" src="{% url 'mail-viewer' %}" style="width: 100%;
height: 100%; border: 0;">
</iframe>
</div>
</div>
<div class="cell mail-status">
</div>
<div class="cell">
</div>
<div class="cell mark-as-seen">
</div>
</div>
<script>
$(function() {
$('[data-pdf-href]').on('welco:mail-selected', function() {
$('input[name="object-pk"]').val($(this).data('object-pk'));
$('.mail-status').empty();
var msg = null;
if ($(this).data('mail-status') == 'done-qualif') {
msg = 'En attente de validation DGS'
} else if ($(this).data('mail-status') == 'done-dgs') {
msg = 'En attente de validation DGA'
}
$('<p class="waiting-for">' + msg + '</p>').appendTo('.mail-status');
});
});
</script>
{% else %}
<!-- nothing -->
<div class="source-mail all">
<div class="cell document top">
<h2>{% trans 'Mails waiting for validation' %}</h2>
{%else %}
<p class="no-mail-table">
{% trans 'There is currently no mail in this list.' %}
</p>
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -28,7 +28,7 @@ urlpatterns = patterns('',
url('^table/info/$', table_info, name='alfortville-table-info'),
url('^table/avis/$', table_avis, name='alfortville-table-avis'),
url('^table/avis-requis/$', table_mandatory_avis, name='alfortville-table-mandatory-avis'),
url('^table/en-attente-de-validation/$', table_waiting, name='alfortville-table-waiting'),
url('^table/en-attente/$', table_waiting, name='alfortville-table-waiting'),
url(r'^ajax/count/dgs/$', count_dgs, name='alfortville-count-dgs'),
url(r'^ajax/count/dga/$', count_dga, name='alfortville-count-dga'),

View File

@ -18,6 +18,7 @@ import json
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
from django.db.models import Q
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView, DetailView
@ -200,19 +201,8 @@ class TableWaiting(TemplateView):
context = super(TableWaiting, self).get_context_data(**kwargs)
content_type = ContentType.objects.get_for_model(Mail)
context['objects'] = []
seen = {}
for association in Association.objects.filter(
formdef_reference__isnull=False,
formdata_id__isnull=True,
source_pk__isnull=False,
source_type=content_type.id):
if not association.source.status: # still on first screen
continue
if association.source_pk not in seen:
context['objects'].append(association.source)
seen['association.source_pk'] = True
context['objects'] = Mail.objects.filter(
status__in=('', 'done-qualif', 'done-dgs')).order_by('creation_timestamp')
return context
table_waiting = login_required(TableWaiting.as_view())