summaryrefslogtreecommitdiffstats
path: root/welco
diff options
context:
space:
mode:
Diffstat (limited to 'welco')
-rw-r--r--welco/contacts/forms.py4
-rw-r--r--welco/contacts/views.py12
-rw-r--r--welco/forms.py2
-rw-r--r--welco/kb/forms.py2
-rw-r--r--welco/kb/migrations/0001_initial.py5
-rw-r--r--welco/kb/migrations/0002_page_keywords.py5
-rw-r--r--welco/kb/migrations/0003_page_tags.py5
-rw-r--r--welco/kb/migrations/0004_remove_page_keywords.py5
-rw-r--r--welco/kb/models.py5
-rw-r--r--welco/kb/search_indexes.py6
-rw-r--r--welco/kb/views.py29
-rw-r--r--welco/monkeypatch.py7
-rw-r--r--welco/qualif/migrations/0001_initial.py5
-rw-r--r--welco/qualif/migrations/0002_association_triaged.py5
-rw-r--r--welco/qualif/migrations/0003_association_comments.py5
-rw-r--r--welco/qualif/migrations/0004_association_user_id.py5
-rw-r--r--welco/qualif/migrations/0005_auto_20151009_1110.py5
-rw-r--r--welco/qualif/migrations/0006_remove_association_user_id.py5
-rw-r--r--welco/qualif/migrations/0007_remove_association_triaged.py5
-rw-r--r--welco/qualif/migrations/0008_association_formdata_url_backoffice.py3
-rw-r--r--welco/qualif/models.py6
-rw-r--r--welco/settings.py3
-rw-r--r--welco/sources/counter/migrations/0001_initial.py5
-rw-r--r--welco/sources/counter/views.py8
-rw-r--r--welco/sources/mail/__init__.py3
-rw-r--r--welco/sources/mail/forms.py2
-rw-r--r--welco/sources/mail/maarch.py9
-rw-r--r--welco/sources/mail/management/commands/feed_mail.py2
-rw-r--r--welco/sources/mail/management/commands/feed_mail_maarch.py4
-rw-r--r--welco/sources/mail/migrations/0001_initial.py5
-rw-r--r--welco/sources/mail/migrations/0002_auto_20150831_1538.py5
-rw-r--r--welco/sources/mail/migrations/0003_auto_20151009_1144.py5
-rw-r--r--welco/sources/mail/migrations/0004_mail_contact_id.py5
-rw-r--r--welco/sources/mail/migrations/0005_auto_20151010_1819.py5
-rw-r--r--welco/sources/mail/migrations/0006_mail_note.py5
-rw-r--r--welco/sources/mail/migrations/0007_mail_mail_number.py5
-rw-r--r--welco/sources/mail/migrations/0008_remove_mail_mail_number.py5
-rw-r--r--welco/sources/mail/migrations/0009_mail_scanner_category.py3
-rw-r--r--welco/sources/mail/migrations/0010_mail_subject.py3
-rw-r--r--welco/sources/mail/migrations/0011_mail_reference.py3
-rw-r--r--welco/sources/mail/migrations/0012_mail_external_id.py3
-rw-r--r--welco/sources/mail/models.py4
-rw-r--r--welco/sources/mail/urls.py2
-rw-r--r--welco/sources/mail/utils.py2
-rw-r--r--welco/sources/mail/views.py20
-rw-r--r--welco/sources/phone/migrations/0001_initial.py3
-rw-r--r--welco/sources/phone/migrations/0002_auto_20151028_1635.py9
-rw-r--r--welco/sources/phone/migrations/0003_auto_20151103_1202.py5
-rw-r--r--welco/sources/phone/migrations/0004_auto_20160204_0252.py5
-rw-r--r--welco/sources/phone/models.py4
-rw-r--r--welco/sources/phone/views.py29
-rw-r--r--welco/static/css/style.css2
-rw-r--r--welco/urls.py10
-rw-r--r--welco/utils.py6
-rw-r--r--welco/views.py29
55 files changed, 129 insertions, 220 deletions
diff --git a/welco/contacts/forms.py b/welco/contacts/forms.py
index e9d890a..2aa1976 100644
--- a/welco/contacts/forms.py
+++ b/welco/contacts/forms.py
@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django import forms
-from django.utils.translation import ugettext_lazy as _, pgettext_lazy
-
+from django.utils.translation import pgettext_lazy
+from django.utils.translation import ugettext_lazy as _
DEFAULT_TITLE_CHOICES = (
('', ''),
diff --git a/welco/contacts/views.py b/welco/contacts/views.py
index 331195b..43c2dcd 100644
--- a/welco/contacts/views.py
+++ b/welco/contacts/views.py
@@ -17,9 +17,9 @@
import json
import logging
import random
-import requests
import time
+import requests
from django import template
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
@@ -27,14 +27,14 @@ from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt
-from django.views.generic import TemplateView, FormView
+from django.views.generic import FormView, TemplateView
from welco.utils import get_wcs_data, sign_url
from .forms import ContactAddForm
-class HomeZone(object):
+class HomeZone:
def __init__(self, request):
self.request = request
@@ -47,7 +47,7 @@ class ContactsZone(TemplateView):
template_name = 'contacts/zone.html'
def get_context_data(self, **kwargs):
- context = super(ContactsZone, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['source_pk'] = self.request.GET.get('source_pk')
if 'source_pk' in self.request.GET:
source_class = ContentType.objects.get(id=self.request.GET['source_type']).model_class()
@@ -68,7 +68,7 @@ zone = csrf_exempt(ContactsZone.as_view())
def search_json(request):
- user_groups = set([x.name for x in request.user.groups.all()])
+ user_groups = {x.name for x in request.user.groups.all()}
for channel in settings.CHANNEL_ROLES:
channel_groups = set(settings.CHANNEL_ROLES[channel])
if user_groups.intersection(channel_groups):
@@ -104,7 +104,7 @@ class ContactDetailFragmentView(TemplateView):
template_name = 'contacts/contact_detail_fragment.html'
def get_context_data(self, **kwargs):
- context = super(ContactDetailFragmentView, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
user_id = self.kwargs.get('slug').split('-')[-1]
user_details = get_wcs_data('api/users/%s/' % user_id)
diff --git a/welco/forms.py b/welco/forms.py
index 0c94561..b0cac84 100644
--- a/welco/forms.py
+++ b/welco/forms.py
@@ -24,7 +24,7 @@ class QualificationForm(forms.Form):
formdef_reference = forms.CharField(label=_('Associated Form'))
def __init__(self, user, *args, **kwargs):
- super(QualificationForm, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
params = {'backoffice-submission': 'on'}
if hasattr(user, 'saml_identifiers') and user.saml_identifiers.exists():
params['NameID'] = user.saml_identifiers.first().name_id
diff --git a/welco/kb/forms.py b/welco/kb/forms.py
index 9e0feef..b84d2fa 100644
--- a/welco/kb/forms.py
+++ b/welco/kb/forms.py
@@ -38,4 +38,4 @@ class PageForm(forms.ModelForm):
i += 1
slug = '%s-%s' % (base_slug, i)
self.instance.slug = slug
- return super(PageForm, self).save(commit=commit)
+ return super().save(commit=commit)
diff --git a/welco/kb/migrations/0001_initial.py b/welco/kb/migrations/0001_initial.py
index 10fdb7b..40cf809 100644
--- a/welco/kb/migrations/0001_initial.py
+++ b/welco/kb/migrations/0001_initial.py
@@ -1,8 +1,5 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
import ckeditor.fields
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/kb/migrations/0002_page_keywords.py b/welco/kb/migrations/0002_page_keywords.py
index b1980a6..0d5e3a7 100644
--- a/welco/kb/migrations/0002_page_keywords.py
+++ b/welco/kb/migrations/0002_page_keywords.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/kb/migrations/0003_page_tags.py b/welco/kb/migrations/0003_page_tags.py
index 0f76b13..80a9677 100644
--- a/welco/kb/migrations/0003_page_tags.py
+++ b/welco/kb/migrations/0003_page_tags.py
@@ -1,8 +1,5 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
import taggit.managers
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/kb/migrations/0004_remove_page_keywords.py b/welco/kb/migrations/0004_remove_page_keywords.py
index 099b634..c4826f2 100644
--- a/welco/kb/migrations/0004_remove_page_keywords.py
+++ b/welco/kb/migrations/0004_remove_page_keywords.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/kb/models.py b/welco/kb/models.py
index 7c40dfa..bd6370f 100644
--- a/welco/kb/models.py
+++ b/welco/kb/models.py
@@ -14,11 +14,10 @@
# 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.urls import reverse
+from ckeditor.fields import RichTextField
from django.db import models
+from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
-
-from ckeditor.fields import RichTextField
from taggit.managers import TaggableManager
diff --git a/welco/kb/search_indexes.py b/welco/kb/search_indexes.py
index ec24f70..3f723e6 100644
--- a/welco/kb/search_indexes.py
+++ b/welco/kb/search_indexes.py
@@ -14,9 +14,9 @@
# 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.utils.html import strip_tags
-from django.utils.six.moves.html_parser import HTMLParser
+import html
+from django.utils.html import strip_tags
from haystack import indexes
from .models import Page
@@ -33,7 +33,7 @@ class PageIndex(indexes.SearchIndex, indexes.Indexable):
return Page
def prepare_text(self, obj):
- return obj.title + ' ' + self.prepare_tags(obj) + ' ' + HTMLParser().unescape(strip_tags(obj.content))
+ return obj.title + ' ' + self.prepare_tags(obj) + ' ' + html.unescape(strip_tags(obj.content))
def prepare_text_auto(self, obj):
return self.prepare_text(obj)
diff --git a/welco/kb/views.py b/welco/kb/views.py
index 64366c4..3cf2e5d 100644
--- a/welco/kb/views.py
+++ b/welco/kb/views.py
@@ -20,20 +20,19 @@ from django import template
from django.conf import settings
from django.contrib.auth.decorators import login_required, user_passes_test
from django.core.exceptions import PermissionDenied
-from django.urls import reverse_lazy
from django.db.models import Count
from django.http import HttpResponse, HttpResponseRedirect
from django.template import RequestContext
+from django.urls import reverse_lazy
from django.views.decorators.csrf import csrf_exempt
-from django.views.generic import DetailView, CreateView, UpdateView, ListView, DeleteView, TemplateView
-
+from django.views.generic import CreateView, DeleteView, DetailView, ListView, TemplateView, UpdateView
from haystack.forms import SearchForm
from haystack.generic_views import SearchView
from haystack.query import SearchQuerySet
from taggit.models import Tag
-from .models import Page
from .forms import PageForm
+from .models import Page
def check_user_perms(user, access=False):
@@ -42,7 +41,7 @@ def check_user_perms(user, access=False):
allowed_roles.extend(settings.KB_ACCESS_ROLES)
if settings.KB_ROLE:
allowed_roles.append(settings.KB_ROLE) # legacy
- user_groups = set([x.name for x in user.groups.all()])
+ user_groups = {x.name for x in user.groups.all()}
return user_groups.intersection(allowed_roles)
@@ -56,10 +55,10 @@ class PageListView(ListView):
def dispatch(self, request, *args, **kwargs):
check_request_perms(request, access=True)
- return super(PageListView, self).dispatch(request, *args, **kwargs)
+ return super().dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs):
- context = super(PageListView, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['form'] = SearchForm()
context['can_manage'] = check_user_perms(self.request.user)
return context
@@ -74,7 +73,7 @@ class PageAddView(CreateView):
def dispatch(self, request, *args, **kwargs):
check_request_perms(request)
- return super(PageAddView, self).dispatch(request, *args, **kwargs)
+ return super().dispatch(request, *args, **kwargs)
page_add = login_required(PageAddView.as_view())
@@ -86,7 +85,7 @@ class PageEditView(UpdateView):
def dispatch(self, request, *args, **kwargs):
check_request_perms(request)
- return super(PageEditView, self).dispatch(request, *args, **kwargs)
+ return super().dispatch(request, *args, **kwargs)
page_edit = login_required(PageEditView.as_view())
@@ -97,10 +96,10 @@ class PageDetailView(DetailView):
def dispatch(self, request, *args, **kwargs):
check_request_perms(request, access=True)
- return super(PageDetailView, self).dispatch(request, *args, **kwargs)
+ return super().dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs):
- context = super(PageDetailView, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['can_manage'] = check_user_perms(self.request.user)
return context
@@ -122,7 +121,7 @@ class PageDeleteView(DeleteView):
def dispatch(self, request, *args, **kwargs):
check_request_perms(request)
- return super(PageDeleteView, self).dispatch(request, *args, **kwargs)
+ return super().dispatch(request, *args, **kwargs)
page_delete = login_required(PageDeleteView.as_view())
@@ -134,7 +133,7 @@ class PageSearchView(SearchView):
def dispatch(self, request, *args, **kwargs):
check_request_perms(request, access=True)
- return super(PageSearchView, self).dispatch(request, *args, **kwargs)
+ return super().dispatch(request, *args, **kwargs)
page_search = login_required(PageSearchView.as_view())
@@ -144,7 +143,7 @@ class KbZone(TemplateView):
template_name = 'kb/zone.html'
def get_context_data(self, **kwargs):
- context = super(KbZone, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['source_pk'] = self.request.GET.get('source_pk')
context['form'] = SearchForm()
context['tags'] = (
@@ -190,7 +189,7 @@ def page_search_json(request):
return response
-class HomeZone(object):
+class HomeZone:
def __init__(self, request):
self.request = request
diff --git a/welco/monkeypatch.py b/welco/monkeypatch.py
index 63116a0..c70bfbb 100644
--- a/welco/monkeypatch.py
+++ b/welco/monkeypatch.py
@@ -14,18 +14,17 @@
# 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.urls import reverse
+import ckeditor.widgets
from django.forms.utils import flatatt
from django.template.loader import render_to_string
+from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from django.utils.translation import get_language
-import ckeditor.widgets
-
-def ckeditor_render(self, name, value, attrs=None):
+def ckeditor_render(self, name, value, attrs=None, renderer=None):
if value is None:
value = ''
final_attrs = {'name': name}
diff --git a/welco/qualif/migrations/0001_initial.py b/welco/qualif/migrations/0001_initial.py
index 61c9943..e4de212 100644
--- a/welco/qualif/migrations/0001_initial.py
+++ b/welco/qualif/migrations/0001_initial.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/qualif/migrations/0002_association_triaged.py b/welco/qualif/migrations/0002_association_triaged.py
index b1b0a47..faf44c5 100644
--- a/welco/qualif/migrations/0002_association_triaged.py
+++ b/welco/qualif/migrations/0002_association_triaged.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/qualif/migrations/0003_association_comments.py b/welco/qualif/migrations/0003_association_comments.py
index 7accd18..a3e82cd 100644
--- a/welco/qualif/migrations/0003_association_comments.py
+++ b/welco/qualif/migrations/0003_association_comments.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/qualif/migrations/0004_association_user_id.py b/welco/qualif/migrations/0004_association_user_id.py
index 476ba2d..fc1454c 100644
--- a/welco/qualif/migrations/0004_association_user_id.py
+++ b/welco/qualif/migrations/0004_association_user_id.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/qualif/migrations/0005_auto_20151009_1110.py b/welco/qualif/migrations/0005_auto_20151009_1110.py
index 8c83224..2df6dcf 100644
--- a/welco/qualif/migrations/0005_auto_20151009_1110.py
+++ b/welco/qualif/migrations/0005_auto_20151009_1110.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/qualif/migrations/0006_remove_association_user_id.py b/welco/qualif/migrations/0006_remove_association_user_id.py
index 49a22bb..94240c4 100644
--- a/welco/qualif/migrations/0006_remove_association_user_id.py
+++ b/welco/qualif/migrations/0006_remove_association_user_id.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/qualif/migrations/0007_remove_association_triaged.py b/welco/qualif/migrations/0007_remove_association_triaged.py
index 5d79a2a..680baba 100644
--- a/welco/qualif/migrations/0007_remove_association_triaged.py
+++ b/welco/qualif/migrations/0007_remove_association_triaged.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/qualif/migrations/0008_association_formdata_url_backoffice.py b/welco/qualif/migrations/0008_association_formdata_url_backoffice.py
index 91ddc18..03c8900 100644
--- a/welco/qualif/migrations/0008_association_formdata_url_backoffice.py
+++ b/welco/qualif/migrations/0008_association_formdata_url_backoffice.py
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from django.db import migrations, models
diff --git a/welco/qualif/models.py b/welco/qualif/models.py
index 6eaa6b5..0da32c4 100644
--- a/welco/qualif/models.py
+++ b/welco/qualif/models.py
@@ -14,13 +14,13 @@
# 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.urls import reverse
+from django.contrib.contenttypes.models import ContentType
from django.db import models
+from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
-from welco.utils import get_wcs_formdef_details, push_wcs_formdata, get_wcs_services
+from welco.utils import get_wcs_formdef_details, get_wcs_services, push_wcs_formdata
class Association(models.Model):
diff --git a/welco/settings.py b/welco/settings.py
index 9bc97ff..cfe3dc0 100644
--- a/welco/settings.py
+++ b/welco/settings.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
"""
Django settings for welco project.
@@ -11,6 +9,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
"""
import os
+
from django.conf import global_settings
from django.utils.translation import ugettext_lazy as _
diff --git a/welco/sources/counter/migrations/0001_initial.py b/welco/sources/counter/migrations/0001_initial.py
index d154133..2962d06 100644
--- a/welco/sources/counter/migrations/0001_initial.py
+++ b/welco/sources/counter/migrations/0001_initial.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/counter/views.py b/welco/sources/counter/views.py
index 6138f90..e45e9c9 100644
--- a/welco/sources/counter/views.py
+++ b/welco/sources/counter/views.py
@@ -18,17 +18,17 @@ import json
from django import template
from django.conf import settings
+from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
+from django.http import HttpResponse
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt
-from django.contrib.auth.decorators import login_required
-from django.http import HttpResponse
from django.views.generic import TemplateView
from .models import CounterPresence
-class Home(object):
+class Home:
source_key = 'counter'
def __init__(self, request, **kwargs):
@@ -46,7 +46,7 @@ class CounterZone(TemplateView):
template_name = 'welco/counter_home.html'
def get_context_data(self, **kwargs):
- context = super(CounterZone, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['source_type'] = ContentType.objects.get_for_model(CounterPresence)
new_source = CounterPresence()
new_source.save()
diff --git a/welco/sources/mail/__init__.py b/welco/sources/mail/__init__.py
index 5a86f3f..94c300e 100644
--- a/welco/sources/mail/__init__.py
+++ b/welco/sources/mail/__init__.py
@@ -26,9 +26,10 @@ class AppConfig(django.apps.AppConfig):
return urls.urlpatterns
def ready(self):
- from welco.qualif.models import Association
from django.db.models import signals
+ from welco.qualif.models import Association
+
signals.post_save.connect(self.association_post_save, sender=Association)
def association_post_save(self, sender, instance, **kwargs):
diff --git a/welco/sources/mail/forms.py b/welco/sources/mail/forms.py
index fd4136a..351496a 100644
--- a/welco/sources/mail/forms.py
+++ b/welco/sources/mail/forms.py
@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django import forms
-from django.utils.translation import ugettext_lazy as _
from django.conf import settings
+from django.utils.translation import ugettext_lazy as _
class MailQualificationForm(forms.Form):
diff --git a/welco/sources/mail/maarch.py b/welco/sources/mail/maarch.py
index f84f46a..16d75b2 100644
--- a/welco/sources/mail/maarch.py
+++ b/welco/sources/mail/maarch.py
@@ -16,11 +16,10 @@
import base64
+import requests
from dateutil.parser import parse as parse_datetime
from django.utils import six
from django.utils.six.moves.urllib import parse as urlparse
-
-import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
@@ -29,7 +28,7 @@ class MaarchError(Exception):
pass
-class MaarchCourrier(object):
+class MaarchCourrier:
url = None
username = None
password = None
@@ -44,7 +43,7 @@ class MaarchCourrier(object):
def __repr__(self):
return '<MaarchCourrier url:%s>' % self.url
- class Courrier(object):
+ class Courrier:
content = None
format = None
status = None
@@ -89,7 +88,7 @@ class MaarchCourrier(object):
data = {key: self.__dict__[key] for key in self.__dict__ if key not in excluded_keys}
if data:
for key, value in data.items():
- if isinstance(value, six.string_types):
+ if isinstance(value, str):
d.append({'column': key, 'value': value, 'type': 'string'})
elif isinstance(value, int):
d.append({'column': key, 'value': str(value), 'type': 'int'})
diff --git a/welco/sources/mail/management/commands/feed_mail.py b/welco/sources/mail/management/commands/feed_mail.py
index baef5ea..45dc0d0 100644
--- a/welco/sources/mail/management/commands/feed_mail.py
+++ b/welco/sources/mail/management/commands/feed_mail.py
@@ -14,8 +14,8 @@
# 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 optparse import make_option
import os
+from optparse import make_option
from django.core.files import File
from django.core.management.base import BaseCommand, CommandError
diff --git a/welco/sources/mail/management/commands/feed_mail_maarch.py b/welco/sources/mail/management/commands/feed_mail_maarch.py
index 88631c3..9856fc3 100644
--- a/welco/sources/mail/management/commands/feed_mail_maarch.py
+++ b/welco/sources/mail/management/commands/feed_mail_maarch.py
@@ -14,12 +14,12 @@
# 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 optparse import make_option
import os
+from optparse import make_option
+from django.conf import settings
from django.core.files.base import ContentFile
from django.core.management.base import BaseCommand, CommandError
-from django.conf import settings
from django.db import transaction
from ...models import Mail
diff --git a/welco/sources/mail/migrations/0001_initial.py b/welco/sources/mail/migrations/0001_initial.py
index b6ef78c..a243fc5 100644
--- a/welco/sources/mail/migrations/0001_initial.py
+++ b/welco/sources/mail/migrations/0001_initial.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/mail/migrations/0002_auto_20150831_1538.py b/welco/sources/mail/migrations/0002_auto_20150831_1538.py
index 77dd556..876776c 100644
--- a/welco/sources/mail/migrations/0002_auto_20150831_1538.py
+++ b/welco/sources/mail/migrations/0002_auto_20150831_1538.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/mail/migrations/0003_auto_20151009_1144.py b/welco/sources/mail/migrations/0003_auto_20151009_1144.py
index 01d43a9..4d847e3 100644
--- a/welco/sources/mail/migrations/0003_auto_20151009_1144.py
+++ b/welco/sources/mail/migrations/0003_auto_20151009_1144.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/mail/migrations/0004_mail_contact_id.py b/welco/sources/mail/migrations/0004_mail_contact_id.py
index adc0926..eae68ac 100644
--- a/welco/sources/mail/migrations/0004_mail_contact_id.py
+++ b/welco/sources/mail/migrations/0004_mail_contact_id.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/mail/migrations/0005_auto_20151010_1819.py b/welco/sources/mail/migrations/0005_auto_20151010_1819.py
index 0967013..781f2d6 100644
--- a/welco/sources/mail/migrations/0005_auto_20151010_1819.py
+++ b/welco/sources/mail/migrations/0005_auto_20151010_1819.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/mail/migrations/0006_mail_note.py b/welco/sources/mail/migrations/0006_mail_note.py
index 6fda77a..988df12 100644
--- a/welco/sources/mail/migrations/0006_mail_note.py
+++ b/welco/sources/mail/migrations/0006_mail_note.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/mail/migrations/0007_mail_mail_number.py b/welco/sources/mail/migrations/0007_mail_mail_number.py
index 6aa7b9c..6be26ed 100644
--- a/welco/sources/mail/migrations/0007_mail_mail_number.py
+++ b/welco/sources/mail/migrations/0007_mail_mail_number.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/mail/migrations/0008_remove_mail_mail_number.py b/welco/sources/mail/migrations/0008_remove_mail_mail_number.py
index 3f5187d..6a0cc40 100644
--- a/welco/sources/mail/migrations/0008_remove_mail_mail_number.py
+++ b/welco/sources/mail/migrations/0008_remove_mail_mail_number.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/mail/migrations/0009_mail_scanner_category.py b/welco/sources/mail/migrations/0009_mail_scanner_category.py
index e41d8e3..9c0222a 100644
--- a/welco/sources/mail/migrations/0009_mail_scanner_category.py
+++ b/welco/sources/mail/migrations/0009_mail_scanner_category.py
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from django.db import migrations, models
diff --git a/welco/sources/mail/migrations/0010_mail_subject.py b/welco/sources/mail/migrations/0010_mail_subject.py
index e7642f2..e2f8743 100644
--- a/welco/sources/mail/migrations/0010_mail_subject.py
+++ b/welco/sources/mail/migrations/0010_mail_subject.py
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from django.db import migrations, models
diff --git a/welco/sources/mail/migrations/0011_mail_reference.py b/welco/sources/mail/migrations/0011_mail_reference.py
index a1af01e..e63fe43 100644
--- a/welco/sources/mail/migrations/0011_mail_reference.py
+++ b/welco/sources/mail/migrations/0011_mail_reference.py
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from django.db import migrations, models
diff --git a/welco/sources/mail/migrations/0012_mail_external_id.py b/welco/sources/mail/migrations/0012_mail_external_id.py
index 430f910..d1ae7c3 100644
--- a/welco/sources/mail/migrations/0012_mail_external_id.py
+++ b/welco/sources/mail/migrations/0012_mail_external_id.py
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from django.db import migrations, models
diff --git a/welco/sources/mail/models.py b/welco/sources/mail/models.py
index 365847e..ea185e0 100644
--- a/welco/sources/mail/models.py
+++ b/welco/sources/mail/models.py
@@ -15,16 +15,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
-import requests
import subprocess
+import requests
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType
-from django.urls import reverse
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
+from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from welco.qualif.models import Association
diff --git a/welco/sources/mail/urls.py b/welco/sources/mail/urls.py
index 5df4848..359ede8 100644
--- a/welco/sources/mail/urls.py
+++ b/welco/sources/mail/urls.py
@@ -16,7 +16,7 @@
from django.conf.urls import url
-from .views import viewer, feeder, qualification_save, edit_note, note, reject, mail_count, mail_response
+from .views import edit_note, feeder, mail_count, mail_response, note, qualification_save, reject, viewer
urlpatterns = [
url('viewer/$', viewer, name='mail-viewer'),
diff --git a/welco/sources/mail/utils.py b/welco/sources/mail/utils.py
index 2d9b1a0..ee4b97d 100644
--- a/welco/sources/mail/utils.py
+++ b/welco/sources/mail/utils.py
@@ -32,7 +32,7 @@ class WelcoMaarchCourrier(MaarchCourrier):
grc_response_status,
batch_size=10,
):
- super(WelcoMaarchCourrier, self).__init__(url, username, password)
+ super().__init__(url, username, password)
self.grc_status = grc_status
self.grc_received_status = grc_received_status
self.grc_send_status = grc_send_status
diff --git a/welco/sources/mail/views.py b/welco/sources/mail/views.py
index 64979a3..bccd171 100644
--- a/welco/sources/mail/views.py
+++ b/welco/sources/mail/views.py
@@ -18,27 +18,25 @@ import json
import logging
from django import template
+from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
-from django.contrib import messages
-from django.urls import reverse
-from django.template import RequestContext
+from django.db.transaction import atomic
from django.http import HttpResponse, HttpResponseRedirect
+from django.template import RequestContext
+from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
-from django.db.transaction import atomic
-
-from rest_framework import authentication, serializers, permissions, status
+from rest_framework import authentication, permissions, serializers, status
from rest_framework.generics import GenericAPIView
from rest_framework.response import Response
from welco.utils import response_for_json
-from .models import Mail
from .forms import MailQualificationForm
-from .utils import get_maarch, MaarchError
-
+from .models import Mail
+from .utils import MaarchError, get_maarch
logger = logging.getLogger(__name__)
@@ -64,7 +62,7 @@ class Feeder(TemplateView):
feeder = login_required(csrf_exempt(Feeder.as_view()))
-class Home(object):
+class Home:
source_key = 'mail'
display_filter = True
allow_reject = True
@@ -112,7 +110,7 @@ class EditNote(TemplateView):
template_name = 'welco/mail_edit_note.html'
def get_context_data(self, **kwargs):
- context = super(EditNote, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['mail'] = Mail.objects.get(id=self.request.GET['mail'])
return context
diff --git a/welco/sources/phone/migrations/0001_initial.py b/welco/sources/phone/migrations/0001_initial.py
index 6072cd7..3074b62 100644
--- a/welco/sources/phone/migrations/0001_initial.py
+++ b/welco/sources/phone/migrations/0001_initial.py
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from django.db import migrations, models
diff --git a/welco/sources/phone/migrations/0002_auto_20151028_1635.py b/welco/sources/phone/migrations/0002_auto_20151028_1635.py
index 4c1dd3d..8154322 100644
--- a/welco/sources/phone/migrations/0002_auto_20151028_1635.py
+++ b/welco/sources/phone/migrations/0002_auto_20151028_1635.py
@@ -1,11 +1,8 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-from django.utils.timezone import utc
-from django.utils.timezone import now
import datetime
+
from django.conf import settings
+from django.db import migrations, models
+from django.utils.timezone import now, utc
class Migration(migrations.Migration):
diff --git a/welco/sources/phone/migrations/0003_auto_20151103_1202.py b/welco/sources/phone/migrations/0003_auto_20151103_1202.py
index ea90523..4348653 100644
--- a/welco/sources/phone/migrations/0003_auto_20151103_1202.py
+++ b/welco/sources/phone/migrations/0003_auto_20151103_1202.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/phone/migrations/0004_auto_20160204_0252.py b/welco/sources/phone/migrations/0004_auto_20160204_0252.py
index 10efdac..12e2eee 100644
--- a/welco/sources/phone/migrations/0004_auto_20160204_0252.py
+++ b/welco/sources/phone/migrations/0004_auto_20160204_0252.py
@@ -1,7 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/welco/sources/phone/models.py b/welco/sources/phone/models.py
index 7d152cd..c3f0c67 100644
--- a/welco/sources/phone/models.py
+++ b/welco/sources/phone/models.py
@@ -18,10 +18,10 @@ import logging
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
-from django.urls import reverse
from django.db import models
-from django.utils.translation import ugettext_lazy as _
+from django.urls import reverse
from django.utils.timezone import now, timedelta
+from django.utils.translation import ugettext_lazy as _
from welco.qualif.models import Association
diff --git a/welco/sources/phone/views.py b/welco/sources/phone/views.py
index dc50404..f3143f3 100644
--- a/welco/sources/phone/views.py
+++ b/welco/sources/phone/views.py
@@ -19,20 +19,20 @@ import logging
from django import template
from django.conf import settings
+from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
+from django.http import HttpResponse, HttpResponseBadRequest
from django.template import RequestContext
-from django.views.decorators.csrf import csrf_exempt
-from django.contrib.auth.decorators import login_required
-from django.http import HttpResponseBadRequest, HttpResponse
from django.utils import six
from django.utils.encoding import force_text
from django.utils.timezone import now
+from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
from .models import PhoneCall, PhoneLine
-class Home(object):
+class Home:
source_key = 'phone'
def __init__(self, request, **kwargs):
@@ -60,7 +60,7 @@ class PhoneZone(TemplateView):
username = username[0].split('@', 1)[0][:80] # remove realm
if username:
PhoneLine.take(callee=username, user=self.request.user)
- context = super(PhoneZone, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['source_type'] = ContentType.objects.get_for_model(PhoneCall)
context['phonelines'] = PhoneLine.objects.filter(users__id=self.request.user.id)
context['phonecalls'] = PhoneCall.get_current_calls(self.request.user)
@@ -87,15 +87,18 @@ def call_event(request):
try:
payload = json.loads(force_text(request.body))
assert isinstance(payload, dict), 'payload is not a JSON object'
- assert set(payload.keys()) <= set(
- ['event', 'caller', 'callee', 'data']
- ), 'payload keys must be "event", "caller", "callee" and optionnaly "data"'
- assert set(['event', 'caller', 'callee']) <= set(
+ assert set(payload.keys()) <= {
+ 'event',
+ 'caller',
+ 'callee',
+ 'data',
+ }, 'payload keys must be "event", "caller", "callee" and optionnaly "data"'
+ assert {'event', 'caller', 'callee'} <= set(
payload.keys()
), 'payload keys must be "event", "caller", "callee" and optionnaly "data"'
assert payload['event'] in ('start', 'stop'), 'event must be "start" or "stop"'
- assert isinstance(payload['caller'], six.string_types), 'caller must be a string'
- assert isinstance(payload['callee'], six.string_types), 'callee must be a string'
+ assert isinstance(payload['caller'], str), 'caller must be a string'
+ assert isinstance(payload['callee'], str), 'callee must be a string'
if 'data' in payload:
assert isinstance(payload['data'], dict), 'data must be a JSON object'
except (TypeError, ValueError, AssertionError) as e:
@@ -208,7 +211,7 @@ def take_line(request):
json.dumps({'err': 1, 'msg': force_text(e)}), content_type='application/json'
)
PhoneLine.take(payload['callee'], request.user)
- logger.info(u'user %s took line %s', request.user, payload['callee'])
+ logger.info('user %s took line %s', request.user, payload['callee'])
return HttpResponse(json.dumps({'err': 0}), content_type='application/json')
@@ -229,5 +232,5 @@ def release_line(request):
json.dumps({'err': 1, 'msg': force_text(e)}), content_type='application/json'
)
PhoneLine.release(payload['callee'], request.user)
- logger.info(u'user %s released line %s', request.user, payload['callee'])
+ logger.info('user %s released line %s', request.user, payload['callee'])
return HttpResponse(json.dumps({'err': 0}), content_type='application/json')
diff --git a/welco/static/css/style.css b/welco/static/css/style.css
index 07d06c6..60000cf 100644
--- a/welco/static/css/style.css
+++ b/welco/static/css/style.css
@@ -9,7 +9,7 @@ body.welco-home div#main-content {
height: calc(100vh - 61px); /* #top 60px + #top border 1px */
}
-body[data-environment-label] div#main-content {
+body.welco-home[data-environment-label] div#main-content {
height: calc(100vh - 71px); /* #top 60px + #top border 1px + #header bottom-border 10px */
}
diff --git a/welco/urls.py b/welco/urls.py
index fc9fc5b..db0400e 100644
--- a/welco/urls.py
+++ b/welco/urls.py
@@ -14,6 +14,7 @@
# 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 ckeditor import views as ckeditor_views
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
@@ -21,15 +22,12 @@ from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.decorators.cache import never_cache
-from ckeditor import views as ckeditor_views
-
-from . import apps
-from .kb.views import kb_manager_required
-
-import welco.views
import welco.contacts.views
import welco.kb.views
+import welco.views
+from . import apps
+from .kb.views import kb_manager_required
urlpatterns = [
url(r'^$', welco.views.home, name='home'),
diff --git a/welco/utils.py b/welco/utils.py
index b179003..3a68648 100644
--- a/welco/utils.py
+++ b/welco/utils.py
@@ -16,18 +16,18 @@
import base64
import datetime
-import hmac
import hashlib
+import hmac
import json
import random
import re
-import requests
+import requests
from django.conf import settings
from django.core.cache import cache
from django.http import HttpResponse, HttpResponseBadRequest
from django.utils.encoding import smart_bytes
-from django.utils.http import urlencode, quote
+from django.utils.http import quote, urlencode
from django.utils.six.moves.urllib import parse as urlparse
diff --git a/welco/views.py b/welco/views.py
index 0e69fa8..860a549 100644
--- a/welco/views.py
+++ b/welco/views.py
@@ -16,17 +16,17 @@
import json
+from django import template
from django.conf import settings
from django.contrib.auth import logout as auth_logout
from django.contrib.auth import views as auth_views
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
-from django.urls import reverse
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import resolve_url
-from django import template
from django.template import RequestContext
+from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.http import quote
from django.utils.translation import ugettext_lazy as _
@@ -38,13 +38,14 @@ if 'mellon' in settings.INSTALLED_APPS:
else:
get_idps = lambda: []
-from .sources.mail.views import Home as MailHome
-from .sources.phone.views import Home as PhoneHome
-from .sources.counter.views import Home as CounterHome
-from .qualif.models import Association
-from .kb.views import HomeZone as KbHomeZone, check_user_perms as check_kb_user_perms
from .contacts.views import HomeZone as ContactsHomeZone
from .forms import QualificationForm
+from .kb.views import HomeZone as KbHomeZone
+from .kb.views import check_user_perms as check_kb_user_perms
+from .qualif.models import Association
+from .sources.counter.views import Home as CounterHome
+from .sources.mail.views import Home as MailHome
+from .sources.phone.views import Home as PhoneHome
class LoginView(auth_views.LoginView):
@@ -59,7 +60,7 @@ class LoginView(auth_views.LoginView):
except KeyError:
return HttpResponseBadRequest('invalid value for "next" parameter')
return HttpResponseRedirect(resolve_url('mellon_login') + '?next=' + quoted_next_url)
- return super(LoginView, self).dispatch(request, *args, **kwargs)
+ return super().dispatch(request, *args, **kwargs)
login = LoginView.as_view()
@@ -80,7 +81,7 @@ class Qualification(TemplateView):
template_name = 'welco/qualification_no_validation.html'
def get_context_data(self, **kwargs):
- context = super(Qualification, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['form'] = QualificationForm(self.request.user)
context['source_type'] = self.request.GET['source_type']
source_type = ContentType.objects.get(id=self.request.GET['source_type'])
@@ -112,21 +113,21 @@ class ChannelHome(TemplateView):
source_klass = MailHome
def check_user_ok(self):
- user_groups = set([x.name for x in self.request.user.groups.all()])
+ user_groups = {x.name for x in self.request.user.groups.all()}
channel_groups = set(settings.CHANNEL_ROLES[self.source_klass.source_key])
return user_groups.intersection(channel_groups)
def get_context_data(self, **kwargs):
if not self.check_user_ok():
raise PermissionDenied()
- context = super(ChannelHome, self).get_context_data(**kwargs)
+ context = super().get_context_data(**kwargs)
context['panels'] = [{'key': x, 'zone_url': x + '-zone'} for x in settings.SCREEN_PANELS]
context['source'] = self.source_klass(self.request, **kwargs)
context['kb'] = KbHomeZone(self.request)
context['contacts'] = ContactsHomeZone(self.request)
context['channels'] = []
- user_groups = set([x.name for x in self.request.user.groups.all()])
+ user_groups = {x.name for x in self.request.user.groups.all()}
for channel in settings.CHANNEL_ROLES:
channel_groups = set(settings.CHANNEL_ROLES[channel])
if user_groups.intersection(channel_groups):
@@ -136,7 +137,7 @@ class ChannelHome(TemplateView):
@login_required
def home(request):
- user_groups = set([x.name for x in request.user.groups.all()])
+ user_groups = {x.name for x in request.user.groups.all()}
for channel in settings.CHANNEL_ROLES:
channel_groups = set(settings.CHANNEL_ROLES[channel])
if user_groups.intersection(channel_groups):
@@ -209,7 +210,7 @@ def create_formdata(request, *args, **kwargs):
@login_required
def menu_json(request):
response = HttpResponse(content_type='application/json')
- user_groups = set([x.name for x in request.user.groups.all()])
+ user_groups = {x.name for x in request.user.groups.all()}
menu = []
labels = {
'mail': _('Mails'),