remove alfortville custom extension (#31454)

This commit is contained in:
Frédéric Péters 2019-03-15 22:35:14 +01:00
parent c7676678df
commit 5bcd9442b9
28 changed files with 0 additions and 1065 deletions

View File

@ -12,7 +12,6 @@ recursive-include welco/contacts/templates *.html
recursive-include welco/sources/counter/templates *.html
recursive-include welco/sources/phone/templates *.html
recursive-include welco/sources/mail/templates *.html
recursive-include welco/contrib/alfortville/templates *.html *.txt
include COPYING README
include MANIFEST.in

View File

@ -1,26 +0,0 @@
# welco - multichannel request processing
# Copyright (C) 2015 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import django.apps
class AppConfig(django.apps.AppConfig):
name = 'welco.contrib.alfortville'
def get_before_urls(self):
from . import urls
return urls.urlpatterns
default_app_config = 'welco.contrib.alfortville.AppConfig'

View File

@ -1,55 +0,0 @@
# welco - multichannel request processing
# Copyright (C) 2015-2016 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.core.mail import EmailMessage, send_mass_mail
from django.core.management.base import BaseCommand, CommandError
from django.template.loader import render_to_string
from hobo.agent.common.models import Role
from welco.contrib.alfortville.models import Inbox
from welco.sources.mail.models import Mail
class Command(BaseCommand):
def handle(self, *args, **kwargs):
ctx = {}
ctx.update(getattr(settings, 'TEMPLATE_VARS', {}))
subject = render_to_string(['alfortville/avis-email_subject.txt'], ctx).strip()
message = render_to_string(['alfortville/avis-email_body.txt'], ctx)
mails = []
relevant_mails = Mail.objects.filter(status='done-dga')
content_type = ContentType.objects.get_for_model(Mail)
User = get_user_model()
for user in User.objects.all():
user_roles = [x.uuid for x in Role.objects.filter(user=user)]
avis = Inbox.objects.filter(
role_slug__in=user_roles,
source_type=content_type,
source_pk__in=[x.id for x in relevant_mails],
subtype__in=[Inbox.MANDATORY_AVIS, Inbox.AVIS],
done=False)
if avis.count() == 0:
continue
mails.append((subject, message, settings.DEFAULT_FROM_EMAIL, [user.email]))
if mails:
send_mass_mail(mails)

View File

@ -1,27 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('qualif', '0003_association_comments'),
]
operations = [
migrations.CreateModel(
name='Inbox',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('role_slug', models.CharField(max_length=50)),
('subtype', models.PositiveSmallIntegerField(default=1, choices=[(1, b'info'), (2, b'avis')])),
('done', models.BooleanField(default=False)),
('qualif', models.ForeignKey(to='qualif.Association')),
],
options={
},
bases=(models.Model,),
),
]

View File

@ -1,31 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0001_initial'),
('alfortville', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='inbox',
name='qualif',
),
migrations.AddField(
model_name='inbox',
name='source_pk',
field=models.PositiveIntegerField(null=True),
preserve_default=True,
),
migrations.AddField(
model_name='inbox',
name='source_type',
field=models.ForeignKey(to='contenttypes.ContentType', null=True),
preserve_default=True,
),
]

View File

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('alfortville', '0002_auto_20151009_1331'),
]
operations = [
migrations.AddField(
model_name='inbox',
name='comments',
field=models.TextField(verbose_name='Comments', blank=True),
preserve_default=True,
),
]

View File

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('alfortville', '0003_inbox_comments'),
]
operations = [
migrations.AlterField(
model_name='inbox',
name='subtype',
field=models.PositiveSmallIntegerField(default=1, choices=[(1, b'info'), (2, b'avis'), (3, b'mandatory-avis')]),
preserve_default=True,
),
]

View File

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('alfortville', '0004_auto_20151016_1523'),
]
operations = [
migrations.AlterField(
model_name='inbox',
name='comments',
field=models.TextField(null=True, verbose_name='Comments', blank=True),
preserve_default=True,
),
]

View File

@ -1,19 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('alfortville', '0005_auto_20151016_1523'),
]
operations = [
migrations.AddField(
model_name='inbox',
name='last_update_timestamp',
field=models.DateTimeField(auto_now=True, null=True),
),
]

View File

@ -1,44 +0,0 @@
# welco - multichannel request processing
# Copyright (C) 2015 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db import models
from django.utils.translation import ugettext_lazy as _
from hobo.agent.common.models import Role
class Inbox(models.Model):
INFO = 1
AVIS = 2
MANDATORY_AVIS = 3
role_slug = models.CharField(max_length=50)
subtype = models.PositiveSmallIntegerField(
choices=((INFO, 'info'),
(AVIS, 'avis'),
(MANDATORY_AVIS, 'mandatory-avis')),
default=INFO)
source_type = models.ForeignKey(ContentType, null=True)
source_pk = models.PositiveIntegerField(null=True)
source = GenericForeignKey('source_type', 'source_pk')
done = models.BooleanField(default=False)
comments = models.TextField(blank=True, null=True, verbose_name=_('Comments'))
last_update_timestamp = models.DateTimeField(auto_now=True, null=True)
def role_name(self):
return Role.objects.get(uuid=self.role_slug).name

View File

@ -1,9 +0,0 @@
Bonjour,
Vous avez des avis à donner sur des courriers (avis requis et/ou avis
demandés).
Pour prendre connaissance des courriers et déposer vos avis, merci de vous
rendre sur :
{{ portal_agent_url }}

View File

@ -1 +0,0 @@
Avis attendus sur des courriers

View File

@ -1,37 +0,0 @@
{% extends "welco/base.html" %}
{% load i18n static %}
{% block content %}
<form method="POST">
{% csrf_token %}
<table class="avis">
<thead>
<tr>
<td></td>
<th>Pour information</th>
<th>Pour avis facultatif</th>
<th>Pour avis requis</th>
</tr>
</thead>
<tbody>
{% for role in roles %}
<tr>
<th>{{role.text}}</th>
<td><input name="info" value="{{role.slug}}" type="checkbox"
{% if role.slug in checked_info %}checked="checked"{% endif %}/></td>
<td><input name="avis" value="{{role.slug}}" type="checkbox"
{% if role.slug in checked_avis %}checked="checked"{% endif %}/></td>
<td><input name="mandatory_avis" value="{{role.slug}}" type="checkbox"
{% if role.slug in checked_mandatory_avis %}checked="checked"{% endif %}/></td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="buttons">
<button>{% trans 'Save' %}</button>
<button class="cancel">{% trans 'Cancel' %}</button>
</div>
</form>
{% endblock %}

View File

@ -1,63 +0,0 @@
{% extends "welco/base.html" %}
{% load i18n static %}
{% block bodyargs %}class="mail-dg-table"{% endblock %}
{% block breadcrumb %}
{{block.super}}
<a href=".">{{home_screen_title}}</a>
{% endblock %}
{% block content %}
<form method="post" action="qualif-many">
<div class="source-mail all">
<div class="cell document top">
{% if source.get_queryset %}
<div>
<table class="main">
<thead>
<th>{% trans 'Post Date' %}</th>
<th>{% trans 'Reference' %}</th>
<th>{% trans 'Subject' %}</th>
<th>{% trans 'User' %}</th>
<th>{% trans 'Category' %}</th>
<th>{% trans 'Related Forms' %}</th>
<th><input type="checkbox" title="{% trans "Click to (un)toggle all mails" %}" id="click-all-pks"/></th>
</thead>
<tbody>
{% for object in mails %}
<tr data-mail-id="{{object.id}}">
<td class="r">{{object.post_date|date:"d F Y"|lower}}</td>
<td class="r">{{object.reference|default:'-'}}</td>
<td class="r">{{object.subject|default:'-'}}</td>
<td class="r">{{object.contact_name }}</td>
<td class="r">{{object.categories|join:", " }}</td>
<td class="r">{% for association in object.associations.all %}{{association.formdef_name}}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
<td><input type="checkbox" name="pks" value="{{object.id}}"/></td>
</tr>
{% endfor %}
</tbody>
<script>
$('td.r').click(function() {
window.open('../?' + $(this).parent().data('mail-id'), target='_welco_dg');
});
$('input#click-all-pks').click(function(e) {
$('input[name="pks"]').prop('checked', $(this).prop('checked'));
});
</script>
</table>
</div>
<div id="dg-transmit">
{% csrf_token %}
<button>Transmettre</button>
</form>
{%else %}
<p class="no-mail-table">
{% trans 'There is currently no mail in this list.' %}
</p>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -1,45 +0,0 @@
{% extends "welco/base.html" %}
{% load i18n static %}
{% block bodyargs %}class="mail-table mail-table-waiting"{% endblock %}
{% block content %}
<div class="source-mail all">
<div class="cell document top">
{% if objects %}
<h2>{% trans 'Pending Mails' %}</h2>
<div>
<table class="main">
<thead>
<th>{% trans 'Post Date' %}</th>
<th>{% trans 'Reference' %}</th>
<th>{% trans 'Subject' %}</th>
<th>{% trans 'Related Forms' %}</th>
<th>{% trans 'Status' %}</th>
</thead>
<tbody>
{% for object in objects %}
<tr>
<td>{{object.post_date|default:'-'}}</td>
<td>{{object.reference|default:'-'}}</td>
<td>{{object.subject|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 %}
</tbody>
</table>
</div>
{%else %}
<p class="no-mail-table">
{% trans 'There is currently no mail in this list.' %}
</p>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -1,77 +0,0 @@
{% extends "welco/base.html" %}
{% load i18n static %}
{% block bodyargs %}class="mail-table mail-table-subtype{{subtype}}"{% endblock %}
{% block content %}
{% if objects %}
<div class="source-mail all">
<div class="cell document top">
<h2>{{title}}</h2>
<div>
<div class="mails source">
<ul>
{% for object in objects %}
<li
data-source-pk="{{object.source.id}}"
data-pdf-href="{{object.source.content.url}}">
{{object.source.creation_timestamp}}
{% for association in object.source.associations.all %}
<br/><span data-formdata-url="{{association.formdata_url}}">{{association.formdef_name}}</span>
{% endfor %}
</li>
{% endfor %}
</ul>
</div>
<div id="postit" class="readonly" style="display: none"
data-base-url="{% url 'mail-edit-note' %}"
>
</div>
<iframe id="pdf-viewer" src="{% url 'mail-viewer' %}" style="width: 100%;
height: 100%; border: 0;">
</iframe>
</div>
</div>
<div class="cell">
</div>
<div class="cell mark-as-seen">
<form method="POST">
{% csrf_token %}
{% if display_comments_field %}
<textarea name="comments" id="comments-field" placeholder="{% trans "Comments" %}"></textarea>
{% endif %}
<input type="hidden" name="object-pk"></input>
<button>{{ button_text }}</button>
</form>
</div>
</div>
<script>
$(function() {
$('[data-pdf-href]').on('welco:mail-selected', function() {
$('input[name="object-pk"]').val($(this).data('source-pk'));
});
});
</script>
{% else %}
<!-- nothing -->
<div class="source-mail all">
<div class="cell document top">
<h2>{{title}}</h2>
<p class="no-mail-table">
{% trans 'There is currently no mail in this list.' %}
</p>
</div>
</div>
{% endif %}
{% endblock %}

View File

@ -1,40 +0,0 @@
# welco - multichannel request processing
# Copyright (C) 2015 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import 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, dgs_qualif_many, dga_qualif_many)
urlpatterns = [
url(r'^dgs/(?P<table>table/)?$', dgs, name='alfortville-dgs'),
url(r'^dga/(?P<table>table/)?$', 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<pk>\w+)/$', copies, name='alfortville-copies'),
url(r'^ajax/copies/(?P<pk>\w+)/$', copies_ajax, name='alfortville-copies-ajax'),
url(r'^table/info/$', table_info, name='alfortville-table-info'),
url(r'^table/avis/$', table_avis, name='alfortville-table-avis'),
url(r'^table/avis-requis/$', table_mandatory_avis, name='alfortville-table-mandatory-avis'),
url(r'^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'),
url(r'^ajax/count/info/$', count_info, name='alfortville-count-info'),
url(r'^ajax/count/avis/$', count_avis, name='alfortville-count-avis'),
url(r'^ajax/count/avis-requis/$', count_mandatory_avis, name='alfortville-count-avis-requis'),
]

View File

@ -1,326 +0,0 @@
# welco - multichannel request processing
# Copyright (C) 2015 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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 _
from django.views.generic import TemplateView, DetailView
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 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
def get_queryset(self):
return Mail.objects.filter(status='done-qualif')
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()]
dgs = login_required(Dgs.as_view())
def is_dga_role(role_name):
return bool(role_name.startswith('DGA') or role_name.startswith('DGD') or
role_name.startswith('Cabinet'))
class DgaMailHome(MailHome):
display_filter = True
allow_reject = False
def filter_formdef_condition(self, formdef):
roles = set()
for function_role in formdef.get('functions', {}).values():
if is_dga_role(function_role.get('role', {}).get('name', '')):
roles.add(function_role.get('role').get('slug'))
return self.user_roles.intersection(roles)
def get_queryset(self):
mellon = self.request.session['mellon_session']
params = {'NameID': mellon['name_id_content']}
self.user_roles = set([x['slug'] for x in get_wcs_data('api/user/', params).get('user_roles')])
formdef_references = []
for category in get_wcs_options('api/formdefs/', self.filter_formdef_condition):
formdef_references.extend([x[0] for x in category[1]])
return Mail.objects.filter(status='done-dgs',
associations__formdef_reference__in=formdef_references)
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()]
return any([x for x in user_roles if is_dga_role(x)])
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'
def get_context_data(self, **kwargs):
context = super(Copies, self).get_context_data(**kwargs)
checked_dicts = {
Inbox.MANDATORY_AVIS: {},
Inbox.AVIS: {},
Inbox.INFO: {},
}
for inbox in Inbox.objects.filter(source_pk=self.object.id):
checked_dicts[inbox.subtype][inbox.role_slug] = True
context['checked_info'] = checked_dicts[Inbox.INFO]
context['checked_avis'] = checked_dicts[Inbox.AVIS]
context['checked_mandatory_avis'] = checked_dicts[Inbox.MANDATORY_AVIS]
context['roles'] = []
all_roles = get_wcs_data('api/roles').get('data')
for start in ('Maire', 'Cabinet', 'Adjoint', 'Conseiller', 'Elu', 'DGS', 'DGD',
'DGA', 'Direction'):
roles = [x for x in all_roles if x['text'].startswith(start)]
roles.sort(lambda x, y: cmp(x['text'], y['text']))
context['roles'].extend(roles)
return context
def post(self, request, *args, **kwargs):
lists = {
Inbox.MANDATORY_AVIS: request.POST.getlist('mandatory_avis'),
Inbox.AVIS: request.POST.getlist('avis'),
Inbox.INFO: request.POST.getlist('info'),
}
for subtype in lists.keys():
Inbox.objects.filter(subtype=subtype).filter(
source_pk=kwargs['pk']).exclude(
role_slug__in=lists[subtype]).delete()
mail_content_type = ContentType.objects.get_for_model(Mail)
for subtype in lists.keys():
for role_slug in lists[subtype]:
Inbox.objects.get_or_create(source_type=mail_content_type,
source_pk=kwargs['pk'], role_slug=role_slug, subtype=subtype)
return HttpResponseRedirect('.')
copies = login_required(Copies.as_view())
def copies_ajax(request, *args, **kwargs):
roles_by_slug = {}
for role in get_wcs_data('api/roles').get('data'):
roles_by_slug[role['slug']] = role
lists = {
Inbox.MANDATORY_AVIS: [],
Inbox.AVIS: [],
Inbox.INFO: []
}
for inbox in Inbox.objects.filter(source_pk=kwargs.get('pk')):
lists[inbox.subtype].append(roles_by_slug[inbox.role_slug]['text'])
response = HttpResponse(content_type='application/json')
json.dump({'info': ', '.join(lists[Inbox.INFO]) or '-',
'avis': ', '.join(lists[Inbox.AVIS]) or '-',
'mandatory_avis': ', '.join(lists[Inbox.MANDATORY_AVIS]) or '-'},
response, indent=2)
return response
class MailTable(TemplateView):
template_name = 'alfortville/mail-table.html'
button_text = _('Next')
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.uuid for x in Role.objects.filter(user=self.request.user)]
mails = Mail.objects.filter(status='done-dga')
content_type = ContentType.objects.get_for_model(Mail)
context['objects'] = Inbox.objects.filter(
role_slug__in=user_roles,
source_type=content_type,
source_pk__in=[x.id for x in mails],
subtype=self.subtype, done=False).order_by('source_pk').distinct('source_pk')
context['subtype'] = self.subtype
context['button_text'] = self.button_text
context['title'] = self.title
context['display_comments_field'] = True
return context
def post(self, request, *args, **kwargs):
user_roles = [x.uuid for x in Role.objects.filter(user=self.request.user)]
content_type = ContentType.objects.get_for_model(Mail)
Inbox.objects.filter(
source_type=content_type,
source_pk__in=request.POST.getlist('object-pk'),
role_slug__in=user_roles,
subtype=self.subtype).update(
done=True,
comments=request.POST.get('comments'))
return HttpResponseRedirect('.')
class TableMandatoryAvis(MailTable):
subtype = Inbox.MANDATORY_AVIS
title = _('Mandatory Avis Copies')
table_mandatory_avis = login_required(TableMandatoryAvis.as_view())
class TableAvis(MailTable):
subtype = Inbox.AVIS
title = _('Avis Copies')
table_avis = login_required(TableAvis.as_view())
class TableInfo(MailTable):
subtype = Inbox.INFO
title = _('Info Copies')
table_info = login_required(TableInfo.as_view())
class TableWaiting(TemplateView):
template_name = 'alfortville/mail-table-waiting.html'
def get_context_data(self, *args, **kwargs):
context = super(TableWaiting, self).get_context_data(**kwargs)
content_type = ContentType.objects.get_for_model(Mail)
context['objects'] = Mail.objects.filter(
status__in=('', 'done-qualif', 'done-dgs')).order_by('creation_timestamp')
return context
table_waiting = login_required(TableWaiting.as_view())
@login_required
def count_dgs(request, *args, **kwargs):
count = DgsMailHome(request).get_queryset().count()
return response_for_json(request, {'count': count})
@login_required
def count_dga(request, *args, **kwargs):
count = DgaMailHome(request).get_queryset().count()
return response_for_json(request, {'count': count})
@login_required
def count_info(request, *args, **kwargs):
table = TableInfo()
table.request = request
count = table.get_context_data().get('objects').count()
return response_for_json(request, {'count': count})
@login_required
def count_avis(request, *args, **kwargs):
table = TableAvis()
table.request = request
count = table.get_context_data().get('objects').count()
return response_for_json(request, {'count': count})
@login_required
def count_mandatory_avis(request, *args, **kwargs):
table = TableMandatoryAvis()
table.request = request
count = table.get_context_data().get('objects').count()
return response_for_json(request, {'count': count})

View File

@ -224,10 +224,6 @@ PHONE_MAX_CALL_DURATION = 0 # in minutes, 0 stands for infinity
# as a phone line number and take it automatically.
PHONE_AUTOTAKE_MELLON_USERNAME = False
# enable/disable specific features
# ex: FLAVOURS = ['alfortville']
FLAVOURS = []
REST_FRAMEWORK = {}
REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = ['rest_framework.authentication.BasicAuthentication']

View File

@ -23,9 +23,3 @@ class MailQualificationForm(forms.Form):
registered_mail_number = forms.CharField(label=_('Registered Mail Number'), required=False)
reference = forms.CharField(label=_('Reference'), required=False, widget=forms.HiddenInput)
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['reference'].widget = forms.TextInput()
self.fields['subject'].widget = forms.TextInput()

View File

@ -44,7 +44,6 @@ class Mail(models.Model):
note = models.TextField(_('Note'), null=True)
external_id = models.CharField(_('External Id'), null=True, max_length=32)
# used only if settings.FLAVOURS contains 'alfortville'
reference = models.CharField(_('Reference'), null=True, max_length=30)
subject = models.CharField(_('Subject'), null=True, max_length=200)
@ -69,35 +68,12 @@ class Mail(models.Model):
'post_date': self.post_date,
'registered_mail_number': self.registered_mail_number,
}
if 'alfortville' in getattr(settings, 'FLAVOURS', []):
data['reference'] = self.reference
data['subject'] = self.subject
return self.get_qualification_form_class()(data)
@classmethod
def get_qualification_form_submit_url(cls):
return reverse('qualif-mail-save')
# TODO: get_info_roles(), get_avis() and get_mandatory_avis() are custom to
# alfortville, they shouldn't appear in this file.
def get_info_roles(self):
from welco.contrib.alfortville.models import Inbox
return Inbox.objects.filter(subtype=Inbox.INFO,
source_type=ContentType.objects.get_for_model(Mail),
source_pk=self.id)
def get_avis(self):
from welco.contrib.alfortville.models import Inbox
return Inbox.objects.filter(subtype=Inbox.AVIS,
source_type=ContentType.objects.get_for_model(Mail),
source_pk=self.id)
def get_mandatory_avis(self):
from welco.contrib.alfortville.models import Inbox
return Inbox.objects.filter(subtype=Inbox.MANDATORY_AVIS,
source_type=ContentType.objects.get_for_model(Mail),
source_pk=self.id)
def contact_name(self):
if not self.contact_id:
return ''
@ -128,9 +104,6 @@ class Mail(models.Model):
'registered_mail_number': self.registered_mail_number,
'external_id': self.external_id,
}
if 'alfortville' in getattr(settings, 'FLAVOURS', []):
context['reference'] = self.reference
context['subject'] = self.subject
return context

View File

@ -36,42 +36,6 @@
</ul>
{% endif %}
{% if object.get_mandatory_avis|length %}
<div class="bo-block
{% for avis in object.get_mandatory_avis %}{% if not avis.comments %} important {% endif %}{% endfor %}">
<strong>{% trans "Mandatory Avis" %}</strong>
<ul>
{% for avis in object.get_mandatory_avis %}
<li>{{avis.role_name}}:
{% if avis.comments %}{{ avis.comments }}{% else %}{% trans 'Waiting for avis.' %}{% endif %}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if object.get_avis|length %}
<div class="bo-block">
<strong>{% trans "Avis" %}</strong>
<ul>
{% for avis in object.get_avis %}
<li>{{avis.role_name}}:
{% if avis.comments %}{{ avis.comments }}{% else %}{% trans 'Waiting for avis.' %}{% endif %}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if object.get_info_roles|length %}
<div class="bo-block visas">
<strong>{% trans "Visas" %}</strong>
<ul>
{% for info in object.get_info_roles %}
<li>{{info.role_name}} {% if not info.done %}{% trans "(not yet seen)" %}{% endif %}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<style>
p.postit {
background: rgba(241,231,103,1);
@ -80,7 +44,4 @@ p.postit {
padding: 1ex;
width: 90%;
}
div.visas ul {
margin-bottom: 0;
}
</style>

View File

@ -2,9 +2,6 @@ div#footer {
display: none;
}
body.mail-dg-table div#main-content,
body.mail-table div#main-content,
body.dgs-home div#main-content,
body.welco-home div#main-content {
width: 100%;
border: 0;
@ -12,21 +9,16 @@ body.welco-home div#main-content {
height: calc(100vh - 41px); /* #top 40px + #top border 1px */
}
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;
padding: 0;
height: 100%;
}
.dgs-page,
.all {
display: flex;
flex-wrap: wrap;
@ -59,24 +51,6 @@ body.welco-home div#content {
height: 95%;
}
.mail-table .cell {
height: 20%;
}
.mail-table .cell.top {
height: 80%;
}
.mail-table-waiting .cell,
.mail-table-subtype1 .cell {
height: 20%;
}
.mail-table-waiting .cell.top,
.mail-table-subtype1 .cell.top {
height: 80%;
}
div#content .cell h2 {
font-size: 100%;
padding-left: 1ex;
@ -334,53 +308,10 @@ div.objects-list div span.badge {
padding: 1ex;
}
table.dgs-summary {
border-collapse: collapse;
width: calc(100% + 1px);
}
div.objects-list > div:hover table {
background: white;
}
table.dgs-summary td {
border: 1px solid #ccc;
border-width: 1px 1px 0 0;
padding: 1ex 1ex 0.4ex 1ex;
}
table.dgs-summary td:last-child {
text-align: center;
}
div.objects-list > div table.dgs-summary a {
padding: 0;
}
table.dgs-summary button {
padding-left: 1ex;
padding-right: 1ex;
}
.dgs-page > div {
width: calc(50% - 1ex);
height: 100%;
}
.dgs-view {
overflow-y: auto;
padding: 1ex;
}
div.qualif-source p,
div.qualif-source p label {
display: inline-block;
}
div.qualif-source input#id_post_date {
width: 12ex;
}
div.buttons {
margin-top: 1em;
}
@ -439,15 +370,6 @@ td.datetime {
width: 70%;
}
div#copies p {
margin: 0;
margin-left: 1ex;
}
div#copies p:first-child {
margin-left: 0;
}
div.add-formdef-reference {
background: white;
position: relative;
@ -527,17 +449,6 @@ form#note textarea {
margin-right: 1ex;
}
p.waiting-for,
p.no-mail-table {
padding: 10px;
}
button.save.pinned {
background: transparent;
box-shadow: none;
border: none;
}
input#id_keywords {
width: 90%;
}
@ -748,7 +659,3 @@ div#content .cell > div#dg-transmit button {
#content button#create-new-contact {
height: auto;
}
table.main td {
border-left: 1px solid #f0f0f0;
}

View File

@ -373,19 +373,6 @@ $(function() {
$('#postit > div.content').load('/ajax/mail/note/' + source_pk);
});
$(document).on('gadjo:dialog-done welco:load-copies', function(ev) {
if (ev.target && ev.target.id == 'create-new-contact') return;
var source_pk = $('div.source .active[data-source-pk]').data('source-pk');
$.getJSON(
'/ajax/copies/' + source_pk + '/',
function(data) {
$('.info span').text(data.info);
$('.avis span').text(data.avis);
$('.mandatory_avis span').text(data.mandatory_avis);
}
);
});
$(document).on('gadjo:dialog-done', function(ev, data) {
if (ev.target && ev.target.id != 'create-new-contact') return;
if (data.err == 1) {

View File

@ -21,28 +21,6 @@
<button class="add">{% trans 'Add' %}</button>
</div>
{% if source_type_name == 'mail' %}
<!-- special alfortville stuff, this should be factored out -->
<div id="copies">
<p><strong>Copies</strong> (<a rel="popup" data-inplace-submit="true" href="{% url 'alfortville-copies' pk=source_pk %}">{% trans 'Edit' %}</a>)</p>
<p class="info">Pour information : <span>...</span></p>
<p class="avis">Pour avis facultatif : <span>...</span></p>
<p class="mandatory_avis">Pour avis requis : <span>...</span></p>
<script>$('#copies').trigger('welco:load-copies');</script>
</div>
{% endif %}
{% if associations|length %}
<div class="done">
{% if validation_steps %}
{% for validation_step in validation_steps %}
<button class="done" data-action-url="{% url 'qualif-done' %}?step={{validation_step.id}}">{{validation_step.label}}</button>
{% endfor %}
{% else %}
<button class="done" data-action-url="{% url 'qualif-done' %}">{% trans 'Submit' %}</button>
{% endif %}
</div>
{% endif %}
</form>
{% endif %}
</div>