Added a setting where the exported excel files should be stored.

Added a option to send the exported excel as mail attachment.
This commit is contained in:
2017-12-07 09:40:35 +01:00
parent bb5081a78b
commit c5781246fe
9 changed files with 48 additions and 54 deletions

63
TODO
View File

@@ -8,15 +8,15 @@ src/utils/html_cleaner.py
| | The code does not comply to PEP8. | | 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
| |++++| /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 | 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. | 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. | 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. | | 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. | | 11|+MAX_COMMENT_ITEMS = 40 # Maximum count of comments in the comments RSS feed.
| 12| 12| | 12| 12|
| 13| 13| | 13| 13|
| 14| 14| # Start ignoring PyLintBear (R0201) | 14| 14| # Start ignoring PyLintBear (R0201)
| | [NORMAL] PEP8Bear: | | [NORMAL] PEP8Bear:
| | The code does not comply to PEP8. | | The code does not comply to PEP8.
@@ -25,7 +25,7 @@ src/utils/html_cleaner.py
| 122| 122| def save(self, commit=True): | 122| 122| def save(self, commit=True):
| 123| 123| """ Create the new User, set him/her inactive, create an acitivation | 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. | 124| 124| request for the user and send him/her an activation email.
| 125| |- | 125| |-
| | 125|+ | | 125|+
| 126| 126| :param commit: commit the SQL and send the email if True | 126| 126| :param commit: commit the SQL and send the email if True
| 127| 127| :return: the created User Object | 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 | |++++| /srv/home/xeniac/Workspace/kasu/src/mahjong_ranking/managers.py
| 7| 7| class HanchanManager(models.Manager): | 7| 7| class HanchanManager(models.Manager):
| 8| 8| """ | 8| 8| """
| 9| 9| The ObjectManager for models.Hanchan QuerySets. | 9| 9| The ObjectManager for models.Hanchan QuerySets.
| 10| |- | 10| |-
| | 10|+ | | 10|+
| 11| 11| It adds many specific filters that makes many queries much easier. | 11| 11| It adds many specific filters that makes many queries much easier.
| 12| 12| """ | 12| 12| """
@@ -167,12 +167,12 @@ src/utils/middleware.py
| | The code does not comply to PEP8. | | 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
| |++++| /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): | 15| 15| def confirmed_hanchans(self, user=None, **filter_args):
| 16| 16| """ Return all valid and confirmed Hanchans. | 16| 16| """ Return all valid and confirmed Hanchans.
| 17| |- | 17| |-
| | 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. | 19| 19| :param filter_args: To add specific arguments to the Django filter.
| 20| 20| :return: QuerySet Object | 20| 20| :return: QuerySet Object
| | [NORMAL] PEP8Bear: | | [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 ]
| | 42|+ [hanchan.get_playerdata(user) for hanchan in queryset] | | 42|+ [hanchan.get_playerdata(user) for hanchan in queryset]
| 43| 43| return queryset | 43| 43| return queryset
| 44| 44| | 44| 44|
| 45| 45| def kyu_hanchans(self, user, **filter_args): | 45| 45| def kyu_hanchans(self, user, **filter_args):
| | [NORMAL] PEP8Bear: | | [NORMAL] PEP8Bear:
| | The code does not comply to PEP8. | | 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 ]
| | 60|+ [hanchan.get_playerdata(user) for hanchan in queryset] | | 60|+ [hanchan.get_playerdata(user) for hanchan in queryset]
| 61| 61| return queryset | 61| 61| return queryset
| 62| 62| | 62| 62|
| 63| 63| def season_hanchans(self, user=None, season=None): | 63| 63| def season_hanchans(self, user=None, season=None):
| | [NORMAL] PEP8Bear: | | [NORMAL] PEP8Bear:
| | The code does not comply to PEP8. | | 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 ]
| | 90|+ [hanchan.get_playerdata(user) for hanchan in queryset] | | 90|+ [hanchan.get_playerdata(user) for hanchan in queryset]
| 91| 91| return queryset | 91| 91| return queryset
| 92| 92| | 92| 92|
| 93| 93| def unconfirmed_hanchans(self, user=None, **filter_args): | 93| 93| def unconfirmed_hanchans(self, user=None, **filter_args):
src/mahjong_ranking/managers.py src/mahjong_ranking/managers.py
@@ -417,7 +417,7 @@ src/content/models.py
| | 60|+ user.registration_date.isoformat() | | 60|+ user.registration_date.isoformat()
| 61| 61| activation_key = hashlib.sha1(salt.encode()).hexdigest() | 61| 61| activation_key = hashlib.sha1(salt.encode()).hexdigest()
| 62| 62| return self.create(user=user, activation_key=activation_key) | 62| 62| return self.create(user=user, activation_key=activation_key)
| 63| 63| | 63| 63|
src/membership/models.py src/membership/models.py
| 229| ········:param·args:·passed·through·the·save()·method·from·django·· | 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 | |++++| /srv/home/xeniac/Workspace/kasu/src/kasu/wsgi.py
| 14| 14| if SOURCE_PATH not in sys.path: | 14| 14| if SOURCE_PATH not in sys.path:
| 15| 15| sys.path.append(SOURCE_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| |-from django.core.wsgi import get_wsgi_application # Ignore PyLintBear (C0413) # Ignore PyLintBear (C0413)
| | 17|+# Ignore PyLintBear (C0413) # Ignore PyLintBear (C0413) | | 17|+# Ignore PyLintBear (C0413) # Ignore PyLintBear (C0413)
| | 18|+from django.core.wsgi import get_wsgi_application | | 18|+from django.core.wsgi import get_wsgi_application
| 18| 19| | 18| 19|
| 19| 20| os.environ['DJANGO_SETTINGS_MODULE'] = 'kasu.settings' | 19| 20| os.environ['DJANGO_SETTINGS_MODULE'] = 'kasu.settings'
| 20| 21| | 20| 21|
| | [NORMAL] PEP8Bear: | | [NORMAL] PEP8Bear:
| | The code does not comply to PEP8. | | 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
| |++++| /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' | 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| |-application = get_wsgi_application() # Ignore PyLintBear (C0103) # Ignore PyLintBear (C0103)
| | 21|+# Ignore PyLintBear (C0103) # Ignore PyLintBear (C0103) | | 21|+# Ignore PyLintBear (C0103) # Ignore PyLintBear (C0103)
| | 22|+application = get_wsgi_application() | | 22|+application = get_wsgi_application()
@@ -570,24 +570,24 @@ src/kasu/wsgi.py
| | The code does not comply to PEP8. | | 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
| |++++| /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): | 198| 198| def get_object(self, queryset=None):
| 199| 199| """ Get the path from the URL and fetch the corresponding page. | 199| 199| """ Get the path from the URL and fetch the corresponding page.
| 200| |- | 200| |-
| | 200|+ | | 200|+
| 201| 201| First get the path wihout fileextentsion leading or trailing slashes, | 201| 201| First get the path wihout fileextentsion leading or trailing slashes,
| 202| 202| then search in the database if such a page exists. | 202| 202| then search in the database if such a page exists.
| 203| 203| | 203| 203|
| | [NORMAL] PEP8Bear: | | [NORMAL] PEP8Bear:
| | The code does not comply to PEP8. | | 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
| |++++| /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): | 289| 289| def get_context_data(self):
| 290| 290| """ Adds recent ariticles and recent comments to the context. | 290| 290| """ Adds recent ariticles and recent comments to the context.
| 291| |- | 291| |-
| | 291|+ | | 291|+
| 292| 292| :return: array() with the context data | 292| 292| :return: array() with the context data
| 293| 293| """ | 293| 293| """
| 294| 294| page = models.Page.objects.get(slug='index') | 294| 294| page = models.Page.objects.get(slug='index')
@@ -766,11 +766,6 @@ src/mahjong_ranking/models.py
| | [NORMAL] PyLintBear (W0201): | | [NORMAL] PyLintBear (W0201):
| | W0201 - Attribute 'kyu_points' defined outside __init__ | | 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 src/mahjong_ranking/models.py
| 330| class·KyuDanRanking(models.Model): | 330| class·KyuDanRanking(models.Model):
| | [INFO] PyLintBear (R0902): | | [INFO] PyLintBear (R0902):
@@ -865,7 +860,7 @@ src/maistar_ranking/models.py
| 47| |- ) | 47| |- )
| | 47|+ ) | | 47|+ )
| 48| 48| ) | 48| 48| )
| 49| 49| | 49| 49|
| 50| 50| def test_html_cleaner(self): | 50| 50| def test_html_cleaner(self):
src/maistar_ranking/managers.py src/maistar_ranking/managers.py
@@ -951,10 +946,10 @@ src/events/views.py
| | The code does not comply to PEP8. | | 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
| |++++| /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): | 69| 69| def set_header(self, name, value):
| 70| 70| """Add or modify an E-Mail Header to the Messages | 70| 70| """Add or modify an E-Mail Header to the Messages
| 71| |- | 71| |-
| | 71|+ | | 71|+
| 72| 72| :param name: The Header Name that should be added | 72| 72| :param name: The Header Name that should be added
| 73| 73| :param value: THe Header Value that shoud be added or set | 73| 73| :param value: THe Header Value that shoud be added or set

View File

@@ -3,7 +3,7 @@ from ckeditor_uploader.fields import RichTextUploadingField
from django.conf import settings from django.conf import settings
from django.core.cache import cache from django.core.cache import cache
from django.core.exceptions import ValidationError 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 import models
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify
from django.utils import timezone from django.utils import timezone
@@ -262,7 +262,7 @@ class Page(models.Model):
def content(self): def content(self):
"""Return the localized content, fallback to german if necessary.""" """Return the localized content, fallback to german if necessary."""
return mark_safe( return mark_safe(
getattr(self, "content_%s" % get_language(), self.content_de) getattr(self, "content_%s" % get_language()) or self.content_de
) )
@property @property
@@ -275,13 +275,12 @@ class Page(models.Model):
@property @property
def description(self): def description(self):
"""Return the localized description, fallback to german if necessary.""" """Return the localized description, fallback to german if necessary."""
return getattr(self, "description_%s" % get_language(), return getattr(self, "description_%s" % get_language()) or self.description_de
self.description_de)
@property @property
def menu_name(self): def menu_name(self):
"""Return the localized menu name, fallback to german if necessary.""" """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 @property
def pdf_file(self): def pdf_file(self):
@@ -291,7 +290,7 @@ class Page(models.Model):
@property @property
def title(self): def title(self):
"""Return the localized title, fallback to german if necessary.""" """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): def clean(self):
"""set the URL path, the right content type, and scrub the HTML code.""" """set the URL path, the right content type, and scrub the HTML code."""

View File

@@ -4,7 +4,7 @@ import os
from ckeditor.fields import RichTextField from ckeditor.fields import RichTextField
from django.conf import settings from django.conf import settings
from django.core.exceptions import ValidationError 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 import models
from django.db.models import Q from django.db.models import Q
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify

View File

@@ -3,7 +3,7 @@ from datetime import timedelta
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import PermissionRequiredMixin 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.db.models import Q
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from django.shortcuts import redirect from django.shortcuts import redirect

View File

@@ -7,7 +7,7 @@ from django.contrib import auth
from django.contrib.auth.mixins import LoginRequiredMixin, \ from django.contrib.auth.mixins import LoginRequiredMixin, \
PermissionRequiredMixin PermissionRequiredMixin
from django.contrib.messages.views import SuccessMessageMixin 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.utils.translation import ugettext as _
from django.views import generic from django.views import generic

View File

@@ -2,7 +2,7 @@
import logging import logging
from django.core.urlresolvers import reverse from django.urls import reverse
from django.db import models from django.db import models
from django.db.models.signals import post_delete, post_save from django.db.models.signals import post_delete, post_save
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _

View File

@@ -3,7 +3,7 @@
from datetime import date from datetime import date
from django.contrib import auth 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.shortcuts import get_object_or_404
from django.views import generic from django.views import generic

View File

@@ -7,7 +7,7 @@ from os import path
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import AbstractUser 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.db import models
from django.utils import timezone from django.utils import timezone
from django.utils.translation import ugettext as _ 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 """Save the Useraccount, and add him tho the "Paid Membership" group
if he activated the "membership" checkbox and has been validated. if he activated the "membership" checkbox and has been validated.
:param args: 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 :param kwargs: passed through the save() method from django
""" """
super(Membership, self).save(*args, **kwargs) super(Membership, self).save(*args, **kwargs)
if self.confirmed: if self.confirmed:

View File

@@ -7,7 +7,7 @@ from django import http
from django.conf import settings from django.conf import settings
from django.contrib import auth, messages from django.contrib import auth, messages
from django.contrib.auth.mixins import LoginRequiredMixin 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.http import Http404
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
@@ -114,7 +114,7 @@ class MembershipDetail(LoginRequiredMixin, generic.DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
""" Add the ladder ranking and the Kyu and Dan ranking the user profile. """ 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) context = generic.DetailView.get_context_data(self, **kwargs)
try: try:
@@ -139,11 +139,11 @@ class RegisterForm(generic.FormView):
@method_decorator(csp_update(**RECAPTCHA_CSP)) @method_decorator(csp_update(**RECAPTCHA_CSP))
def dispatch(self, request, *args, **kwargs): 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. Content-Security_Policity HTTP Headers.
:param request: :param request:
:param args: :param args:
:param kwargs: :param kwargs:
:return: """ :return: """
return super(RegisterForm, self).dispatch(request, *args, **kwargs) return super(RegisterForm, self).dispatch(request, *args, **kwargs)