diff --git a/dav_auth/views.py b/dav_auth/views.py index bedb253..36d5a39 100644 --- a/dav_auth/views.py +++ b/dav_auth/views.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import logging +import secrets from django.apps import apps from django.core.exceptions import ValidationError from django.contrib import messages @@ -82,13 +83,15 @@ class CreateAndSendPasswordView(generic.FormView): form_class = forms.CreateAndSendPasswordForm template_name = 'dav_auth/forms/recreate_password.html' success_url = reverse_lazy('dav_auth:login') + password_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#$%&@^~.,:;/_-*+!?' + password_length = 32 def form_valid(self, form): username = form.cleaned_data.get('username') user_model = get_user_model() try: user = user_model.objects.get(username=username) - random_password = user_model.objects.make_random_password(length=32) + random_password = ''.join(secrets.choice(self.password_chars) for i in range(self.password_length)) user.set_password(random_password) user.save() email = emails.PasswordSetEmail(user, random_password) diff --git a/dav_base/config/modules.py b/dav_base/config/modules.py index ac0f7da..f0bfcd9 100644 --- a/dav_base/config/modules.py +++ b/dav_base/config/modules.py @@ -1,6 +1,6 @@ import json import os -import pkg_resources +from importlib.resources import files as resource_files from django.conf import settings from django.urls import re_path, include @@ -65,7 +65,7 @@ class ModuleMeta: def _load_from_package(self): package_name = self._package_name - json_text = pkg_resources.resource_string(package_name, self._json_file) + json_text = resource_files(package_name).joinpath(self._json_file).read_bytes() meta_dict = json.loads(json_text) meta_dict['package'] = package_name self.load_from_dict(meta_dict) diff --git a/dav_base/console_scripts/admin.py b/dav_base/console_scripts/admin.py index 70defda..291d9e8 100644 --- a/dav_base/console_scripts/admin.py +++ b/dav_base/console_scripts/admin.py @@ -2,7 +2,7 @@ import argparse import os import posix import sys -import pkg_resources +from importlib.resources import files as resource_files from django.core.management import execute_from_command_line from dav_base.config.modules import DJANGO_MAIN_MODULE, ModuleConfig @@ -94,20 +94,20 @@ class AdminCommand: # pylint: disable=too-few-public-methods config = ModuleConfig(django_base_dir=django_base_dir) config.save() - input_file = os.path.join('django_project_config', 'additional_settings.py') + input_file = resource_files(__package__).joinpath('django_project_config', 'additional_settings.py') output_file = os.path.join(django_base_dir, django_main_module, 'settings.py') with open(output_file, 'ab') as f: - f.write(pkg_resources.resource_string(__package__, input_file)) + f.write(input_file.read_bytes()) - input_file = os.path.join('django_project_config', 'urls.py') + input_file = resource_files(__package__).joinpath('django_project_config', 'urls.py') output_file = os.path.join(django_base_dir, django_main_module, 'urls.py') with open(output_file, 'wb') as f: - f.write(pkg_resources.resource_string(__package__, input_file)) + f.write(input_file.read_bytes()) - input_file = os.path.join('django_project_config', 'settings-dav_base.py') + input_file = resource_files(__package__).joinpath('django_project_config', 'settings-dav_base.py') output_file = os.path.join(django_base_dir, django_main_module, 'settings-dav_base.py') with open(output_file, 'wb') as f: - f.write(pkg_resources.resource_string(__package__, input_file)) + f.write(input_file.read_bytes()) return posix.EX_OK diff --git a/dav_base/management/commands/enable_module.py b/dav_base/management/commands/enable_module.py index 09494a1..3625fc3 100644 --- a/dav_base/management/commands/enable_module.py +++ b/dav_base/management/commands/enable_module.py @@ -1,5 +1,5 @@ import os -import pkg_resources +from importlib.resources import files as resource_files from django.conf import settings from django.core.management.base import BaseCommand, CommandError @@ -23,12 +23,12 @@ class Command(BaseCommand): raise CommandError('Module \'{}\' is already enabled'.format(module_name)) settings_file_name = 'settings-{}.py'.format(module_name) - input_file = os.path.join('django_project_config', settings_file_name) - if pkg_resources.resource_exists(module_name, input_file): + input_file = resource_files(module_name).joinpath('django_project_config', settings_file_name) + if input_file.is_file(): output_file = os.path.join(django_base_dir, django_main_module, settings_file_name) if not os.path.exists(output_file): with open(output_file, 'wb') as f: - f.write(pkg_resources.resource_string(module_name, input_file)) + f.write(input_file.read_bytes()) module_meta_obj = ModuleMeta(module_name) config.modules[module_name] = module_meta_obj diff --git a/dav_events/templates/dav_events/event/ka-alpin.txt b/dav_events/templates/dav_events/event/ka-alpin.txt index 8ad69f4..4191bdd 100644 --- a/dav_events/templates/dav_events/event/ka-alpin.txt +++ b/dav_events/templates/dav_events/event/ka-alpin.txt @@ -3,6 +3,8 @@ {{ normalized_short_date }} {% if alt_normalized_short_date %}({% trans 'Ersatztermin' %}: {{ alt_normalized_short_date }}) {% endif %} +{% if trainer_email or trainer_phone %}{% if trainer_email %}{{ trainer_email }}{% endif %}{% if trainer_email and trainer_phone %}, {% endif %}{% if trainer_phone %}{{ trainer_phone }}{% endif %} +{% endif %} {{ description }} {% if mode == 'training' %} {% trans 'Kursinhalte' %}: @@ -44,5 +46,5 @@ {% endif %}{% if charge > 0 or additional_costs %}{% trans 'Kosten' %}: {% if charge > 0 %}{{ charge|floatformat:'-2' }} € {% trans 'Teilnahmegebühr' %}{% endif %}{% if additional_costs %}{% if charge > 0 %} {% trans 'zzgl.' %} {% endif %}{{ additional_costs }}{% endif %} {% endif %}{% if registration_required and deadline %}{% trans 'Anmeldeschluss' %}: {{ deadline|date:'D, j. N Y' }} {% endif %}{% if trainer_2_fullname %}{% if mode == 'training' %}{% trans 'Ausbildungsteam' %}:{% else %}{% trans 'Team' %}:{% endif %} {{ trainer_firstname }} {{ trainer_familyname }}, {{ trainer_2_fullname }}{% if trainer_3_fullname %}, {{ trainer_3_fullname }}{% endif %} -{% endif %}{% if trainer_familyname %}{% trans 'Leitung' %}: {{ trainer_firstname }} {{ trainer_familyname }}{% if trainer_email or trainer_phone %} ({% if trainer_email %}{{ trainer_email }}{% endif %}{% if trainer_email and trainer_phone %}, {% endif %}{% if trainer_phone %}{{ trainer_phone }}{% endif %}){% endif %} +{% endif %}{% if trainer_familyname %}{% trans 'Leitung' %}: {{ trainer_firstname }} {{ trainer_familyname }} {% endif %} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index fc5bc0e..1ca3069 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ babel -django<5.1 +django<6 django-bootstrap3 django-countries django-datetime-widget2