diff --git a/MANIFEST.in b/MANIFEST.in index 3be7c1f..e0a5bc1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/welco/contrib/alfortville/__init__.py b/welco/contrib/alfortville/__init__.py deleted file mode 100644 index cab37e2..0000000 --- a/welco/contrib/alfortville/__init__.py +++ /dev/null @@ -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 . - -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' diff --git a/welco/contrib/alfortville/management/__init__.py b/welco/contrib/alfortville/management/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/welco/contrib/alfortville/management/commands/__init__.py b/welco/contrib/alfortville/management/commands/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/welco/contrib/alfortville/management/commands/send-avis-email.py b/welco/contrib/alfortville/management/commands/send-avis-email.py deleted file mode 100644 index 6209197..0000000 --- a/welco/contrib/alfortville/management/commands/send-avis-email.py +++ /dev/null @@ -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 . - -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) diff --git a/welco/contrib/alfortville/migrations/0001_initial.py b/welco/contrib/alfortville/migrations/0001_initial.py deleted file mode 100644 index 6788f46..0000000 --- a/welco/contrib/alfortville/migrations/0001_initial.py +++ /dev/null @@ -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,), - ), - ] diff --git a/welco/contrib/alfortville/migrations/0002_auto_20151009_1331.py b/welco/contrib/alfortville/migrations/0002_auto_20151009_1331.py deleted file mode 100644 index be70a26..0000000 --- a/welco/contrib/alfortville/migrations/0002_auto_20151009_1331.py +++ /dev/null @@ -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, - ), - ] diff --git a/welco/contrib/alfortville/migrations/0003_inbox_comments.py b/welco/contrib/alfortville/migrations/0003_inbox_comments.py deleted file mode 100644 index ed3d219..0000000 --- a/welco/contrib/alfortville/migrations/0003_inbox_comments.py +++ /dev/null @@ -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, - ), - ] diff --git a/welco/contrib/alfortville/migrations/0004_auto_20151016_1523.py b/welco/contrib/alfortville/migrations/0004_auto_20151016_1523.py deleted file mode 100644 index e17cf0b..0000000 --- a/welco/contrib/alfortville/migrations/0004_auto_20151016_1523.py +++ /dev/null @@ -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, - ), - ] diff --git a/welco/contrib/alfortville/migrations/0005_auto_20151016_1523.py b/welco/contrib/alfortville/migrations/0005_auto_20151016_1523.py deleted file mode 100644 index b053299..0000000 --- a/welco/contrib/alfortville/migrations/0005_auto_20151016_1523.py +++ /dev/null @@ -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, - ), - ] diff --git a/welco/contrib/alfortville/migrations/0006_inbox_last_update_timestamp.py b/welco/contrib/alfortville/migrations/0006_inbox_last_update_timestamp.py deleted file mode 100644 index f2b19ce..0000000 --- a/welco/contrib/alfortville/migrations/0006_inbox_last_update_timestamp.py +++ /dev/null @@ -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), - ), - ] diff --git a/welco/contrib/alfortville/migrations/__init__.py b/welco/contrib/alfortville/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/welco/contrib/alfortville/models.py b/welco/contrib/alfortville/models.py deleted file mode 100644 index cb1d12e..0000000 --- a/welco/contrib/alfortville/models.py +++ /dev/null @@ -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 . - -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 diff --git a/welco/contrib/alfortville/templates/alfortville/avis-email_body.txt b/welco/contrib/alfortville/templates/alfortville/avis-email_body.txt deleted file mode 100644 index e60de9c..0000000 --- a/welco/contrib/alfortville/templates/alfortville/avis-email_body.txt +++ /dev/null @@ -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 }} diff --git a/welco/contrib/alfortville/templates/alfortville/avis-email_subject.txt b/welco/contrib/alfortville/templates/alfortville/avis-email_subject.txt deleted file mode 100644 index 8c7155f..0000000 --- a/welco/contrib/alfortville/templates/alfortville/avis-email_subject.txt +++ /dev/null @@ -1 +0,0 @@ -Avis attendus sur des courriers diff --git a/welco/contrib/alfortville/templates/alfortville/copies.html b/welco/contrib/alfortville/templates/alfortville/copies.html deleted file mode 100644 index b418524..0000000 --- a/welco/contrib/alfortville/templates/alfortville/copies.html +++ /dev/null @@ -1,37 +0,0 @@ -{% extends "welco/base.html" %} -{% load i18n static %} - -{% block content %} - -
-{% csrf_token %} - - - - - - - - - - - {% for role in roles %} - - - - - - - {% endfor %} - -
Pour informationPour avis facultatifPour avis requis
{{role.text}}
-
- - -
-
- -{% endblock %} diff --git a/welco/contrib/alfortville/templates/alfortville/dg-table.html b/welco/contrib/alfortville/templates/alfortville/dg-table.html deleted file mode 100644 index 86b9563..0000000 --- a/welco/contrib/alfortville/templates/alfortville/dg-table.html +++ /dev/null @@ -1,63 +0,0 @@ -{% extends "welco/base.html" %} -{% load i18n static %} - -{% block bodyargs %}class="mail-dg-table"{% endblock %} - -{% block breadcrumb %} -{{block.super}} -{{home_screen_title}} -{% endblock %} - -{% block content %} - -
-
-
-{% if source.get_queryset %} -
- - - - - - - - - - - -{% for object in mails %} - - - - - - - - - -{% endfor %} - - -
{% trans 'Post Date' %}{% trans 'Reference' %}{% trans 'Subject' %}{% trans 'User' %}{% trans 'Category' %}{% trans 'Related Forms' %}
{{object.post_date|date:"d F Y"|lower}}{{object.reference|default:'-'}}{{object.subject|default:'-'}}{{object.contact_name }}{{object.categories|join:", " }}{% for association in object.associations.all %}{{association.formdef_name}}{% if not forloop.last %}, {% endif %}{% endfor %}
-
-
-{% csrf_token %} - - -{%else %} -

-{% trans 'There is currently no mail in this list.' %} -

-{% endif %} -
-
- -{% endblock %} diff --git a/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html b/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html deleted file mode 100644 index e282804..0000000 --- a/welco/contrib/alfortville/templates/alfortville/mail-table-waiting.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "welco/base.html" %} -{% load i18n static %} - -{% block bodyargs %}class="mail-table mail-table-waiting"{% endblock %} - -{% block content %} - -
-
-{% if objects %} -

{% trans 'Pending Mails' %}

-
- - - - - - - - - -{% for object in objects %} - - - - - - - -{% endfor %} - -
{% trans 'Post Date' %}{% trans 'Reference' %}{% trans 'Subject' %}{% trans 'Related Forms' %}{% trans 'Status' %}
{{object.post_date|default:'-'}}{{object.reference|default:'-'}}{{object.subject|default:'-'}}{% for association in object.associations.all %}{{association.formdef_name}}{% if not forloop.last %}, {% endif %}{% endfor %}{% 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 %}
-
-{%else %} -

-{% trans 'There is currently no mail in this list.' %} -

-{% endif %} -
-
- -{% endblock %} diff --git a/welco/contrib/alfortville/templates/alfortville/mail-table.html b/welco/contrib/alfortville/templates/alfortville/mail-table.html deleted file mode 100644 index e586451..0000000 --- a/welco/contrib/alfortville/templates/alfortville/mail-table.html +++ /dev/null @@ -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 %} -
-
-

{{title}}

-
-
-
    -{% for object in objects %} -
  • - {{object.source.creation_timestamp}} - {% for association in object.source.associations.all %} -
    {{association.formdef_name}} - {% endfor %} -
  • -{% endfor %} -
-
- - -
-
- -
-
- -
-
- {% csrf_token %} - {% if display_comments_field %} - - {% endif %} - - -
-
- -
- - -{% else %} - - -
-
-

{{title}}

- -

-{% trans 'There is currently no mail in this list.' %} -

- -
-
- - -{% endif %} - -{% endblock %} diff --git a/welco/contrib/alfortville/urls.py b/welco/contrib/alfortville/urls.py deleted file mode 100644 index 26f1324..0000000 --- a/welco/contrib/alfortville/urls.py +++ /dev/null @@ -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 . - -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/(?Ptable/)?$', dgs, name='alfortville-dgs'), - url(r'^dga/(?P
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\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'), - 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'), -] diff --git a/welco/contrib/alfortville/views.py b/welco/contrib/alfortville/views.py deleted file mode 100644 index 2da4bd1..0000000 --- a/welco/contrib/alfortville/views.py +++ /dev/null @@ -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 . - -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}) diff --git a/welco/settings.py b/welco/settings.py index 28d427a..83bb858 100644 --- a/welco/settings.py +++ b/welco/settings.py @@ -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'] diff --git a/welco/sources/mail/forms.py b/welco/sources/mail/forms.py index a00f435..b49e766 100644 --- a/welco/sources/mail/forms.py +++ b/welco/sources/mail/forms.py @@ -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() diff --git a/welco/sources/mail/models.py b/welco/sources/mail/models.py index f3b42bd..d50d199 100644 --- a/welco/sources/mail/models.py +++ b/welco/sources/mail/models.py @@ -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 diff --git a/welco/sources/mail/templates/welco/mail_summary.html b/welco/sources/mail/templates/welco/mail_summary.html index c401312..fff76e1 100644 --- a/welco/sources/mail/templates/welco/mail_summary.html +++ b/welco/sources/mail/templates/welco/mail_summary.html @@ -36,42 +36,6 @@ {% endif %} -{% if object.get_mandatory_avis|length %} -
-{% trans "Mandatory Avis" %} -
    - {% for avis in object.get_mandatory_avis %} -
  • {{avis.role_name}}: - {% if avis.comments %}{{ avis.comments }}{% else %}{% trans 'Waiting for avis.' %}{% endif %}
  • - {% endfor %} -
-
-{% endif %} - -{% if object.get_avis|length %} -
-{% trans "Avis" %} -
    - {% for avis in object.get_avis %} -
  • {{avis.role_name}}: - {% if avis.comments %}{{ avis.comments }}{% else %}{% trans 'Waiting for avis.' %}{% endif %}
  • - {% endfor %} -
-
-{% endif %} - -{% if object.get_info_roles|length %} -
-{% trans "Visas" %} -
    - {% for info in object.get_info_roles %} -
  • {{info.role_name}} {% if not info.done %}{% trans "(not yet seen)" %}{% endif %}
  • - {% endfor %} -
-
-{% endif %} - diff --git a/welco/static/css/style.css b/welco/static/css/style.css index e291fd0..29ee430 100644 --- a/welco/static/css/style.css +++ b/welco/static/css/style.css @@ -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; -} diff --git a/welco/static/js/welco.js b/welco/static/js/welco.js index 9ac903d..701e3e3 100644 --- a/welco/static/js/welco.js +++ b/welco/static/js/welco.js @@ -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) { diff --git a/welco/templates/welco/qualification.html b/welco/templates/welco/qualification.html index 4032e3f..3fc21e9 100644 --- a/welco/templates/welco/qualification.html +++ b/welco/templates/welco/qualification.html @@ -21,28 +21,6 @@ - {% if source_type_name == 'mail' %} - -
-

Copies ({% trans 'Edit' %})

-

Pour information : ...

-

Pour avis facultatif : ...

-

Pour avis requis : ...

- -
- {% endif %} - - {% if associations|length %} -
- {% if validation_steps %} - {% for validation_step in validation_steps %} - - {% endfor %} - {% else %} - - {% endif %} -
- {% endif %} {% endif %}