This commit is contained in:
parent
229479409e
commit
98dccb4964
|
@ -1,8 +0,0 @@
|
||||||
import django.apps
|
|
||||||
|
|
||||||
|
|
||||||
class AppConfig(django.apps.AppConfig):
|
|
||||||
name = 'docbow_project.docbow'
|
|
||||||
|
|
||||||
def ready(self):
|
|
||||||
pass
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class AppSettings:
|
class AppSettings:
|
||||||
__DEFAULTS = {
|
__DEFAULTS = {
|
||||||
'PERSONAL_EMAIL': True,
|
'PERSONAL_EMAIL': True,
|
||||||
|
@ -67,8 +70,6 @@ class AppSettings:
|
||||||
return getattr(settings, self.__prefix + name, self.__DEFAULTS[name])
|
return getattr(settings, self.__prefix + name, self.__DEFAULTS[name])
|
||||||
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
app_settings = AppSettings(prefix='DOCBOW_')
|
app_settings = AppSettings(prefix='DOCBOW_')
|
||||||
app_settings.__name__ = __name__
|
app_settings.__name__ = __name__
|
||||||
sys.modules[__name__] = app_settings
|
sys.modules[__name__] = app_settings
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import django.apps
|
||||||
|
|
||||||
|
|
||||||
|
class AppConfig(django.apps.AppConfig):
|
||||||
|
name = 'docbow_project.docbow'
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
from . import signals # noqa: F401
|
|
@ -4,6 +4,7 @@ import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
|
import unicodedata
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
@ -11,9 +12,12 @@ from django.conf import settings
|
||||||
from django.contrib.admin.widgets import FilteredSelectMultiple as AdminFilteredSelectMultiple
|
from django.contrib.admin.widgets import FilteredSelectMultiple as AdminFilteredSelectMultiple
|
||||||
from django.contrib.auth.forms import PasswordChangeForm, PasswordResetForm
|
from django.contrib.auth.forms import PasswordChangeForm, PasswordResetForm
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib.auth.tokens import default_token_generator
|
||||||
|
from django.contrib.sites.shortcuts import get_current_site
|
||||||
from django.db.models.query import Q
|
from django.db.models.query import Q
|
||||||
from django.forms import CharField, EmailField, Form, ModelChoiceField, ModelForm, Textarea, ValidationError
|
from django.forms import CharField, EmailField, Form, ModelChoiceField, ModelForm, Textarea, ValidationError
|
||||||
from django.utils.encoding import force_str
|
from django.utils.encoding import force_bytes, force_str
|
||||||
|
from django.utils.http import urlsafe_base64_encode
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django_journal import journal as django_journal
|
from django_journal import journal as django_journal
|
||||||
|
|
||||||
|
@ -483,14 +487,6 @@ class ProfileForm(ModelForm):
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
import unicodedata
|
|
||||||
|
|
||||||
from django.contrib.auth.tokens import default_token_generator
|
|
||||||
from django.contrib.sites.shortcuts import get_current_site
|
|
||||||
from django.utils.encoding import force_bytes
|
|
||||||
from django.utils.http import urlsafe_base64_encode
|
|
||||||
|
|
||||||
|
|
||||||
def _unicode_ci_compare(s1, s2):
|
def _unicode_ci_compare(s1, s2):
|
||||||
"""
|
"""
|
||||||
Perform case-insensitive comparison of two identifiers, using the
|
Perform case-insensitive comparison of two identifiers, using the
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.utils.encoding import force_str
|
from django.utils.encoding import force_str
|
||||||
|
|
||||||
|
@ -43,21 +43,15 @@ class Command(BaseCommand):
|
||||||
mailing_list, created = MailingList.objects.get_or_create(
|
mailing_list, created = MailingList.objects.get_or_create(
|
||||||
name=force_str(options['ml_name'], locale_encoding)
|
name=force_str(options['ml_name'], locale_encoding)
|
||||||
)
|
)
|
||||||
try:
|
for name in options['add_list']:
|
||||||
for l in options['add_list']:
|
ml = get_object(MailingList, name)
|
||||||
l = get_object(MailingList, l)
|
mailing_list.mailing_list_members.add(ml)
|
||||||
mailing_list.mailing_list_members.add(l)
|
for name in options['remove_list']:
|
||||||
for l in options['remove_list']:
|
ml = get_object(MailingList, name)
|
||||||
l = get_object(MailingList, l)
|
mailing_list.mailing_list_members.remove(ml)
|
||||||
mailing_list.mailing_list_members.remove(l)
|
for g in options['add_user']:
|
||||||
except MailingList.DoesNotExist:
|
g = get_object(User, g)
|
||||||
raise CommandError('list %r does not exist' % l)
|
mailing_list.members.add(g)
|
||||||
try:
|
for g in options['remove_user']:
|
||||||
for g in options['add_user']:
|
g = get_object(User, g)
|
||||||
g = get_object(User, g)
|
mailing_list.members.remove(g)
|
||||||
mailing_list.members.add(g)
|
|
||||||
for g in options['remove_user']:
|
|
||||||
g = get_object(User, g)
|
|
||||||
mailing_list.members.remove(g)
|
|
||||||
except User.DoesNotExist:
|
|
||||||
raise CommandError('user %r does not exist' % g)
|
|
||||||
|
|
|
@ -58,24 +58,18 @@ List and groups can be referred by name or by id.
|
||||||
user.is_active = options['activate']
|
user.is_active = options['activate']
|
||||||
if options['superuser'] is not None:
|
if options['superuser'] is not None:
|
||||||
user.is_superuser = options['superuser']
|
user.is_superuser = options['superuser']
|
||||||
try:
|
for name in options['add_list']:
|
||||||
for l in options['add_list']:
|
ml = get_object(MailingList, name)
|
||||||
l = get_object(MailingList, l)
|
ml.members.add(user)
|
||||||
l.members.add(user)
|
for name in options['remove_list']:
|
||||||
for l in options['remove_list']:
|
ml = get_object(MailingList, name)
|
||||||
l = get_object(MailingList, l)
|
ml.members.remove(user)
|
||||||
l.members.remove(user)
|
for g in options['add_group']:
|
||||||
except MailingList.DoesNotExist:
|
g = get_object(Group, g)
|
||||||
raise CommandError('list %r does not exist' % l)
|
user.groups.add(g)
|
||||||
try:
|
for g in options['remove_group']:
|
||||||
for g in options['add_group']:
|
g = get_object(Group, g)
|
||||||
g = get_object(Group, g)
|
user.groups.remove(g)
|
||||||
user.groups.add(g)
|
|
||||||
for g in options['remove_group']:
|
|
||||||
g = get_object(Group, g)
|
|
||||||
user.groups.remove(g)
|
|
||||||
except Group.DoesNotExist:
|
|
||||||
raise CommandError('group %r does not exist' % g)
|
|
||||||
profile, created = DocbowProfile.objects.get_or_create(user=user)
|
profile, created = DocbowProfile.objects.get_or_create(user=user)
|
||||||
if options['mobile_phone']:
|
if options['mobile_phone']:
|
||||||
profile.mobile_phone = force_str(options['mobile_phone'], 'utf-8')
|
profile.mobile_phone = force_str(options['mobile_phone'], 'utf-8')
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def timestamp_logs(self, path):
|
def timestamp_logs(self, path):
|
||||||
with open(os.path.join(path, 'log-timestamp.der'), 'w') as f:
|
with open(os.path.join(path, 'log-timestamp.der'), 'w') as f:
|
||||||
with open(os.path.join(path, 'log.csv')) as log_handle:
|
with open(os.path.join(path, 'log.csv')):
|
||||||
tst = str(time.time())
|
tst = str(time.time())
|
||||||
f.write(tst)
|
f.write(tst)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import csv
|
import csv
|
||||||
|
import functools
|
||||||
import os.path
|
import os.path
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
@ -108,7 +109,7 @@ class Command(BaseCommand):
|
||||||
d = dict(zip(first, line))
|
d = dict(zip(first, line))
|
||||||
self.synthesis(d, **options)
|
self.synthesis(d, **options)
|
||||||
all_users.append(d)
|
all_users.append(d)
|
||||||
all_profiles = set(reduce(list.__add__, [x['profil'] for x in all_users]))
|
all_profiles = set(functools.reduce(list.__add__, [x['profil'] for x in all_users]))
|
||||||
profiles = dict()
|
profiles = dict()
|
||||||
count_created, count_modified = 0, 0
|
count_created, count_modified = 0, 0
|
||||||
for profile in filter(None, all_profiles):
|
for profile in filter(None, all_profiles):
|
||||||
|
@ -134,7 +135,9 @@ class Command(BaseCommand):
|
||||||
lambda x: auth_models.Group.objects.get_or_create(name=x)[0], user['groupe']
|
lambda x: auth_models.Group.objects.get_or_create(name=x)[0], user['groupe']
|
||||||
)
|
)
|
||||||
user_instance.groups = user_groups
|
user_instance.groups = user_groups
|
||||||
user_instance.is_staff = reduce(bool.__or__, ['Administrateur' in x for x in user['groupe']])
|
user_instance.is_staff = functools.reduce(
|
||||||
|
bool.__or__, ['Administrateur' in x for x in user['groupe']]
|
||||||
|
)
|
||||||
if user.get('password'):
|
if user.get('password'):
|
||||||
password = user.get('password')
|
password = user.get('password')
|
||||||
if password.startswith('sha1$'):
|
if password.startswith('sha1$'):
|
||||||
|
|
|
@ -40,19 +40,13 @@ class Command(BaseCommand):
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
raise CommandError('user %r does not exist' % options['sender'])
|
raise CommandError('user %r does not exist' % options['sender'])
|
||||||
to_lists = []
|
to_lists = []
|
||||||
try:
|
for name in options.get('to_list') or []:
|
||||||
for l in options.get('to_list') or []:
|
ml = get_object(MailingList, force_str(name, locale_encoding))
|
||||||
l = get_object(MailingList, force_str(l, locale_encoding))
|
to_lists.append(ml)
|
||||||
to_lists.append(l)
|
|
||||||
except MailingList.DoesNotExist:
|
|
||||||
raise CommandError('list %r does not exist' % l)
|
|
||||||
to_users = []
|
to_users = []
|
||||||
try:
|
for username in options.get('to_user') or []:
|
||||||
for l in options.get('to_user') or []:
|
user = get_object(User, force_str(username, locale_encoding), 'username')
|
||||||
l = get_object(User, force_str(l, locale_encoding), 'username')
|
to_users.append(user)
|
||||||
to_users.append(l)
|
|
||||||
except User.DoesNotExist:
|
|
||||||
raise CommandError('user %r does not exist' % l)
|
|
||||||
if 'filetype' not in options:
|
if 'filetype' not in options:
|
||||||
raise CommandError('missing --filetype parameter')
|
raise CommandError('missing --filetype parameter')
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -8,6 +8,7 @@ import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
import watson.search as watson
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import Group, User
|
from django.contrib.auth.models import Group, User
|
||||||
from django.db.models import (
|
from django.db.models import (
|
||||||
|
@ -327,7 +328,7 @@ class Document(Model):
|
||||||
It can differ from ``to()`` if the members of a recipient
|
It can differ from ``to()`` if the members of a recipient
|
||||||
mailing-list changed.
|
mailing-list changed.
|
||||||
"""
|
"""
|
||||||
return [m.owner for m in self.mailboxes.all() if m.outbox == False]
|
return [m.owner for m in self.mailboxes.all() if m.outbox is False]
|
||||||
|
|
||||||
def timestamp(self, to=None):
|
def timestamp(self, to=None):
|
||||||
if not self._timestamp:
|
if not self._timestamp:
|
||||||
|
@ -488,15 +489,15 @@ class DocumentForwarded(Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def list_to_csv(l, mapping_func=None):
|
def list_to_csv(_list, mapping_func=None):
|
||||||
"""Convert a list to a comma separated string of its unicode values.
|
"""Convert a list to a comma separated string of its unicode values.
|
||||||
|
|
||||||
A mapping_func function can be passed to transform the list prior to the
|
A mapping_func function can be passed to transform the list prior to the
|
||||||
formatting.
|
formatting.
|
||||||
"""
|
"""
|
||||||
if mapping_func:
|
if mapping_func:
|
||||||
l = map(mapping_func, l)
|
_list = map(mapping_func, _list)
|
||||||
return ', '.join(map(force_str, l))
|
return ', '.join(map(force_str, _list))
|
||||||
|
|
||||||
|
|
||||||
class AutomaticForwarding(Model):
|
class AutomaticForwarding(Model):
|
||||||
|
@ -602,7 +603,7 @@ class AttachedFile(Model):
|
||||||
prefix, true_filename = filename.split('_', 1)
|
prefix, true_filename = filename.split('_', 1)
|
||||||
if prefix.isdigit():
|
if prefix.isdigit():
|
||||||
return true_filename
|
return true_filename
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
@ -659,7 +660,7 @@ class Delegation(Model):
|
||||||
def guest_delegate(self):
|
def guest_delegate(self):
|
||||||
try:
|
try:
|
||||||
return self.to.docbowprofile.is_guest
|
return self.to.docbowprofile.is_guest
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -904,9 +905,6 @@ def non_guest_users():
|
||||||
return User.objects.exclude(docbowprofile__is_guest=True).filter(is_active=True)
|
return User.objects.exclude(docbowprofile__is_guest=True).filter(is_active=True)
|
||||||
|
|
||||||
|
|
||||||
import watson.search as watson
|
|
||||||
|
|
||||||
|
|
||||||
class DocumentAdapter(watson.SearchAdapter):
|
class DocumentAdapter(watson.SearchAdapter):
|
||||||
def gather_strings(self, obj):
|
def gather_strings(self, obj):
|
||||||
yield obj.comment
|
yield obj.comment
|
||||||
|
|
|
@ -109,7 +109,7 @@ class WorkSheet:
|
||||||
|
|
||||||
class WorkCell:
|
class WorkCell:
|
||||||
def __init__(self, worksheet, value, hint=None):
|
def __init__(self, worksheet, value, hint=None):
|
||||||
if type(value) is not str:
|
if not isinstance(value, str):
|
||||||
value = force_str(value, 'utf-8')
|
value = force_str(value, 'utf-8')
|
||||||
self.value = value
|
self.value = value
|
||||||
self.worksheet = worksheet
|
self.worksheet = worksheet
|
||||||
|
|
|
@ -7,8 +7,10 @@ import zipfile
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
import django.contrib.auth as auth
|
import django.contrib.auth as auth
|
||||||
|
from django import http
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.contrib.auth import BACKEND_SESSION_KEY, SESSION_KEY
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.files.base import File
|
from django.core.files.base import File
|
||||||
|
@ -61,7 +63,9 @@ from docbow_project.docbow.models import (
|
||||||
)
|
)
|
||||||
from docbow_project.docbow.utils import date_to_aware_datetime
|
from docbow_project.docbow.utils import date_to_aware_datetime
|
||||||
|
|
||||||
gettext_noop = lambda x: x
|
|
||||||
|
def gettext_noop(x):
|
||||||
|
return x
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -560,10 +564,6 @@ def restore(request, doc_id, outbox=False):
|
||||||
return redirect(return_view)
|
return redirect(return_view)
|
||||||
|
|
||||||
|
|
||||||
from django import http
|
|
||||||
from django.contrib.auth import BACKEND_SESSION_KEY, SESSION_KEY
|
|
||||||
|
|
||||||
|
|
||||||
def su(request, username, redirect_url='/'):
|
def su(request, username, redirect_url='/'):
|
||||||
"""Allows changing user for super-users. Super-user status is kept using a
|
"""Allows changing user for super-users. Super-user status is kept using a
|
||||||
flag on the session.
|
flag on the session.
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
import django.apps
|
|
||||||
|
|
||||||
|
|
||||||
class AppConfig(django.apps.AppConfig):
|
|
||||||
name = 'docbow_project.pfwb'
|
|
||||||
|
|
||||||
def ready(self):
|
|
||||||
pass
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class AppSettings:
|
class AppSettings:
|
||||||
'''Thanks django-allauth'''
|
'''Thanks django-allauth'''
|
||||||
|
|
||||||
|
@ -43,6 +46,5 @@ class AppSettings:
|
||||||
app_settings = AppSettings('DOCBOW_')
|
app_settings = AppSettings('DOCBOW_')
|
||||||
app_settings.__name__ = __name__
|
app_settings.__name__ = __name__
|
||||||
app_settings.__file__ = __file__
|
app_settings.__file__ = __file__
|
||||||
import sys
|
|
||||||
|
|
||||||
sys.modules[__name__] = app_settings
|
sys.modules[__name__] = app_settings
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import django.apps
|
||||||
|
|
||||||
|
|
||||||
|
class AppConfig(django.apps.AppConfig):
|
||||||
|
name = 'docbow_project.pfwb'
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
from . import signals # noqa: F401
|
|
@ -71,7 +71,7 @@ In case of failure the following return value is returned:
|
||||||
try:
|
try:
|
||||||
mbox = mailbox.mbox(settings.SENDMAIL_DEBUG_MBOX)
|
mbox = mailbox.mbox(settings.SENDMAIL_DEBUG_MBOX)
|
||||||
mbox.add(mail)
|
mbox.add(mail)
|
||||||
except:
|
except Exception:
|
||||||
logger.exception('mbox exception')
|
logger.exception('mbox exception')
|
||||||
try:
|
try:
|
||||||
self.handle_mail(mail, (options['recipient'],), **options)
|
self.handle_mail(mail, (options['recipient'],), **options)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from docbow_project.settings import *
|
from docbow_project.settings import * # noqa: F403
|
||||||
|
|
||||||
DOCBOW_EDIT_EMAIL = True
|
DOCBOW_EDIT_EMAIL = True
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
import django.apps
|
|
||||||
|
|
||||||
|
|
||||||
class AppConfig(django.apps.AppConfig):
|
|
||||||
name = 'docbow_project.pw'
|
|
|
@ -73,7 +73,7 @@ In case of failure the following return value is returned:
|
||||||
try:
|
try:
|
||||||
mbox = mailbox.mbox(settings.SENDMAIL_DEBUG_MBOX)
|
mbox = mailbox.mbox(settings.SENDMAIL_DEBUG_MBOX)
|
||||||
mbox.add(mail)
|
mbox.add(mail)
|
||||||
except:
|
except Exception:
|
||||||
logger.exception('mbox exception')
|
logger.exception('mbox exception')
|
||||||
try:
|
try:
|
||||||
self.handle_mail(mail, (options['recipient'],), **options)
|
self.handle_mail(mail, (options['recipient'],), **options)
|
||||||
|
|
|
@ -7,7 +7,7 @@ try:
|
||||||
from authentic2.custom_user.models import User as A2User
|
from authentic2.custom_user.models import User as A2User
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
except:
|
else:
|
||||||
# when user is created or deleted on Docbow, create or delete on authentic
|
# when user is created or deleted on Docbow, create or delete on authentic
|
||||||
# when first_name, last_name, email or password change on docbow, write it on authentic
|
# when first_name, last_name, email or password change on docbow, write it on authentic
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ except:
|
||||||
try:
|
try:
|
||||||
user = A2User.objects.using('authentic').get(username=username)
|
user = A2User.objects.using('authentic').get(username=username)
|
||||||
except A2User.DoesNotExist:
|
except A2User.DoesNotExist:
|
||||||
update_password = True
|
|
||||||
user = A2User()
|
user = A2User()
|
||||||
user.username = instance.username
|
user.username = instance.username
|
||||||
user.first_name = instance.first_name
|
user.first_name = instance.first_name
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from docbow_project.settings import *
|
from docbow_project.settings import * # noqa: F403
|
||||||
|
|
||||||
DEFAULT_FROM_EMAIL = 'gestionnaire@courrier.parlement-wallon.be'
|
DEFAULT_FROM_EMAIL = 'gestionnaire@courrier.parlement-wallon.be'
|
||||||
CONTACT_SUBJECT_PREFIX = 'Contact depuis courrier.parlement-wallon.be: '
|
CONTACT_SUBJECT_PREFIX = 'Contact depuis courrier.parlement-wallon.be: '
|
||||||
|
@ -14,7 +14,7 @@ DOCBOW_DELEGATE_TO_EXISTING_USER = False
|
||||||
DOCBOW_DEFAULT_ACCEPT_NOTIFICATIONS_FOR_GUEST = False
|
DOCBOW_DEFAULT_ACCEPT_NOTIFICATIONS_FOR_GUEST = False
|
||||||
|
|
||||||
if 'USE_SAML' in os.environ:
|
if 'USE_SAML' in os.environ:
|
||||||
INSTALLED_APPS += ('mellon',)
|
INSTALLED_APPS += ('mellon',) # noqa: F405
|
||||||
LOGIN_URL = 'mellon_login'
|
LOGIN_URL = 'mellon_login'
|
||||||
LOGOUT_URL = 'mellon_logout'
|
LOGOUT_URL = 'mellon_logout'
|
||||||
AUTHENTICATION_BACKENDS = ('mellon.backends.SAMLBackend',)
|
AUTHENTICATION_BACKENDS = ('mellon.backends.SAMLBackend',)
|
||||||
|
@ -33,19 +33,19 @@ if 'USE_SAML' in os.environ:
|
||||||
MELLON_USERNAME_TEMPLATE = '{attributes[name_id_content]}'
|
MELLON_USERNAME_TEMPLATE = '{attributes[name_id_content]}'
|
||||||
|
|
||||||
if 'AUTHENTIC_DATABASE_ENGINE' in os.environ:
|
if 'AUTHENTIC_DATABASE_ENGINE' in os.environ:
|
||||||
DATABASES['authentic'] = {
|
DATABASES['authentic'] = { # noqa: F405
|
||||||
'ENGINE': os.environ.get('AUTHENTIC_DATABASE_ENGINE'),
|
'ENGINE': os.environ.get('AUTHENTIC_DATABASE_ENGINE'),
|
||||||
'NAME': os.environ.get('AUTHENTIC_DATABASE_NAME'),
|
'NAME': os.environ.get('AUTHENTIC_DATABASE_NAME'),
|
||||||
'USER': os.environ.get('AUTHENTIC_DATABASE_USER'),
|
'USER': os.environ.get('AUTHENTIC_DATABASE_USER'),
|
||||||
}
|
}
|
||||||
|
|
||||||
JOURNAL_DB_FOR_ERROR_ALIAS = 'journal'
|
JOURNAL_DB_FOR_ERROR_ALIAS = 'journal'
|
||||||
DATABASES['journal'] = DATABASES['default'].copy()
|
DATABASES['journal'] = DATABASES['default'].copy() # noqa: F405
|
||||||
DATABASES['journal']['TEST_MIRROR'] = 'default'
|
DATABASES['journal']['TEST_MIRROR'] = 'default' # noqa: F405
|
||||||
BASE_URL = 'https://courrier.parlement-wallon.be'
|
BASE_URL = 'https://courrier.parlement-wallon.be'
|
||||||
EMAIL_SUBJECT_PREFIX = ''
|
EMAIL_SUBJECT_PREFIX = ''
|
||||||
|
|
||||||
if PLATFORM == 'test':
|
if PLATFORM == 'test': # noqa: F405
|
||||||
BASE_URL = 'https://pes-pw.dev.entrouvert.org'
|
BASE_URL = 'https://pes-pw.dev.entrouvert.org'
|
||||||
DEFAULT_FROM_EMAIL = 'gestionnaire@pes-pw.dev.entrouvert.org'
|
DEFAULT_FROM_EMAIL = 'gestionnaire@pes-pw.dev.entrouvert.org'
|
||||||
CONTACT_SUBJECT_PREFIX = 'Contact depuis pes-pw.dev.entrouvert.org: '
|
CONTACT_SUBJECT_PREFIX = 'Contact depuis pes-pw.dev.entrouvert.org: '
|
||||||
|
@ -53,6 +53,6 @@ if PLATFORM == 'test':
|
||||||
HELP_DIR = '/usr/share/doc/docbow/build-pw'
|
HELP_DIR = '/usr/share/doc/docbow/build-pw'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from local_settings import *
|
from local_settings import * # noqa: F403
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import os
|
import os
|
||||||
|
|
||||||
gettext_noop = lambda s: s
|
|
||||||
|
def gettext_noop(s):
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(__file__)
|
BASE_DIR = os.path.dirname(__file__)
|
||||||
PROJECT_NAME = 'docbow'
|
PROJECT_NAME = 'docbow'
|
||||||
|
|
|
@ -8,7 +8,7 @@ import docbow_project.docbow.views
|
||||||
|
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
from .docbow.admin import site as docbow_admin_site
|
from .docbow.admin import site as docbow_admin_site # noqa: E402
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', include('docbow_project.docbow.urls')),
|
path('', include('docbow_project.docbow.urls')),
|
||||||
|
|
|
@ -13,10 +13,6 @@ middleware here, or combine a Django application with an application of another
|
||||||
framework.
|
framework.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import os
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'docbow_project.settings')
|
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# AUTHENTIC URL and credentials are used
|
# AUTHENTIC URL and credentials are used
|
||||||
# to manage guest users.
|
# to manage guest users.
|
||||||
|
|
||||||
INSTALLED_APPS += ('mellon',)
|
INSTALLED_APPS += ('mellon',) # noqa: F821
|
||||||
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
'docbow_project.docbow.auth_backend.DocbowMellonAuthBackend' 'django.contrib.auth.backends.ModelBackend'
|
'docbow_project.docbow.auth_backend.DocbowMellonAuthBackend' 'django.contrib.auth.backends.ModelBackend'
|
||||||
|
|
|
@ -12,7 +12,15 @@ from functools import wraps
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.core import management
|
||||||
|
from django.test import TestCase
|
||||||
|
from django.test.utils import override_settings
|
||||||
from django.utils.encoding import force_bytes, force_str
|
from django.utils.encoding import force_bytes, force_str
|
||||||
|
from django_journal.models import Journal
|
||||||
|
|
||||||
|
from docbow_project.docbow.models import AttachedFile, Document, FileType, MailingList
|
||||||
|
from docbow_project.pfwb.models import PloneFileType, TabellioDocType
|
||||||
|
|
||||||
MEDIA_ROOT = tempfile.mkdtemp()
|
MEDIA_ROOT = tempfile.mkdtemp()
|
||||||
|
|
||||||
|
@ -58,15 +66,6 @@ class stdout_output:
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.core import management
|
|
||||||
from django.test import TestCase
|
|
||||||
from django.test.utils import override_settings
|
|
||||||
from django_journal.models import Journal
|
|
||||||
|
|
||||||
from docbow_project.docbow.models import AttachedFile, Document, FileType, MailingList
|
|
||||||
from docbow_project.pfwb.models import PloneFileType, TabellioDocType
|
|
||||||
|
|
||||||
EXPEDITION_EMAIL = 'expedition@example.com'
|
EXPEDITION_EMAIL = 'expedition@example.com'
|
||||||
RECIPIENT_EMAIL = 'recipient@example.com'
|
RECIPIENT_EMAIL = 'recipient@example.com'
|
||||||
RECIPIENT_LIST_EMAIL = 'liste-ma-liste@example.com'
|
RECIPIENT_LIST_EMAIL = 'liste-ma-liste@example.com'
|
||||||
|
@ -403,10 +402,10 @@ class ArchiveTestCase(TestCase):
|
||||||
|
|
||||||
with captured_output() as (out, err):
|
with captured_output() as (out, err):
|
||||||
management.call_command('archive2', self.archive_dir, 0)
|
management.call_command('archive2', self.archive_dir, 0)
|
||||||
l = glob.glob(os.path.join(self.archive_dir, '*'))
|
file_list = glob.glob(os.path.join(self.archive_dir, '*'))
|
||||||
assert len(l) == 1
|
assert len(file_list) == 1
|
||||||
self.assertTrue(l[0].split('T')[0], datetime.datetime.today().isoformat())
|
self.assertTrue(file_list[0].split('T')[0], datetime.datetime.today().isoformat())
|
||||||
archive_dir = os.path.join(self.archive_dir, l[0])
|
archive_dir = os.path.join(self.archive_dir, file_list[0])
|
||||||
self.assertTrue(os.path.exists(os.path.join(archive_dir, 'doc')))
|
self.assertTrue(os.path.exists(os.path.join(archive_dir, 'doc')))
|
||||||
self.assertTrue(os.path.exists(os.path.join(archive_dir, 'doc', str(self.document.id))))
|
self.assertTrue(os.path.exists(os.path.join(archive_dir, 'doc', str(self.document.id))))
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
|
@ -428,9 +427,9 @@ def test_send_mail_truncate_filename(db, settings):
|
||||||
settings.MEDIA_ROOT = MEDIA_ROOT
|
settings.MEDIA_ROOT = MEDIA_ROOT
|
||||||
|
|
||||||
pjd_filetype = FileType.objects.create(name='PJD', id=2)
|
pjd_filetype = FileType.objects.create(name='PJD', id=2)
|
||||||
tabellio_doc_type = TabellioDocType.objects.create(filetype=pjd_filetype, tabellio_doc_type='PJD')
|
TabellioDocType.objects.create(filetype=pjd_filetype, tabellio_doc_type='PJD')
|
||||||
expedition_user = User.objects.create(username='expedition', id=1)
|
User.objects.create(username='expedition', id=1)
|
||||||
to_user = User.objects.create(username='recipient', email=RECIPIENT_EMAIL, id=2)
|
User.objects.create(username='recipient', email=RECIPIENT_EMAIL, id=2)
|
||||||
|
|
||||||
subject = 'foo: ' + 'aaaa M.' + 'b' * 300
|
subject = 'foo: ' + 'aaaa M.' + 'b' * 300
|
||||||
content = '''\
|
content = '''\
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
|
|
||||||
SECRET_KEY = 'coin'
|
SECRET_KEY = 'coin'
|
||||||
|
|
||||||
INSTALLED_APPS += ('mellon', 'docbow_project.pfwb')
|
INSTALLED_APPS += ('mellon', 'docbow_project.pfwb') # noqa: F821
|
||||||
|
|
||||||
MELLON_ADAPTER = ('docbow_project.pfwb.mellon_adapter.PFWBMellonAdapter',)
|
MELLON_ADAPTER = ('docbow_project.pfwb.mellon_adapter.PFWBMellonAdapter',)
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,14 @@ from contextlib import contextmanager
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.core import management
|
||||||
|
from django.test import TestCase
|
||||||
|
from django.test.utils import override_settings
|
||||||
from django.utils.encoding import force_bytes, force_str
|
from django.utils.encoding import force_bytes, force_str
|
||||||
|
|
||||||
|
from docbow_project.docbow.models import Document, FileType, MailingList
|
||||||
|
|
||||||
MEDIA_ROOT = tempfile.mkdtemp()
|
MEDIA_ROOT = tempfile.mkdtemp()
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,13 +63,6 @@ class stdout_output:
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.core import management
|
|
||||||
from django.test import TestCase
|
|
||||||
from django.test.utils import override_settings
|
|
||||||
|
|
||||||
from docbow_project.docbow.models import Document, FileType, MailingList
|
|
||||||
|
|
||||||
EXPEDITION_EMAIL = 'expedition@example.com'
|
EXPEDITION_EMAIL = 'expedition@example.com'
|
||||||
RECIPIENT_EMAIL = 'recipient@example.com'
|
RECIPIENT_EMAIL = 'recipient@example.com'
|
||||||
PRIVATE_RECIPIENT_EMAIL = 'recipient-private@example.com'
|
PRIVATE_RECIPIENT_EMAIL = 'recipient-private@example.com'
|
||||||
|
|
|
@ -16,7 +16,7 @@ DATABASES = {
|
||||||
PARLEMENT = os.environ['PARLEMENT']
|
PARLEMENT = os.environ['PARLEMENT']
|
||||||
|
|
||||||
if PARLEMENT == 'pfwb':
|
if PARLEMENT == 'pfwb':
|
||||||
INSTALLED_APPS += ('docbow_project.pfwb',)
|
INSTALLED_APPS += ('docbow_project.pfwb',) # noqa: F821
|
||||||
DOCBOW_EDIT_EMAIL = True
|
DOCBOW_EDIT_EMAIL = True
|
||||||
TABELLIO_DBNAME = 'tabellio-test-%s' % os.environ.get('BRANCH_NAME', '').replace('/', '-')[:63]
|
TABELLIO_DBNAME = 'tabellio-test-%s' % os.environ.get('BRANCH_NAME', '').replace('/', '-')[:63]
|
||||||
TABELLIO_DBHOST = ''
|
TABELLIO_DBHOST = ''
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
|
|
||||||
SECRET_KEY = 'coin'
|
SECRET_KEY = 'coin'
|
||||||
|
|
||||||
INSTALLED_APPS += ('mellon',)
|
INSTALLED_APPS += ('mellon',) # noqa: F821
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
|
|
|
@ -118,7 +118,7 @@ def test_delete_delegate_sso(a2settings, client, monkeypatch, user):
|
||||||
|
|
||||||
mock_resp = MockResp(json={})
|
mock_resp = MockResp(json={})
|
||||||
mock_delete = mock.Mock(return_value=mock_resp)
|
mock_delete = mock.Mock(return_value=mock_resp)
|
||||||
monkeypatch.setattr(docbow_project.docbow.profile_views.requests, 'delete', mock_delete)
|
monkeypatch.setattr(docbow_project.docbow.utils.requests, 'delete', mock_delete)
|
||||||
|
|
||||||
delegate = User.objects.create(
|
delegate = User.objects.create(
|
||||||
first_name='john', last_name='doe', username='john.doe-1', email='john@localhost'
|
first_name='john', last_name='doe', username='john.doe-1', email='john@localhost'
|
||||||
|
|
Loading…
Reference in New Issue