From c7b714c41be0a809e974d1a3fd115b8e2c61da16 Mon Sep 17 00:00:00 2001 From: Xeniac Date: Thu, 7 Dec 2017 09:40:35 +0100 Subject: [PATCH] Added a setting where the exported excel files should be stored. Added a option to send the exported excel as mail attachment. --- TODO | 63 ++++++++++++++++------------------- src/content/models.py | 11 +++--- src/events/models.py | 2 +- src/events/views.py | 2 +- src/mahjong_ranking/views.py | 2 +- src/maistar_ranking/models.py | 2 +- src/maistar_ranking/views.py | 2 +- src/membership/models.py | 6 ++-- src/membership/views.py | 12 +++---- 9 files changed, 48 insertions(+), 54 deletions(-) diff --git a/TODO b/TODO index b1e4522..0607631 100644 --- a/TODO +++ b/TODO @@ -8,15 +8,15 @@ src/utils/html_cleaner.py | | The code does not comply to PEP8. |----| | /srv/home/xeniac/Workspace/kasu/src/content/feeds.py | |++++| /srv/home/xeniac/Workspace/kasu/src/content/feeds.py -| 7| 7| +| 7| 7| | 8| 8| from content.models import Article -| 9| 9| +| 9| 9| | 10| |-MAX_ARTICLE_ITEMS = 10 # Maximum count of articles in the news RSS feed. | 11| |-MAX_COMMENT_ITEMS = 40 # Maximum count of comments in the comments RSS feed. | | 10|+MAX_ARTICLE_ITEMS = 10 # Maximum count of articles in the news RSS feed. | | 11|+MAX_COMMENT_ITEMS = 40 # Maximum count of comments in the comments RSS feed. -| 12| 12| -| 13| 13| +| 12| 12| +| 13| 13| | 14| 14| # Start ignoring PyLintBear (R0201) | | [NORMAL] PEP8Bear: | | The code does not comply to PEP8. @@ -25,7 +25,7 @@ src/utils/html_cleaner.py | 122| 122| def save(self, commit=True): | 123| 123| """ Create the new User, set him/her inactive, create an acitivation | 124| 124| request for the user and send him/her an activation email. -| 125| |- +| 125| |- | | 125|+ | 126| 126| :param commit: commit the SQL and send the email if True | 127| 127| :return: the created User Object @@ -157,8 +157,8 @@ src/utils/middleware.py | |++++| /srv/home/xeniac/Workspace/kasu/src/mahjong_ranking/managers.py | 7| 7| class HanchanManager(models.Manager): | 8| 8| """ -| 9| 9| The ObjectManager for models.Hanchan QuerySets. -| 10| |- +| 9| 9| The ObjectManager for models.Hanchan QuerySets. +| 10| |- | | 10|+ | 11| 11| It adds many specific filters that makes many queries much easier. | 12| 12| """ @@ -167,12 +167,12 @@ src/utils/middleware.py | | The code does not comply to PEP8. |----| | /srv/home/xeniac/Workspace/kasu/src/mahjong_ranking/managers.py | |++++| /srv/home/xeniac/Workspace/kasu/src/mahjong_ranking/managers.py -| 14| 14| +| 14| 14| | 15| 15| def confirmed_hanchans(self, user=None, **filter_args): -| 16| 16| """ Return all valid and confirmed Hanchans. -| 17| |- +| 16| 16| """ Return all valid and confirmed Hanchans. +| 17| |- | | 17|+ -| 18| 18| :param user: Only return Hanchans where this user participated. +| 18| 18| :param user: Only return Hanchans where this user participated. | 19| 19| :param filter_args: To add specific arguments to the Django filter. | 20| 20| :return: QuerySet Object | | [NORMAL] PEP8Bear: @@ -185,7 +185,7 @@ src/utils/middleware.py | 42| |- [ hanchan.get_playerdata(user) for hanchan in queryset ] | | 42|+ [hanchan.get_playerdata(user) for hanchan in queryset] | 43| 43| return queryset -| 44| 44| +| 44| 44| | 45| 45| def kyu_hanchans(self, user, **filter_args): | | [NORMAL] PEP8Bear: | | The code does not comply to PEP8. @@ -197,7 +197,7 @@ src/utils/middleware.py | 60| |- [ hanchan.get_playerdata(user) for hanchan in queryset ] | | 60|+ [hanchan.get_playerdata(user) for hanchan in queryset] | 61| 61| return queryset -| 62| 62| +| 62| 62| | 63| 63| def season_hanchans(self, user=None, season=None): | | [NORMAL] PEP8Bear: | | The code does not comply to PEP8. @@ -209,7 +209,7 @@ src/utils/middleware.py | 90| |- [ hanchan.get_playerdata(user) for hanchan in queryset ] | | 90|+ [hanchan.get_playerdata(user) for hanchan in queryset] | 91| 91| return queryset -| 92| 92| +| 92| 92| | 93| 93| def unconfirmed_hanchans(self, user=None, **filter_args): src/mahjong_ranking/managers.py @@ -417,7 +417,7 @@ src/content/models.py | | 60|+ user.registration_date.isoformat() | 61| 61| activation_key = hashlib.sha1(salt.encode()).hexdigest() | 62| 62| return self.create(user=user, activation_key=activation_key) -| 63| 63| +| 63| 63| src/membership/models.py | 229| ········:param·args:·passed·through·the·save()·method·from·django·· @@ -534,20 +534,20 @@ src/events/models.py | |++++| /srv/home/xeniac/Workspace/kasu/src/kasu/wsgi.py | 14| 14| if SOURCE_PATH not in sys.path: | 15| 15| sys.path.append(SOURCE_PATH) -| 16| 16| +| 16| 16| | 17| |-from django.core.wsgi import get_wsgi_application # Ignore PyLintBear (C0413) # Ignore PyLintBear (C0413) | | 17|+# Ignore PyLintBear (C0413) # Ignore PyLintBear (C0413) | | 18|+from django.core.wsgi import get_wsgi_application -| 18| 19| +| 18| 19| | 19| 20| os.environ['DJANGO_SETTINGS_MODULE'] = 'kasu.settings' -| 20| 21| +| 20| 21| | | [NORMAL] PEP8Bear: | | The code does not comply to PEP8. |----| | /srv/home/xeniac/Workspace/kasu/src/kasu/wsgi.py | |++++| /srv/home/xeniac/Workspace/kasu/src/kasu/wsgi.py -| 18| 18| +| 18| 18| | 19| 19| os.environ['DJANGO_SETTINGS_MODULE'] = 'kasu.settings' -| 20| 20| +| 20| 20| | 21| |-application = get_wsgi_application() # Ignore PyLintBear (C0103) # Ignore PyLintBear (C0103) | | 21|+# Ignore PyLintBear (C0103) # Ignore PyLintBear (C0103) | | 22|+application = get_wsgi_application() @@ -570,24 +570,24 @@ src/kasu/wsgi.py | | The code does not comply to PEP8. |----| | /srv/home/xeniac/Workspace/kasu/src/content/views.py | |++++| /srv/home/xeniac/Workspace/kasu/src/content/views.py -| 197| 197| +| 197| 197| | 198| 198| def get_object(self, queryset=None): | 199| 199| """ Get the path from the URL and fetch the corresponding page. -| 200| |- +| 200| |- | | 200|+ | 201| 201| First get the path wihout fileextentsion leading or trailing slashes, | 202| 202| then search in the database if such a page exists. -| 203| 203| +| 203| 203| | | [NORMAL] PEP8Bear: | | The code does not comply to PEP8. |----| | /srv/home/xeniac/Workspace/kasu/src/content/views.py | |++++| /srv/home/xeniac/Workspace/kasu/src/content/views.py -| 288| 288| +| 288| 288| | 289| 289| def get_context_data(self): | 290| 290| """ Adds recent ariticles and recent comments to the context. -| 291| |- +| 291| |- | | 291|+ -| 292| 292| :return: array() with the context data +| 292| 292| :return: array() with the context data | 293| 293| """ | 294| 294| page = models.Page.objects.get(slug='index') @@ -766,11 +766,6 @@ src/mahjong_ranking/models.py | | [NORMAL] PyLintBear (W0201): | | W0201 - Attribute 'kyu_points' defined outside __init__ -src/mahjong_ranking/models.py -| 330| class·KyuDanRanking(models.Model): -| | [NORMAL] PyLintBear (W5102): -| | W5102 - Found __unicode__ method on model (KyuDanRanking). Python3 uses __str__. - src/mahjong_ranking/models.py | 330| class·KyuDanRanking(models.Model): | | [INFO] PyLintBear (R0902): @@ -865,7 +860,7 @@ src/maistar_ranking/models.py | 47| |- ) | | 47|+ ) | 48| 48| ) -| 49| 49| +| 49| 49| | 50| 50| def test_html_cleaner(self): src/maistar_ranking/managers.py @@ -951,10 +946,10 @@ src/events/views.py | | The code does not comply to PEP8. |----| | /srv/home/xeniac/Workspace/kasu/src/utils/massmailer.py | |++++| /srv/home/xeniac/Workspace/kasu/src/utils/massmailer.py -| 68| 68| +| 68| 68| | 69| 69| def set_header(self, name, value): | 70| 70| """Add or modify an E-Mail Header to the Messages -| 71| |- +| 71| |- | | 71|+ | 72| 72| :param name: The Header Name that should be added | 73| 73| :param value: THe Header Value that shoud be added or set diff --git a/src/content/models.py b/src/content/models.py index df51317..869bb37 100644 --- a/src/content/models.py +++ b/src/content/models.py @@ -3,7 +3,7 @@ from ckeditor_uploader.fields import RichTextUploadingField from django.conf import settings from django.core.cache import cache from django.core.exceptions import ValidationError -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db import models from django.template.defaultfilters import slugify from django.utils import timezone @@ -262,7 +262,7 @@ class Page(models.Model): def content(self): """Return the localized content, fallback to german if necessary.""" return mark_safe( - getattr(self, "content_%s" % get_language(), self.content_de) + getattr(self, "content_%s" % get_language()) or self.content_de ) @property @@ -275,13 +275,12 @@ class Page(models.Model): @property def description(self): """Return the localized description, fallback to german if necessary.""" - return getattr(self, "description_%s" % get_language(), - self.description_de) + return getattr(self, "description_%s" % get_language()) or self.description_de @property def menu_name(self): """Return the localized menu name, fallback to german if necessary.""" - return getattr(self, "menu_name_%s" % get_language(), self.menu_name_de) + return getattr(self, "menu_name_%s" % get_language()) or self.menu_name_de @property def pdf_file(self): @@ -291,7 +290,7 @@ class Page(models.Model): @property def title(self): """Return the localized title, fallback to german if necessary.""" - return getattr(self, "title_%s" % get_language(), self.title_de) + return getattr(self, "title_%s" % get_language()) or self.title_de def clean(self): """set the URL path, the right content type, and scrub the HTML code.""" diff --git a/src/events/models.py b/src/events/models.py index d805865..273c545 100644 --- a/src/events/models.py +++ b/src/events/models.py @@ -4,7 +4,7 @@ import os from ckeditor.fields import RichTextField from django.conf import settings from django.core.exceptions import ValidationError -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db import models from django.db.models import Q from django.template.defaultfilters import slugify diff --git a/src/events/views.py b/src/events/views.py index e92bd3a..8ee2a35 100644 --- a/src/events/views.py +++ b/src/events/views.py @@ -3,7 +3,7 @@ from datetime import timedelta from django.contrib.auth import get_user_model from django.contrib.auth.mixins import PermissionRequiredMixin -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db.models import Q from django.http import HttpResponse, Http404 from django.shortcuts import redirect diff --git a/src/mahjong_ranking/views.py b/src/mahjong_ranking/views.py index 5394070..9855843 100644 --- a/src/mahjong_ranking/views.py +++ b/src/mahjong_ranking/views.py @@ -7,7 +7,7 @@ from django.contrib import auth from django.contrib.auth.mixins import LoginRequiredMixin, \ PermissionRequiredMixin from django.contrib.messages.views import SuccessMessageMixin -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import ugettext as _ from django.views import generic diff --git a/src/maistar_ranking/models.py b/src/maistar_ranking/models.py index 3c9706b..3099b83 100644 --- a/src/maistar_ranking/models.py +++ b/src/maistar_ranking/models.py @@ -2,7 +2,7 @@ import logging -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db import models from django.db.models.signals import post_delete, post_save from django.utils.translation import ugettext as _ diff --git a/src/maistar_ranking/views.py b/src/maistar_ranking/views.py index 993aa75..115c1a9 100644 --- a/src/maistar_ranking/views.py +++ b/src/maistar_ranking/views.py @@ -3,7 +3,7 @@ from datetime import date from django.contrib import auth -from django.core.urlresolvers import reverse +from django.urls import reverse from django.shortcuts import get_object_or_404 from django.views import generic diff --git a/src/membership/models.py b/src/membership/models.py index 599b6b3..17e4312 100644 --- a/src/membership/models.py +++ b/src/membership/models.py @@ -7,7 +7,7 @@ from os import path from django.conf import settings from django.contrib.auth.models import AbstractUser -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db import models from django.utils import timezone from django.utils.translation import ugettext as _ @@ -226,8 +226,8 @@ class Membership(AbstractUser): """Save the Useraccount, and add him tho the "Paid Membership" group if he activated the "membership" checkbox and has been validated. - :param args: passed through the save() method from django - :param kwargs: passed through the save() method from django + :param args: passed through the save() method from django + :param kwargs: passed through the save() method from django """ super(Membership, self).save(*args, **kwargs) if self.confirmed: diff --git a/src/membership/views.py b/src/membership/views.py index fe9ed28..afdaad9 100644 --- a/src/membership/views.py +++ b/src/membership/views.py @@ -7,7 +7,7 @@ from django import http from django.conf import settings from django.contrib import auth, messages from django.contrib.auth.mixins import LoginRequiredMixin -from django.core.urlresolvers import reverse +from django.urls import reverse from django.http import Http404 from django.utils.decorators import method_decorator from django.utils.translation import ugettext as _ @@ -114,7 +114,7 @@ class MembershipDetail(LoginRequiredMixin, generic.DetailView): def get_context_data(self, **kwargs): """ Add the ladder ranking and the Kyu and Dan ranking the user profile. - :return: array with the context data + :return: array with the context data """ context = generic.DetailView.get_context_data(self, **kwargs) try: @@ -139,11 +139,11 @@ class RegisterForm(generic.FormView): @method_decorator(csp_update(**RECAPTCHA_CSP)) def dispatch(self, request, *args, **kwargs): - """Overwrite to add googles recaptcha ressoruces to the + """Overwrite to add googles recaptcha ressoruces to the Content-Security_Policity HTTP Headers. - :param request: - :param args: - :param kwargs: + :param request: + :param args: + :param kwargs: :return: """ return super(RegisterForm, self).dispatch(request, *args, **kwargs)