Small fixes for Warnings found by PyCharm, mostly spellingerrors.

This commit is contained in:
2023-08-01 14:38:32 +02:00
parent ef00fc25f7
commit c62d2ee010
50 changed files with 294 additions and 385 deletions

View File

@@ -11,15 +11,15 @@ MAX_ARTICLE_ITEMS = 10 # Maximum count of articles in the news RSS feed.
MAX_COMMENT_ITEMS = 40 # Maximum count of comments in the comments RSS feed. MAX_COMMENT_ITEMS = 40 # Maximum count of comments in the comments RSS feed.
# Start ignoring PyLintBear (R0201) # noinspection PyMethodMayBeStatic
class LatestNews(Feed): class LatestNews(Feed):
""" An Feed with the latest news from this site """ """ An Feed with the latest news from this site """
link = "http://www.kasu.at/"
description = _("Current news from Kasu") description = _("Current news from Kasu")
title = "Kasu - traditonelle asiatische Spielkultur" link = "http://www.kasu.at/"
title = _("Current news from Kasu")
feed_type = Rss201rev2Feed feed_type = Rss201rev2Feed
def items(self): def items(self) -> object:
"""get the newest published news articles for the feed.""" """get the newest published news articles for the feed."""
return Article.objects.published()[:MAX_ARTICLE_ITEMS] return Article.objects.published()[:MAX_ARTICLE_ITEMS]
@@ -78,5 +78,3 @@ class LatestComments(Feed):
'user_name': item.user_name, 'user_name': item.user_name,
'content_object': item.content_object 'content_object': item.content_object
} }
# Stop ignoring

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: kasu.content\n" "Project-Id-Version: kasu.content\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-09 22:00+0200\n" "POT-Creation-Date: 2023-07-27 00:05+0200\n"
"PO-Revision-Date: 2018-01-12 15:25+0105\n" "PO-Revision-Date: 2018-01-12 15:25+0105\n"
"Last-Translator: b'Christian Berg <kasu@xendynastie.at>'\n" "Last-Translator: b'Christian Berg <kasu@xendynastie.at>'\n"
"Language-Team: Deutsch <>\n" "Language-Team: Deutsch <>\n"
@@ -210,21 +210,23 @@ msgstr "Teile auf"
msgid "Edit Article" msgid "Edit Article"
msgstr "Artikel bearbeiten" msgstr "Artikel bearbeiten"
#: templates/content/article_form.html:32 templates/content/page_form.html:42 #: templates/content/article_form.html:24
#: templates/content/article_form.html:31 templates/content/page_form.html:42
#: templates/content/page_form.html:49 #: templates/content/page_form.html:49
msgid "German" msgid "German"
msgstr "Deutsch" msgstr "Deutsch"
#: templates/content/article_form.html:33 templates/content/page_form.html:43 #: templates/content/article_form.html:25
#: templates/content/article_form.html:39 templates/content/page_form.html:43
#: templates/content/page_form.html:57 #: templates/content/page_form.html:57
msgid "English" msgid "English"
msgstr "Englisch" msgstr "Englisch"
#: templates/content/article_form.html:59 templates/content/page_form.html:66 #: templates/content/article_form.html:47 templates/content/page_form.html:66
msgid "reset" msgid "reset"
msgstr "Zurücksetzen" msgstr "Zurücksetzen"
#: templates/content/article_form.html:60 templates/content/page_form.html:67 #: templates/content/article_form.html:48 templates/content/page_form.html:67
msgid "save" msgid "save"
msgstr "Speichern" msgstr "Speichern"

View File

@@ -111,6 +111,7 @@ class Article(models.Model):
"""Returns the headline of this article.""" """Returns the headline of this article."""
return self.headline return self.headline
# noinspection PyUnresolvedReferences
@property @property
def get_image(self): def get_image(self):
"""Return the article image, or the category image if unset.""" """Return the article image, or the category image if unset."""
@@ -169,6 +170,7 @@ class Category(models.Model):
return self.name return self.name
# noinspection PyUnresolvedReferences
class Page(models.Model): class Page(models.Model):
"""A page on this homepage. It can have a "static" HTML page, the URL of a """A page on this homepage. It can have a "static" HTML page, the URL of a
dynamic Django view, or a PDF document. dynamic Django view, or a PDF document.
@@ -317,12 +319,12 @@ class Page(models.Model):
raise ValidationError( raise ValidationError(
_(u'Please upload a PDF-File to this PDF-Page.')) _(u'Please upload a PDF-File to this PDF-Page.'))
def get_absolute_url(self): def get_absolute_url(self) -> str:
"""Return the path with an extension that matches the content type. """Return the path with an extension that matches the content type.
It's useful for an user to match the URL to the contenttype. It's useful for a user to match the URL to the contenttype.
:return: sting with the absolute URL of this page.""" :return: string with the absolute URL of this page."""
return '/' + self.path + CONTENT_TYPE_EXTENSIONS[self.content_type] return '/' + str(self.path) + CONTENT_TYPE_EXTENSIONS[self.content_type]
class Meta(object): class Meta(object):
"""Set default ordering and an unique priamry key to avoid dupes.""" """Set default ordering and an unique priamry key to avoid dupes."""

View File

@@ -8,7 +8,7 @@ class ArticleSitemap(GenericSitemap):
min_priority = 0.25 min_priority = 0.25
@staticmethod @staticmethod
def items(): def items(**kwargs):
"""only add published articles to the sitemap""" """only add published articles to the sitemap"""
return Article.objects.published() return Article.objects.published()
@@ -18,6 +18,6 @@ class PageSitemap(GenericSitemap):
min_priority = 0.5 min_priority = 0.5
@staticmethod @staticmethod
def items(): def items(**kwargs):
"""add all pages to the sitemap.""" """add all pages to the sitemap."""
return Page.objects.all() return Page.objects.all()

View File

@@ -53,10 +53,10 @@
{% block navigation %} {% block navigation %}
<ul id="navigation"> <ul id="navigation">
<li><a href="{{current_top_page.get_absolute_url}}" <li><a href="{{current_top_page.get_absolute_url}}"
{% if not active_category %} class="active" {% endif %}>{% trans 'All Categories' %}</a></li> class="active">{% trans 'All Categories' %}</a></li>
{% for category in categories %} {% for category in categories %}
<li><a href="{% url 'article-archive' category=category.slug %}" <li><a href="{% url 'article-archive' category=category.slug %}"
{% if category.slug == active_category.slug %} class="active"{% endif %}>{{ category.name }}</a></li> class="active">{{ category.name }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endblock %} {% endblock %}

View File

@@ -9,51 +9,39 @@
{% endblock %} {% endblock %}
{% block maincontent %} {% block maincontent %}
{% get_fieldset "category, image" from form as fieldset_common %}
{% get_fieldset "headline_de" from form as fieldset_de %}
{% get_fieldset "headline_en" from form as fieldset_en %}
<form action="" method="post" enctype="multipart/form-data"> <form action="" method="post" enctype="multipart/form-data">
{{ form.media }} {% csrf_token %} {{ form.media }} {% csrf_token %}
<fieldset> <fieldset>
<div> {% with fieldset_common as form %}{% include "form.html" %}{% endwith %}
<label for="id_category" class="field_name {{ form.category.css_classes }}">{{ form.category.label}}</label>
{{ form.category }}
{% if form.category.help_text %}<p class="help_text">{{form.category.help_text}}</p>{% endif %}
{% if form.category.errors %}{{ form.category.errors }}{% endif %}
</div>
<div>
<label for="id_image" class="field_name {{ form.image.css_classes }}">{{ form.image.label}}</label>
{{ form.image }}
{% if form.image.help_text %}<p class="help_text">{{form.image.help_text}}</p>{% endif %}
{% if form.image.errors %}{{ form.image.errors }}{% endif %}
</div>
</fieldset> </fieldset>
<ul class="tabs grid_12"> <ul class="tabs">
<li><a href="#de">{% trans "German" %}</a></li> <li><a href="#de">{% trans "German" %}</a></li>
<li><a href="#en">{% trans "English" %}</a></li> <li><a href="#en">{% trans "English" %}</a></li>
</ul> </ul>
<label for="id_{{ form.headline_de.html_name }}" class="fieldname {{ form.headline_de.css_classes }}">
{{ form.headline_de.label }}</label>
<p class="grid_10">{{ form.headline_de }}</p>
<div class="tab_container"> <div class="tab_container">
<div id="de" class="tab_content"> <section id="de" class="tab_content">
<fieldset> <fieldset class="grid_12">
<legend>Deutsch</legend> <legend>{% trans "German" %}</legend>
<label for="id_{{ form.headline_de.html_name }}" class="fieldname {{ form.headline_de.css_classes }}"> {% with fieldset_de as form %}{% include "form.html" %}{% endwith %}
{{ form.headline_de.label }}</label>
<p class="grid_10">{{ form.headline_de }}</p>
</fieldset> </fieldset>
<br>
{{form.content_de}} {{form.content_de}}
</div> </section>
<div id="en" class="tab_content"> <section id="en" class="tab_content">
<h3 class="grid_12">English</h3> <fieldset class="grid_12">
<label for="id_{{ form.headline_en.html_name }}" class="grid_2 {{ form.headline_en.css_classes }}"> <legend>{% trans "English" %}</legend>
{{ form.headline_en.label }}</label> {% with fieldset_en as form %}{% include "form.html" %}{% endwith %}
<p class="grid_10">{{ form.headline_en }}</p> </fieldset>
<p>&nbsp;</p> <br>
{{form.content_en}} {{form.content_en}}
</div> </section>
</div> </div>
<p class="buttonbar"> <p class="buttonbar">
<button type="reset"><span class="fa fa-undo"></span> {% trans 'reset' %}</button> <button type="reset"><span class="fa fa-undo"></span> {% trans 'reset' %}</button>

View File

@@ -1,66 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>{% block title %}{{page.title}}{% endblock %}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
@font-face {
font-family: 'Amerika Sans';
src: url('{{ STATIC_ROOT }}/fonts/amerika_sans.ttf');
}
@font-face {
font-family: 'Philosopher';
src: url('{{ STATIC_ROOT }}/fonts/philosopher-regular.ttf');
font-weight: normal;
font-style: normal;
}
h1,h2,h3,h4,h5,h6 {
font-family: 'Amerika Sans', Helvetica;
font-variant: small-caps;
font-weight: bold;
margin: 0.5em 0 0.2em 0;
}
body {
font-family: Philosopher;
font-size: 12pt;
}
#page_header {
text-align: right;
}
@page {
margin-right: 0;
margin-bottom: 0;
margin-top: 35mm;
margin-left: 2cm;
@frame header {
-pdf-frame-content : page_header;
top: 0;
margin: 5mm;
height: 4cm;
}
@frame footer {
-pdf-frame-content: page_footer;
bottom: 0cm;
height: 2cm;
margin: 5mm;
}
}
</style>
</head>
<body>
<h1>{{ page.title }}</h1>
{{ page.content }}
<div id="page_header">
<img src="{{STATIC_ROOT}}/img/logo.png" alt="Kasu">
</div>
<div id="page_footer">
{{ page.title }} Seite:
<pdf:pagenumber />
</div>
</body>
</html>

View File

@@ -19,7 +19,7 @@ class WYSIWYGEditorMixin(PermissionRequiredMixin):
@csp_update(SCRIPT_SRC="'unsafe-eval'") @csp_update(SCRIPT_SRC="'unsafe-eval'")
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
"""Add "unsafe-eval" to the Content-Secuirty-Policy HTTP Headers for the """Add "unsafe-eval" to the Content-Security-Policy HTTP Headers for the
WYSIWYG Editor. WYSIWYG Editor.
:param request: the HTTP Request Object :param request: the HTTP Request Object
@@ -40,7 +40,7 @@ class ArticleArchiveMixin(object):
Filter the queryset by category if one has been specified in the URL Filter the queryset by category if one has been specified in the URL
:param queryset: an model.Article.objects Queryset :param queryset: an model.Article.objects Queryset
:return: an model.Article.objects Queryset filterd by category :return: an model.Article.objects Queryset filtered by category
""" """
category_slug = self.kwargs.get('category') category_slug = self.kwargs.get('category')
@@ -90,7 +90,7 @@ class ArticleArchiveIndex(ArticleArchiveMixin, generic.ArchiveIndexView):
class ArticleYearArchive(ArticleArchiveMixin, generic.YearArchiveView): class ArticleYearArchive(ArticleArchiveMixin, generic.YearArchiveView):
""" """
Displays the Articles filterd by a specific year Displays the Articles filtered by a specific year
""" """
queryset = models.Article.objects.filter(status=models.STATUS_PUBLISHED) queryset = models.Article.objects.filter(status=models.STATUS_PUBLISHED)
@@ -113,7 +113,7 @@ class ArticleYearArchive(ArticleArchiveMixin, generic.YearArchiveView):
class ArticleMonthArchive(ArticleArchiveMixin, generic.MonthArchiveView): class ArticleMonthArchive(ArticleArchiveMixin, generic.MonthArchiveView):
""" """
Displays the Articles filterd by a specific month Displays the Articles filtered by a specific month
""" """
queryset = models.Article.objects.filter(status=models.STATUS_PUBLISHED) queryset = models.Article.objects.filter(status=models.STATUS_PUBLISHED)
@@ -138,6 +138,7 @@ class ArticleDetail(generic.DetailView):
""" """
Render the news Article, but only if it got published. Render the news Article, but only if it got published.
""" """
def get_queryset(self): def get_queryset(self):
queryset = models.Article.objects.filter(status=models.STATUS_PUBLISHED) queryset = models.Article.objects.filter(status=models.STATUS_PUBLISHED)
queryset = queryset.filter(date_created__year=self.kwargs['year']) queryset = queryset.filter(date_created__year=self.kwargs['year'])
@@ -173,7 +174,7 @@ class ArticleForm(WYSIWYGEditorMixin, generic.UpdateView):
class PageAddForm(WYSIWYGEditorMixin, generic.CreateView): class PageAddForm(WYSIWYGEditorMixin, generic.CreateView):
""" Renders an Form to create a new page for users with conforming """ Renders a Form to create a new page for users with conforming
permissions.""" permissions."""
form_class = forms.PageForm form_class = forms.PageForm
@@ -195,7 +196,7 @@ class PageAddForm(WYSIWYGEditorMixin, generic.CreateView):
class PageEditForm(WYSIWYGEditorMixin, generic.UpdateView): class PageEditForm(WYSIWYGEditorMixin, generic.UpdateView):
"""Renders an Form to edit a page for users with conforming permissions.""" """Renders a Form to edit a page for users with conforming permissions."""
form_class = forms.PageForm form_class = forms.PageForm
model = models.Page model = models.Page
@@ -204,7 +205,7 @@ class PageEditForm(WYSIWYGEditorMixin, generic.UpdateView):
def get_object(self, queryset=None): def get_object(self, queryset=None):
""" Get the path from the URL and fetch the corresponding page. """ Get the path from the URL and fetch the corresponding page.
First get the path wihout fileextentsion leading or trailing slashes, First get the path without file extension leading or trailing slashes,
then search in the database if such a page exists. then search in the database if such a page exists.
:param queryset: Get the single item from this filtered queryset. :param queryset: Get the single item from this filtered queryset.
@@ -273,9 +274,9 @@ class PagePdf(generic.DeleteView):
def render_to_response(self, context, **response_kwargs): def render_to_response(self, context, **response_kwargs):
"""Stream the PDF File to the client and set the right content headers. """Stream the PDF File to the client and set the right content headers.
:param context: useless only for compatility :param context: useless only for compatibility
:param response_kwargs: will be added to the HttpResponse kwargs. :param response_kwargs: will be added to the HttpResponse kwargs.
:return: an HTTPResponse with PDF Content or an Http404 exception :return: an HTTPResponse with PDF Content or a Http404 exception
""" """
try: try:
with open(self.object.pdf_file.path, 'rb') as pdf_file: with open(self.object.pdf_file.path, 'rb') as pdf_file:
@@ -285,8 +286,8 @@ class PagePdf(generic.DeleteView):
**response_kwargs **response_kwargs
) )
return response return response
except: except FileExistsError:
raise Http404('File not Found %s.pdf' % self.kwargs['path']) raise Http404('File %s.pdf not found' % self.kwargs['path'])
class StartPage(generic.TemplateView): class StartPage(generic.TemplateView):
@@ -294,7 +295,7 @@ class StartPage(generic.TemplateView):
template_name = 'index.html' template_name = 'index.html'
def get_context_data(self): def get_context_data(self):
""" Adds recent ariticles and recent comments to the context. """ Adds recent articles and recent comments to the context.
:return: array() with the context data :return: array() with the context data
""" """

View File

@@ -1,6 +1,6 @@
"""Django admin interface for the event app. """Django admin interface for the event app.
It's the best way to add eventseries, or edit/delete events.""" It's the best way to add event-series, or edit/delete events."""
from django.contrib import admin from django.contrib import admin
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
@@ -8,7 +8,7 @@ from events.models import Event, Photo, Location
class EventInline(admin.TabularInline): class EventInline(admin.TabularInline):
"""To list events of an eventseries below the 'master event'""" """To list events of an event-series below the 'master event'"""
model = Event model = Event
fields = ('name', 'start', 'end') fields = ('name', 'start', 'end')
verbose_name_plural = _('Event Series') verbose_name_plural = _('Event Series')

View File

@@ -1,20 +1,20 @@
""" Content processor to display upcoming events on every page you want. """ """ Content processor to display upcoming events on every page you want. """
from django.core.cache import cache from django.core.cache import cache
from django.http import HttpRequest
from .models import Event from .models import Event
def events_overview(request): # Ignore PyLintBear (W0613) def events_overview(request: HttpRequest) -> dict[str, Event]:
""" """
Adds event information as variables to the template context on every page. Adds event information as variables to the template context on every page.
For speed reasons everything will be cached for an hour. the following For speed reasons everything will be cached for an hour. the following
variables will be added to the template context: variables will be added to the template context:
* current_event: If an event is running at this moment, the correspondi * current_event: If an event is running at this moment, the corresponding event object.
event object.
* next_event: the next event that is upcoming. * next_event: the next event that is upcoming.
* upcoming_events: the next 3 events that are upcoming. * upcoming_events: the next 3 events that are upcoming.
:param request: An Django HTTPRequest object :param request: a Django HTTPRequest object
:return: dict() with the new context variables :return: dict() with the new context variables
""" """
current_event = cache.get('current_event', False) current_event = cache.get('current_event', False)

View File

@@ -1,4 +1,3 @@
""" urls for the event gallery part of the events app. """
from django.urls import path from django.urls import path
from . import views from . import views

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: kasu.events\n" "Project-Id-Version: kasu.events\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-11 10:15+0200\n" "POT-Creation-Date: 2023-07-26 18:31+0200\n"
"PO-Revision-Date: 2018-01-12 15:25+0105\n" "PO-Revision-Date: 2018-01-12 15:25+0105\n"
"Last-Translator: b'Christian Berg <kasu@xendynastie.at>'\n" "Last-Translator: b'Christian Berg <kasu@xendynastie.at>'\n"
"Language-Team: Kasu <verein@kasu.at>\n" "Language-Team: Kasu <verein@kasu.at>\n"
@@ -35,7 +35,7 @@ msgstr "Beginn"
msgid "end" msgid "end"
msgstr "Ende" msgstr "Ende"
#: mixins.py:86 #: mixins.py:87
msgid "Event does not exist" msgid "Event does not exist"
msgstr "Veranstaltung gibt es nicht" msgstr "Veranstaltung gibt es nicht"

View File

@@ -1,4 +1,5 @@
"""Mixins for Events.""" """Mixins for Events."""
from django.core.exceptions import ImproperlyConfigured
from django.db.models import Q from django.db.models import Q
from django.http import Http404 from django.http import Http404
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
@@ -32,8 +33,7 @@ class EventDetailMixin(object):
event = None event = None
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Add self.event or the related event of self.object to the template """Add this event or the related event of the given object to the template context.
context.
:return: TemplateContext object""" :return: TemplateContext object"""
context = super(EventDetailMixin, self).get_context_data(**kwargs) context = super(EventDetailMixin, self).get_context_data(**kwargs)

View File

@@ -1,4 +1,4 @@
"""Models to solitary events, events series with an location and photos.""" """Models to solitary events, events series with a location and photos."""
import os import os
from ckeditor.fields import RichTextField from ckeditor.fields import RichTextField
@@ -16,14 +16,15 @@ from utils import COUNTRIES, OverwriteStorage
from .managers import EventManager from .managers import EventManager
def get_upload_path(instance, filename): def get_upload_path(instance: models.Model, filename: str) -> str:
""" """
Generates the desired file path and filename for an uploaded Image. Generates the desired file path and filename for an uploaded Image.
With this function Django can save the uploaded images to subfolders that With this function Django can save the uploaded images to a subfolder that
also have a meaning for humans. also have a meaning for humans.
@param instance: an Django Object for which the Image has been uploaded. @return: String: path for the image.
@type instance: a instace of an models.Model sub-class. @param instance: a Django Object for which the Image has been uploaded.
@type instance: an instance of a models.Model subclass.
@param filename: The filename of the uploaded image. @param filename: The filename of the uploaded image.
@type filename: String @type filename: String
""" """
@@ -48,7 +49,7 @@ def get_upload_path(instance, filename):
class Event(models.Model): class Event(models.Model):
"""An Event that could be a tournament, a game session, or an convention.""" """An Event that could be a tournament, a game session, or a convention."""
name = models.CharField(_('Name'), max_length=255) name = models.CharField(_('Name'), max_length=255)
description = RichTextField(_("Description"), blank=True) description = RichTextField(_("Description"), blank=True)
location = models.ForeignKey('Location', on_delete=models.PROTECT) location = models.ForeignKey('Location', on_delete=models.PROTECT)
@@ -131,7 +132,7 @@ class Event(models.Model):
'year': self.start.strftime('%Y'), 'year': self.start.strftime('%Y'),
'month': self.start.strftime('%m') 'month': self.start.strftime('%m')
} }
return reverse('eventseries-form', kwargs=kwargs) return reverse('event-series-form', kwargs=kwargs)
def get_edit_url(self): def get_edit_url(self):
kwargs = { kwargs = {
@@ -167,7 +168,7 @@ class Event(models.Model):
self.photo_count = self.photo_set.count() self.photo_count = self.photo_set.count()
super(Event, self).save(**kwargs) super(Event, self).save(**kwargs)
# Update the Hanchans if necesery: # Update the Hanchans if necessary:
for hanchan in self.hanchan_set.all(): for hanchan in self.hanchan_set.all():
hanchan.save() hanchan.save()
@@ -267,7 +268,7 @@ class Photo(models.Model):
return os.path.basename(self.image.name) return os.path.basename(self.image.name)
def rotate(self, rotate): def rotate(self, rotate):
# TODO: Eine vernüftigte Methode ohne viele Abhängigkeiten finden um # TODO: Eine vernünftige Methode ohne viele Abhängigkeiten finden um
# die Bilder bei Bedarf zu drehen. # die Bilder bei Bedarf zu drehen.
if rotate == 'clockwise': if rotate == 'clockwise':
pass pass

View File

@@ -1,4 +1,3 @@
"""To geneate a Sitemap with all events."""
from kasu.sitemaps import GenericSitemap from kasu.sitemaps import GenericSitemap
from django.utils import timezone from django.utils import timezone
from .models import Event from .models import Event
@@ -6,11 +5,13 @@ from .models import Event
class EventSitemap(GenericSitemap): class EventSitemap(GenericSitemap):
"""sitemap to help indexing all events on this site.""" """sitemap to help indexing all events on this site."""
changefreq = "never" changefreq: str = "never"
protocol = 'https' protocol: str = 'https'
priority_field = 'start' priority_field: str = 'start'
@staticmethod @staticmethod
def items(): def items(**kwargs) -> Event:
"""add all upcoming and archived events to the sitemap.""" """add all upcoming and archived events to the sitemap.
@param **kwargs:
"""
return Event.objects.all() return Event.objects.all()

View File

@@ -66,4 +66,5 @@
</div> </div>
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% block form %}{% endblock %}
{% endblock %} {% endblock %}

View File

@@ -10,7 +10,7 @@
{% include "form.html" %} {% include "form.html" %}
{% if event.id and event.event_set.count %} {% if event.id and event.event_set.count %}
<p class="warning"> <p class="warning">
<strong>Achtung! Das ist eine Veranstaltungsreihe!</strong> Diese kann man im Moment nur im Admin-Interface vernünfig bearbeiten.<br /> <strong>Achtung! Das ist eine Veranstaltungsreihe!</strong> Diese kann man im Moment nur im Admin-Interface vernünftig bearbeiten.<br />
Du bearbeitest hier den "Hauptevent" der Reihe ({{event.event_set.count}}). Alle Änderungen (abgesehen von Name, Start und Ende) werden von den darauf folgendem Veranstaltungen übernommen. Du bearbeitest hier den "Hauptevent" der Reihe ({{event.event_set.count}}). Alle Änderungen (abgesehen von Name, Start und Ende) werden von den darauf folgendem Veranstaltungen übernommen.
</p> </p>
{% endif %} {% endif %}

View File

@@ -5,7 +5,7 @@
<form action="" method="post" class="grid_12"> <form action="" method="post" class="grid_12">
{% csrf_token %} {% csrf_token %}
<header> <header>
<h1 class="grid_12">Dieses Photo wirklich löschen?</h1> <h1 class="grid_12">Dieses Foto wirklich löschen?</h1>
</header> </header>
<p>Sind Sie sicher, dass Sie das Bild &ldquo;{{photo.name}}&rdquo; löschen wollen?</p> <p>Sind Sie sicher, dass Sie das Bild &ldquo;{{photo.name}}&rdquo; löschen wollen?</p>
<img src="{{photo.image|thumbnail_url:'display'}}" alt="{{photo.name}}" title="{{photo.name}}" class="grid_10 push_1"/> <img src="{{photo.image|thumbnail_url:'display'}}" alt="{{photo.name}}" title="{{photo.name}}" class="grid_10 push_1"/>

View File

@@ -59,9 +59,6 @@ if ($('a.next').attr('href')) {
<a class="button" href="http://facebook.com/sharer.php?u=http%3A%2F%2Fwww.kasu.at{{photo.get_absolute_url|urlencode}}" target="_blank" rel="nofollow"> <a class="button" href="http://facebook.com/sharer.php?u=http%3A%2F%2Fwww.kasu.at{{photo.get_absolute_url|urlencode}}" target="_blank" rel="nofollow">
<span class="fa fa-twitter"></span>Facebook <span class="fa fa-twitter"></span>Facebook
</a> </a>
<a class="button" href="https://m.google.com/app/plus/x/?v=compose&amp;content={{photo.headline|urlencode}}+-+http%3A%2F%2Fwww.kasu.at/{{photo.get_absolute_url|urlencode}}" target="_blank" rel="nofollow">
<span class="fa fa-google-plus"></span> Google+
</a>
<a class="button" href="https://twitter.com/share?url=http%3A%2F%2Fwww.kasu.at/{{photo.get_absolute_url|urlencode}}" target='_blank' rel="nofollow"> <a class="button" href="https://twitter.com/share?url=http%3A%2F%2Fwww.kasu.at/{{photo.get_absolute_url|urlencode}}" target='_blank' rel="nofollow">
<span class="fa fa-twitter"></span> Twitter <span class="fa fa-twitter"></span> Twitter
</a> </a>

View File

@@ -1,46 +1,10 @@
{% extends "base.html" %} {% extends "events/event_archive.html" %}
{% load i18n comments thumbnail %} {% load i18n comments thumbnail %}
{% block maincontent %} {% block bottom %}
{% for event in event_list %}
{% get_comment_count for event as comment_count %}
{% ifchanged %}<h3 class="grid_12">{{ event.start|date:'F Y' }}</h3>{% endifchanged %}
<div style="float:left">
<a href="{% url 'event-photo-list' event.pk %}"><img src="{{ event.get_image|thumbnail_url:'thumbnail' }}" alt="" class="thumbnail"/></a>
<div class="grid_4" />
<h4><a href="{% url 'event-photo-list' event.pk %}">{{ event.name }}</a></h4>
<div class="info">
<span class="fa fa-calendar-o" title="{% trans 'Start' %}"></span>
{{ event.start|date }}
{% if event.end %}
{% trans "from" %} {{ event.start|time:'H:i' }} {% trans "to" %} {{ event.end|time:'H:i' }}
{% else %}
{{ event.start|time:'H:i' }}
{% endif %}
</div>
{% if event.description %}<p>{{event.description}}</p>{% endif %}
<div class="info">
<span class="fa fa-map-marker" title="{% trans 'Location' %}"></span>
{{ event.location }}
<span class="fa fa-comments" title="{% trans 'Comments' %}"></span>
<a href="{{event.get_absolute_url}}#comments">{{ comment_count }} {% trans 'Comments' %}</a>
<span class="fa fa-camera-retro" title="{% trans 'Photos' %}"></span>
<a href="{% url 'event-photo-list' event.pk %}">{{ event.photo_count }} {% trans 'Photos' %}</a>
</div>
<p style="text-align:right">
{% if perms.events.add_photo %}
<a href="{% url 'event-photo-list' event.pk %}" class="button">
<span class="fa fa-cloud-upload"></span>
{%trans "Upload" %}</a>
{% endif %}
</p>
</div>
{% endfor %}
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<fieldset class="grid_8 push_2"> <fieldset id="bottom_buttonbar" class="grid_12">
<legend>Photos hochladen</legend> <legend>Photos hochladen</legend>
{% include "form.html" %} {% include "form.html" %}
<p class="buttonbar"> <p class="buttonbar">
@@ -52,5 +16,5 @@
</fieldset> </fieldset>
</form> </form>
{% endblock %} {% endblock %}
{% block buttonbar %}
{% endblock %}

View File

@@ -1,20 +1,19 @@
""" """
This file should test the functionality of the events app using the unittest This file should test the functionality of the events app using the unittest
module. These will pass when you run "manage.py test". module. These will pass when you run "manage.py test".
useful tests have to be written yet. sorry!
Usefull tests have to been written yet. sorry!
""" """
from django.test import TestCase from django.test import TestCase
class EventTest(TestCase): class EventTest(TestCase):
""" Here we should test the creation and modifiaction of Events. """ """ Here we should test the creation and modification of Events. """
class LocationTest(TestCase): class LocationTest(TestCase):
""" Here we should test the creation and modifiaction of Locations. """ """ Here we should test the creation and modification of Locations. """
class PhotoTest(TestCase): class PhotoTest(TestCase):
""" Here we should test the creation and modifiaction of Photos. """ """ Here we should test the creation and modification of Photos. """

View File

@@ -8,7 +8,7 @@ urlpatterns = [
path('<int:year>/', views.EventArchiveYear.as_view(), name='event-archive'), path('<int:year>/', views.EventArchiveYear.as_view(), name='event-archive'),
path('<int:year>/<int:month>/', views.EventArchiveMonth.as_view(), name='event-archive'), path('<int:year>/<int:month>/', views.EventArchiveMonth.as_view(), name='event-archive'),
path('<int:year>/<int:month>/<int:pk>/', views.EventDetail.as_view(), name='event-detail'), path('<int:year>/<int:month>/<int:pk>/', views.EventDetail.as_view(), name='event-detail'),
path('<int:year>/<int:month>/<int:pk>/add_dates/', views.EventSeriesForm.as_view(), name='eventseries-form'), path('<int:year>/<int:month>/<int:pk>/add_dates/', views.EventSeriesForm.as_view(), name='event-series-form'),
path('<int:year>/<int:month>/<int:pk>/edit/', views.EventForm.as_view(), name='event-form'), path('<int:year>/<int:month>/<int:pk>/edit/', views.EventForm.as_view(), name='event-form'),
path('add/', views.EventForm.as_view(), name='event-form'), path('add/', views.EventForm.as_view(), name='event-form'),
path('archive/', views.EventArchiveIndex.as_view(), name='event-archive'), path('archive/', views.EventArchiveIndex.as_view(), name='event-archive'),

View File

@@ -50,19 +50,15 @@ class EventDetail(mixins.EventDetailMixin, generic.DetailView):
class EventForm(PermissionRequiredMixin, mixins.EventDetailMixin, class EventForm(PermissionRequiredMixin, mixins.EventDetailMixin,
generic.UpdateView): generic.UpdateView):
"""Frontend formular to add or edit a Event.""" """Frontend formular to add or edit an Event."""
form_class = forms.EventForm form_class = forms.EventForm
template_name = 'events/event_form.html' template_name = 'events/event_form.html'
permission_required = 'events.add_event' permission_required = 'events.add_event'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Dynamicle set the title to Add or Edit Event, depanding if an """set the title to add or edit Event, depending on the fact if an event ID was given."""
event ID was given, or not."""
context = super(EventForm, self).get_context_data(**kwargs) context = super(EventForm, self).get_context_data(**kwargs)
if self.kwargs.get('pk'): context['title'] = _("Edit Event") if self.kwargs.get('pk') else _("Add Event")
context['title'] = _("Edit Event")
else:
context['title'] = _("Add Event")
return context return context
def get_object(self, queryset=None): def get_object(self, queryset=None):
@@ -74,7 +70,7 @@ class EventForm(PermissionRequiredMixin, mixins.EventDetailMixin,
class EventGallery(generic.ListView): class EventGallery(generic.ListView):
"""Display a overview of all event photo albums.""" """Display an overview of all event photo albums."""
template_name = 'events/photo_gallery.html' template_name = 'events/photo_gallery.html'
paginate_by = 24 paginate_by = 24
@@ -89,7 +85,7 @@ class EventGallery(generic.ListView):
class EventListIcal(generic.View): class EventListIcal(generic.View):
"""Generates an returns an iCal File with all upcoming events.""" """Generates and returns an iCal File with all upcoming events."""
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
"""Add all upcoming events to an .ics file and send it.""" """Add all upcoming events to an .ics file and send it."""
@@ -132,7 +128,7 @@ class EventPhoto(mixins.EventPhotoMixin, generic.UpdateView):
class EventPhotoList(mixins.EventPhotoMixin, generic.ListView): class EventPhotoList(mixins.EventPhotoMixin, generic.ListView):
"""List all Photos of the event or event series in an album.""" """List all Photos of the event or event series."""
context_object_name = 'photo_list' context_object_name = 'photo_list'
event = None event = None
paginate_by = 36 paginate_by = 36

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: kasu.utils\n" "Project-Id-Version: kasu.utils\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-20 21:25+0200\n" "POT-Creation-Date: 2023-07-26 18:31+0200\n"
"PO-Revision-Date: 2018-12-30 11:14+0105\n" "PO-Revision-Date: 2018-12-30 11:14+0105\n"
"Last-Translator: b' <kasu@xendynastie.at>'\n" "Last-Translator: b' <kasu@xendynastie.at>'\n"
"Language-Team: Kasu <verein@kasu.at>\n" "Language-Team: Kasu <verein@kasu.at>\n"
@@ -215,11 +215,11 @@ msgstr "Besuche uns auf"
msgid "Add Article" msgid "Add Article"
msgstr "Artikel hinzufügen" msgstr "Artikel hinzufügen"
#: templates/paginator.html:8 #: templates/paginator.html:7
msgid "Previous" msgid "Previous"
msgstr "Vorherige" msgstr "Vorherige"
#: templates/paginator.html:20 #: templates/paginator.html:18
msgid "Next" msgid "Next"
msgstr "Nächste" msgstr "Nächste"

View File

@@ -37,7 +37,7 @@
{% block extra_head %}{% endblock %} {% block extra_head %}{% endblock %}
<script src="{{ STATIC_URL }}js/piwik.js"></script> <script src="{{ STATIC_URL }}js/piwik.js"></script>
</head> </head>
<body id="body" {% block itemscope %}{% endblock %}> <body id="body" itemscope>
<header id="siteheader"> <header id="siteheader">
<div id="sitelogo"><a href="/index.html">Kasu - traditionelle asiatische Spielkultur</a></div> <div id="sitelogo"><a href="/index.html">Kasu - traditionelle asiatische Spielkultur</a></div>
<nav id="mainnav"> <nav id="mainnav">
@@ -51,7 +51,7 @@
<ul class="main_dropdown"> <ul class="main_dropdown">
{% for subpage in item.subpages.all %}<li><a {% for subpage in item.subpages.all %}<li><a
href="{{subpage.get_absolute_url}}" href="{{subpage.get_absolute_url}}"
{% if subpage == current_page %}class="active"{% endif %}>{{subpage.menu_name}}</a></li> >{{subpage.menu_name}}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
@@ -142,20 +142,21 @@
{% endblock %} {% endblock %}
{% block comments %}{% endblock %} {% block comments %}{% endblock %}
<br class="clear"/> <br class="clear"/>
<p id="bottom_buttonbar" class="buttonbar"> {% block bottom %}
<div id="bottom_buttonbar" class="buttonbar">
{% block buttonbar %} {% block buttonbar %}
{% if current_page and perms.content.add_page %} {% if current_page and perms.content.add_page %}
<a href="{% url 'add-page' current_page.path %}" class="button"><span class="fa fa-plus"></span> <a href="{% url 'add-page' current_page.path %}" class="button"><span class="fa fa-plus"></span>
{% trans "Add Subpage" %}</a> {% trans "Add Subpage" %}</a>
{% endif %} {% endif %}
{% if current_page and perms.content.change_page %} {% if current_page and perms.content.change_page %}
<a href="{% url 'edit-page' current_page.path %}" class="button"><span class="fa fa-pencil"></span> <a href="{% url 'edit-page' current_page.path %}" class="button"><span class="fa fa-pencil"></span>
{% trans "Edit Page" %}</a> {% trans "Edit Page" %}</a>
{% endif %} {% endif %}
{% block additional_buttonbar %}{% endblock %} {% block additional_buttonbar %}{% endblock %}
{% endblock %} {% endblock %}
</p> </div>
{% endblock %}
</main> </main>
<footer id="footer"> <footer id="footer">
<p><strong>Herausgeber:</strong> Verein Kasu - traditionelle asiatische Spielkultur (<a <p><strong>Herausgeber:</strong> Verein Kasu - traditionelle asiatische Spielkultur (<a
@@ -169,8 +170,8 @@
<select name="language" id="language"> <select name="language" id="language">
{% get_language_info_list for LANGUAGES as languages %} {% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %} {% for language in languages %}
<option value="{{language.code}}" {% if language.code == LANGUAGE_CODE %} <option value="{{language.code}}"
selected="selected" {% endif %}>{{ language.name_local }} ({{ language.code }}) selected="selected">{{ language.name_local }} ({{ language.code }})
</option> </option>
{% endfor %} {% endfor %}
</select> </select>

View File

@@ -16,7 +16,7 @@
</div> </div>
<header class="comment_header"> <header class="comment_header">
<a href="{{ user.get_profile.get_absolute_url }}" class="user">{{comment.user}}</a> <a href="{{ user.get_profile.get_absolute_url }}" class="user">{{comment.user}}</a>
<div class="submit_date"><time time="{% now 'c' %}">{% now 'DATETIME_FORMAT' %}</time></div> <div class="submit_date"><time>{% now 'DATETIME_FORMAT' %}</time></div>
</header> </header>
<div class="comment_text">{{comment}}</div> <div class="comment_text">{{comment}}</div>
</article> </article>

View File

@@ -1 +1,2 @@
<input type="{{ type|default:'text' }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} /> <input type="{{ type|default:'text' }}" name="{{ widget.name }}"
value="{{ widget.value|stringformat:'s' }}" "django/forms/widgets/attrs.html" %} />

View File

@@ -2,7 +2,7 @@
{% for hidden in form.hidden_fields %}{{ hidden }}{% endfor %} {% for hidden in form.hidden_fields %}{{ hidden }}{% endfor %}
{% for field in form.visible_fields %} {% for field in form.visible_fields %}
<div> <div>
<label {% if field.html_name != 'recaptcha' %} for="id_{{ field.html_name}}" {% endif %} <label for="id_{{ field.html_name}}"
class="field_name {{ field.css_classes }}">{{ field.label}}</label> class="field_name {{ field.css_classes }}">{{ field.label}}</label>
{{ field }} {{ field }}
{% if field.field.widget.input_type == 'checkbox' %} {% if field.field.widget.input_type == 'checkbox' %}

View File

@@ -1,22 +1,22 @@
{% load i18n %} {% load i18n %}
<nav class="grid_12 pagination"> <nav class="grid_12 pagination">
<a {% if page_obj.has_previous %} {% if page_obj.has_previous %}
class="previous" href="?page={{ page_obj.previous_page_number }}" <a class="previous" href="?page={{ page_obj.previous_page_number }}"><span class="fa fa-arrow-left"></span>
{% trans "Previous" %}</a>
{% else %} {% else %}
class="previous disabled" <a class="previous disabled"><span class="fa fa-arrow-left"></span>{% trans "Previous" %}</a>
{% endif %}> {% endif %}
<span class="fa fa-arrow-left"></span>{% trans "Previous" %}
</a>
{% for page in paginator.page_range %} {% for page in paginator.page_range %}
<a {% if page_obj.number == page %}class="active"{% else %}href="?page={{page}}"{% endif %}>{{page}}</a> {% if page_obj.number == page %}
{% endfor %} <a class="active">{{page}}</a>
<a {% if page_obj.has_next %}
class="next" href="?page={{ page_obj.next_page_number }}"
{% else %} {% else %}
class="next disabled" <a href="?page={{page}}">{{page}}</a>
{% endif %}> {% endif %}
{% trans "Next" %} <span class="fa fa-arrow-right"></span> {% endfor %}
</a> {% if page_obj.has_next %}
<a class="next" href="?page={{ page_obj.next_page_number }}">{% trans "Next" %}
<span class="fa fa-arrow-right"></span></a>
{% else %}
<a class="next disabled">{% trans "Next" %} <span class="fa fa-arrow-right"></span></a>
{% endif %}
</nav> </nav>

View File

@@ -20,7 +20,7 @@ admin.autodiscover()
sitemaps = { sitemaps = {
'event_rankings': EventRankingSitemap, 'event_rankings': EventRankingSitemap,
'event_hanchans': EventHanchanSitemap, 'event_hanchans': EventHanchanSitemap,
'mahjong_seasons': MajongSeasonSitemap, 'mahjong_seasons': MahjongSeasonSitemap,
'maistar_games': MaistarGamesSitemap, 'maistar_games': MaistarGamesSitemap,
'articles': ArticleSitemap, 'articles': ArticleSitemap,
'events': EventSitemap, 'events': EventSitemap,

View File

@@ -1,4 +1,4 @@
""" Adds management of the mahong ranking system to the admin interface. """ """ Adds management of the mahjong ranking system to the admin interface. """
from django.contrib import admin from django.contrib import admin
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
@@ -36,14 +36,14 @@ def confirm(modeladmin, request, queryset): # Ignore PyLintBear (W0613)
confirm.short_description = _("Confirm") confirm.short_description = _("Confirm")
def unconfirm(modeladmin, request, queryset): # Ignore PyLintBear (W0613) def reject(modeladmin, request, queryset): # Ignore PyLintBear (W0613)
"""An admin action to quickly set selected hanchans to unconfirmed. """ """An admin action to quickly set selected hanchans to unconfirmed. """
for hanchan in queryset: for hanchan in queryset:
hanchan.confirmed = False hanchan.confirmed = False
hanchan.save() hanchan.save()
unconfirm.short_description = _('Set unconfirmed') reject.short_description = _('Reject')
class EventRankingAdmin(admin.ModelAdmin): class EventRankingAdmin(admin.ModelAdmin):
@@ -57,7 +57,7 @@ class EventRankingAdmin(admin.ModelAdmin):
class HanchanAdmin(admin.ModelAdmin): class HanchanAdmin(admin.ModelAdmin):
""" To administrate the stored Hanchans. """ """ To administrate the stored Hanchans. """
actions = [recalculate, confirm, unconfirm] actions = [recalculate, confirm, reject]
date_hierarchy = 'start' date_hierarchy = 'start'
list_filter = ('season', 'event', 'confirmed') list_filter = ('season', 'event', 'confirmed')
search_fields = ('player_names',) search_fields = ('player_names',)

View File

@@ -64,7 +64,7 @@ class HanchanAdminForm(HanchanForm):
""" Extends the HanchanForm for users with admin privileges. """ Extends the HanchanForm for users with admin privileges.
They are allowed to confirm/unconfirm Hanchans, this could be userful if They are allowed to confirm/unconfirm Hanchans, this could be userful if
one games smells fishy and needs the opinion of an referee.""" one games smells fishy and needs the opinion of a referee."""
class Meta(object): class Meta(object):
""" Extend the formfields to add the confirmed checkbox. """ """ Extend the formfields to add the confirmed checkbox. """

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: kasu.mahjong_ranking\n" "Project-Id-Version: kasu.mahjong_ranking\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-20 21:25+0200\n" "POT-Creation-Date: 2023-07-27 00:05+0200\n"
"PO-Revision-Date: 2018-05-08 00:20+0105\n" "PO-Revision-Date: 2018-05-08 00:20+0105\n"
"Last-Translator: b'Christian Berg <kasu@xendynastie.at>'\n" "Last-Translator: b'Christian Berg <kasu@xendynastie.at>'\n"
"Language-Team: Kasu <verein@kasu.at>\n" "Language-Team: Kasu <verein@kasu.at>\n"

View File

@@ -1,4 +1,4 @@
"""Export Mahjong Rankings as excel files.""" """Export Mahjong Rankings as Excel files."""
import os import os
from datetime import date, time, datetime from datetime import date, time, datetime

View File

@@ -74,11 +74,12 @@ class HanchanManager(models.Manager):
[hanchan.get_playerdata(user) for hanchan in queryset] [hanchan.get_playerdata(user) for hanchan in queryset]
return queryset return queryset
def season_hanchans(self, user=None, season=None, until=None): def season_hanchans(self, user: object = None, season: int = None, until: date = None):
"""Return all Hanchans that belong to a given or the current season. """Return all Hanchans that belong to a given or the current season.
:param user: Only return Hanchans where this user participated. :param user: Only return Hanchans where this user participated.
:param season: the year of the wanted season, current year if None. :param season: the year of the wanted season, current year if None.
:param until: only return hanchans played until the given date.
:return: QuerySet Object :return: QuerySet Object
""" """
try: try:
@@ -92,6 +93,7 @@ class HanchanManager(models.Manager):
:param user: Return Hanchans where this user participated. :param user: Return Hanchans where this user participated.
:param since: only return Hanchans played since the given datetime :param since: only return Hanchans played since the given datetime
:param until: only return hanchans played until the given date.
:param filter_args: To add specific arguments to the Django filter. :param filter_args: To add specific arguments to the Django filter.
:return: a QuerySet Object :return: a QuerySet Object
""" """
@@ -199,10 +201,8 @@ class SeasonRankingManager(models.Manager):
class KyuDanRankingManager(models.Manager): class KyuDanRankingManager(models.Manager):
def json_data(self): def json_data(self):
""" Get all Rankings for a given Season and return them as a list of """ Get all Rankings for a given Season and return them as a list of
dict objects, suitable for JSON exports and other processings. dict objects, suitable for JSON exports and other processing.
:return: a list() of dict() objects suitable for JSON export.
:param season: Season that should be exported, current season if empty
:return: a list() of dict() objects suiteable for JSON export.
""" """
json_data = list() json_data = list()
values = self.all() values = self.all()

View File

@@ -48,9 +48,9 @@ class EventRanking(models.Model):
def recalculate(self): def recalculate(self):
""" """
Berechnet die durschnittliche Platzierung und Punkte, u.v.m. neu. Berechnet die durchschnittliche Platzierung und Punkte, u.v.m. neu.
Diese Daten werden benötigt um die Platzierung zu erstellen. Sie Diese Daten werden benötigt, um die Platzierung zu erstellen. Sie
können zwar sehr leicht errechnet werden, es macht trotzdem Sinn können zwar sehr leicht errechnet werden, es macht trotzdem Sinn
sie zwischenzuspeichern. sie zwischenzuspeichern.
""" """
@@ -291,9 +291,8 @@ class Hanchan(models.Model):
self.bonus_points = getattr(self, '%s_bonus_points' % player) self.bonus_points = getattr(self, '%s_bonus_points' % player)
self.player_comment = getattr(self, '%s_comment' % player) self.player_comment = getattr(self, '%s_comment' % player)
def update_playerdata(self, user, **kwargs): def update_player_data(self, user, **kwargs):
"""i small workaround to access score, placement of a specific user """to access scores and placement of a specific user from templates"""
prominent from a in the user templates"""
for player in ('player1', 'player2', 'player3', 'player4'): for player in ('player1', 'player2', 'player3', 'player4'):
if getattr(self, player) == user: if getattr(self, player) == user:
setattr(self, '%s_input_score' % player, self.input_score) setattr(self, '%s_input_score' % player, self.input_score)
@@ -423,7 +422,7 @@ class KyuDanRanking(models.Model):
def append_tournament_bonuspoints(self, hanchan): def append_tournament_bonuspoints(self, hanchan):
""" """
Prüft ob es die letzte Hanchan in einem Turnier war. Wenn ja werden Prüft, ob es die letzte Hanchan in einem Turnier war. Wenn ja, werden
bei Bedarf Bonuspunkte vergeben, falls der Spieler das Turnier bei Bedarf Bonuspunkte vergeben, falls der Spieler das Turnier
gewonnen hat. gewonnen hat.
:param hanchan: Ein Player Objekt :param hanchan: Ein Player Objekt
@@ -525,7 +524,7 @@ class KyuDanRanking(models.Model):
self.append_tournament_bonuspoints(hanchan) self.append_tournament_bonuspoints(hanchan)
self.update_rank() self.update_rank()
self.append_3_in_a_row_bonuspoints(hanchan) self.append_3_in_a_row_bonuspoints(hanchan)
hanchan.update_playerdata(self.user) hanchan.update_player_data(self.user)
hanchan.save(recalculate=False) hanchan.save(recalculate=False)
self.won_hanchans += 1 if hanchan.placement == 1 else 0 self.won_hanchans += 1 if hanchan.placement == 1 else 0
self.good_hanchans += 1 if hanchan.placement == 2 else 0 self.good_hanchans += 1 if hanchan.placement == 2 else 0
@@ -536,7 +535,7 @@ class KyuDanRanking(models.Model):
""" """
Berechne die Kyu bzw. Dan Punkte für eine Hanchan neu. Berechne die Kyu bzw. Dan Punkte für eine Hanchan neu.
:type hanchan: Hanchan :type hanchan: Hanchan
:param hanchan: Das Player Objekt das neuberechnet werden soll. :param hanchan: das Player-Objekt, welches neu berechnet werden soll.
""" """
hanchan.kyu_points = None hanchan.kyu_points = None
hanchan.dan_points = None hanchan.dan_points = None

View File

@@ -11,38 +11,42 @@ from .models import SeasonRanking
class EventRankingSitemap(GenericSitemap): class EventRankingSitemap(GenericSitemap):
@staticmethod @staticmethod
def items(): def items(**kwargs):
"""add all upcoming and archived events to the sitemap.""" """add all upcoming and archived events to the sitemap.
@param **kwargs:
"""
return Event.objects.all().exclude(eventranking=None) return Event.objects.all().exclude(eventranking=None)
@staticmethod @staticmethod
def location(event): def location(event, **kwargs):
return reverse('event-ranking', kwargs={'event': event.id}) return reverse('event-ranking', kwargs={'event': event.id})
class EventHanchanSitemap(GenericSitemap): class EventHanchanSitemap(GenericSitemap):
@staticmethod @staticmethod
def items(): def items(**kwargs):
"""add all upcoming and archived events to the sitemap.""" """add all upcoming and archived events to the sitemap.
@param **kwargs:
"""
return Event.objects.all().exclude(eventranking=None) return Event.objects.all().exclude(eventranking=None)
@staticmethod @staticmethod
def location(event): def location(event, **kwargs):
return reverse('event-hanchan-list', kwargs={'event': event.id}) return reverse('event-hanchan-list', kwargs={'event': event.id})
class MajongSeasonSitemap(Sitemap): class MahjongSeasonSitemap(Sitemap):
priority = 0.5 priority = 0.5
@staticmethod @staticmethod
def items(): def items(**kwargs):
seasons = SeasonRanking.objects.all().distinct('season').order_by( seasons = SeasonRanking.objects.all().distinct('season').order_by(
'season') 'season')
seasons = seasons.values_list('season', flat=True) seasons = seasons.values_list('season', flat=True)
return seasons return seasons
@staticmethod @staticmethod
def location(season): def location(season, **kwargs):
return reverse('mahjong-ladder', kwargs={'season': season}) return reverse('mahjong-ladder', kwargs={'season': season})
@staticmethod @staticmethod

View File

@@ -18,7 +18,7 @@
<fieldset class="hanchan"> <fieldset class="hanchan">
{% for hidden in form.hidden_fields %} {{ hidden }} {% endfor %} {% for hidden in form.hidden_fields %} {{ hidden }} {% endfor %}
<p> <p>
<label for="id_{{ form.start.html_name }}_0" class="field_name {{ form.start.css_classes }}">{{ form.start.label }}:</label> <label for="{{ form.start.if_for_label }}" class="field_name {{ form.start.css_classes }}">{{ form.start.label }}:</label>
{{ form.start }} {{ form.start }}
{{ form.start.errors }} {{ form.start.errors }}
</p> </p>

View File

@@ -33,7 +33,7 @@
<legend>{% trans "Delete Hanchan" %}</legend> <legend>{% trans "Delete Hanchan" %}</legend>
{% include 'form.html' %} {% include 'form.html' %}
<label class="field_name fa fa-exclamation-triangle fa-5x fa-pull-left" ></label> <label class="field_name fa fa-exclamation-triangle fa-5x fa-pull-left" ></label>
<p>Bist du sicher dass du diese Hanchan und alle Ergebnisse und Wertungen welche sich hierauf beziehen löschen möchtest?</p> <p>Bist du sicher, dass du diese Hanchan und alle Ergebnisse und Wertungen, welche sich hierauf beziehen löschen möchtest?</p>
<br class="clear"> <br class="clear">
<p class="buttonbar"> <p class="buttonbar">
<button type="button" onclick="window.history.back()"><span class="fa fa-close"></span> {% trans 'Cancel' %}</button> <button type="button" onclick="window.history.back()"><span class="fa fa-close"></span> {% trans 'Cancel' %}</button>

View File

@@ -31,7 +31,7 @@
{% for season_link in season_list%} {% for season_link in season_list%}
<option <option
value="{% url 'mahjong-ladder' season_link %}" value="{% url 'mahjong-ladder' season_link %}"
{% if season == season_link %} selected="selected"{% endif %}>{{ season_link }} selected="selected">{{ season_link }}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>

View File

@@ -64,7 +64,7 @@
<select id="season" name="season" size="1"> <select id="season" name="season" size="1">
{% for season_link in season_list%} {% for season_link in season_list%}
<option <option
{% if season == season_link %} selected="selected"{% endif %} selected="selected"
value="{{ season_link }}">{{ season_link }}</option> value="{{ season_link }}">{{ season_link }}</option>
{% endfor %} {% endfor %}
</select> </select>
@@ -75,5 +75,5 @@
{% endblock %} {% endblock %}
{% block buttonbar %} {% block buttonbar %}
<a href="?download=xlsx" class="button"><span class="fa fa-table"></span> Download</a> <a href="?download=xlsx{% if season %}&season={{ season }}{% endif %}" class="button"><span class="fa fa-table"></span> Download</a>
{% endblock %} {% endblock %}

View File

@@ -50,7 +50,7 @@
{% empty %} {% empty %}
<tr> <tr>
<td colspan="8">Leider hat es noch niemand in das Ranking geschafft. <td colspan="8">Leider hat es noch niemand in das Ranking geschafft.
Ein Spieler wird erst ins Ranking genommen wenn er 5 Hanchans absolviert hat. Spieler werden erst ins Ranking genommen, wenn sie 5 Hanchans absolviert haben.
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@@ -45,7 +45,7 @@ def get_kyu_dan_ranking(user=None):
class DeleteHanchan(EventDetailMixin, PermissionRequiredMixin, class DeleteHanchan(EventDetailMixin, PermissionRequiredMixin,
generic.DeleteView): generic.DeleteView):
"""Deletes a Hanchan if confimration has been answerd with 'yes'.""" """Deletes a Hanchan if confirmation has been answered with 'yes'."""
form_class = forms.HanchanForm form_class = forms.HanchanForm
model = models.Hanchan model = models.Hanchan
permission_required = 'mahjong_ranking.delete_hanchan' permission_required = 'mahjong_ranking.delete_hanchan'
@@ -53,7 +53,7 @@ class DeleteHanchan(EventDetailMixin, PermissionRequiredMixin,
def get_success_url(self): def get_success_url(self):
""" """
Return to the HachanList of the event form the deleted hanchan. Return to the HanchanList of the event form the deleted hanchan.
:return: URL of the EventHanchanList for the event :return: URL of the EventHanchanList for the event
""" """
return reverse('event-hanchan-list', return reverse('event-hanchan-list',
@@ -71,7 +71,7 @@ class HanchanForm(SuccessMessageMixin, EventDetailMixin,
def get_form_class(self): def get_form_class(self):
""" """
Users with hanchan edit persmission can also un-/confirm hanchans. Users with hanchan edit permission can also un-/confirm a Hanchan.
:return: forms.HanchanForm, or forms.HanchanAdminForm :return: forms.HanchanForm, or forms.HanchanAdminForm
""" """
return forms.HanchanAdminForm if self.request.user.has_perm( return forms.HanchanAdminForm if self.request.user.has_perm(
@@ -123,27 +123,27 @@ class HanchanForm(SuccessMessageMixin, EventDetailMixin,
class EventHanchanForm(EventDetailMixin, PermissionRequiredMixin, class EventHanchanForm(EventDetailMixin, PermissionRequiredMixin,
generic.TemplateView): generic.TemplateView):
"""Display a Formset to add and Edit Hanchans of the specific Event.""" """Display a Formset to add and Edit Hanchans of the specific Event."""
formset: forms.HanchanFormset
permission_required = 'mahjong_ranking.add_hanchan' permission_required = 'mahjong_ranking.add_hanchan'
template_name = 'mahjong_ranking/eventhanchan_form.html' template_name = 'mahjong_ranking/eventhanchan_form.html'
model = models.Hanchan model = models.Hanchan
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
self.event = models.Event.objects.get(pk=self.kwargs['event']) self.event = models.Event.objects.get(pk=self.kwargs['event'])
self.formset = forms.HanchanFormset(
instance=self.event,
initial=[{'start': self.event.start}]
)
context = super(EventHanchanForm, self).get_context_data() context = super(EventHanchanForm, self).get_context_data()
context['formset'] = self.formset context['formset'] = self.formset
return context return context
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.get_queryset() self.get_queryset()
self.formset = forms.HanchanFormset(
instance=self.event,
initial=[{'start': self.event.start}]
)
context = self.get_context_data(**kwargs) context = self.get_context_data(**kwargs)
return self.render_to_response(context) return self.render_to_response(context)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
print("ICH WURDE GEPOSTET!!!!")
self.get_queryset() self.get_queryset()
self.formset = forms.HanchanFormset( self.formset = forms.HanchanFormset(
self.request.POST, self.request.POST,
@@ -172,9 +172,9 @@ class EventRankingList(EventDetailMixin, generic.ListView):
class KyuDanRankingList(MahjongMixin, generic.ListView): class KyuDanRankingList(MahjongMixin, generic.ListView):
"""List all Players with an Kyu or Dan score. """ """List all Players with a Kyu or Dan score. """
order_by = None order_by = None
paginate_by = 25 paginate_by = 100
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
"""Set the order_by settings, revert to default_order if necessary.""" """Set the order_by settings, revert to default_order if necessary."""
@@ -192,7 +192,7 @@ class KyuDanRankingList(MahjongMixin, generic.ListView):
class SeasonRankingList(MahjongMixin, generic.ListView): class SeasonRankingList(MahjongMixin, generic.ListView):
model = models.SeasonRanking model = models.SeasonRanking
paginate_by = 25 paginate_by = 100
season = None season = None
def get_queryset(self): def get_queryset(self):
@@ -205,18 +205,23 @@ class SeasonRankingList(MahjongMixin, generic.ListView):
class PlayerScore(LoginRequiredMixin, generic.ListView): class PlayerScore(LoginRequiredMixin, generic.ListView):
paginate_by = 25 paginate_by: int = 100
user = auth.get_user_model() user = auth.get_user_model()
kyu_dan_ranking = None
season = None
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
user_model = auth.get_user_model() user_model = auth.get_user_model()
try: try:
self.user = user_model.objects.get( self.user = user_model.objects.get(
username=self.kwargs.get('username')) username=self.kwargs.get('username'))
self.kyu_dan_ranking = get_kyu_dan_ranking(user=self.user)
self.season = int(self.request.GET.get('season', date.today().year))
except user_model.DoesNotExist: except user_model.DoesNotExist:
raise django.http.Http404( raise django.http.Http404(
_("No user found matching the name {}").format( _("No user found matching the name {}").format(
self.kwargs.get('username'))) self.kwargs.get('username')))
if request.GET.get('download') == 'xlsx': if request.GET.get('download') == 'xlsx':
return self.get_xlsx(request, *args, **kwargs) return self.get_xlsx(request, *args, **kwargs)
return super(PlayerScore, self).get(request, *args, **kwargs) return super(PlayerScore, self).get(request, *args, **kwargs)
@@ -228,7 +233,7 @@ class PlayerScore(LoginRequiredMixin, generic.ListView):
context['kyu_dan_ranking'] = models.KyuDanRanking.objects.get( context['kyu_dan_ranking'] = models.KyuDanRanking.objects.get(
user=self.user) user=self.user)
except models.KyuDanRanking.DoesNotExist: except models.KyuDanRanking.DoesNotExist:
context['ranking'] = None context['kyu_dan_ranking'] = None
try: try:
context['ladder_ranking'] = models.SeasonRanking.objects.get( context['ladder_ranking'] = models.SeasonRanking.objects.get(
user=self.user, user=self.user,
@@ -238,27 +243,31 @@ class PlayerScore(LoginRequiredMixin, generic.ListView):
return context return context
def get_xlsx(self, request, *args, **kwargs): def get_xlsx(self, request, *args, **kwargs):
self.object_list = self.get_queryset()
response = django.http.HttpResponse( response = django.http.HttpResponse(
content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
response['Content-Disposition'] = 'attachment; ' \ response['Content-Disposition'] = f'attachment; filename="{self.xlsx_filename}"'
'filename="{xlsx_filename}"'.format( xlsx_workbook = xlsx.Workbook()
xlsx_filename=self.xlsx_filename) xlsx_workbook.generate_sheet(
xlxs_workbook = xlsx.Workbook()
xlxs_workbook.generate_sheet(
title=self.xlsx_filename.split('.')[0], title=self.xlsx_filename.split('.')[0],
columns_settings=self.xlsx_columns, columns_settings=self.xlsx_columns,
object_list=self.object_list object_list=self.get_queryset()
) )
xlxs_workbook.save(response) xlsx_workbook.save(response)
return response return response
@property
def xlsx_columns(self):
return {}
@property
def xlsx_filename(self):
return ""
class PlayerDanScore(PlayerScore): class PlayerDanScore(PlayerScore):
template_name = 'mahjong_ranking/player_dan_score.html' template_name = 'mahjong_ranking/player_dan_score.html'
def get_queryset(self): def get_queryset(self):
self.kyu_dan_ranking = get_kyu_dan_ranking(user=self.user)
return models.Hanchan.objects.dan_hanchans( return models.Hanchan.objects.dan_hanchans(
user=self.user, user=self.user,
since=self.kyu_dan_ranking.legacy_date) since=self.kyu_dan_ranking.legacy_date)
@@ -298,17 +307,20 @@ class PlayerDanScore(PlayerScore):
@property @property
def xlsx_filename(self): def xlsx_filename(self):
return "{username}_dan_score.xlsx".format(username=self.user.username) return f"{self.user.username}_dan_score.xlsx"
class PlayerInvalidScore(PlayerScore): class PlayerInvalidScore(PlayerScore):
template_name = 'mahjong_ranking/player_invalid_score.html' template_name = 'mahjong_ranking/player_invalid_score.html'
def get_queryset(self): def get_queryset(self):
self.xlsx_filename = "{username}_invalid_score.xlsx".format(
username=self.user.username)
return models.Hanchan.objects.unconfirmed(user=self.user) return models.Hanchan.objects.unconfirmed(user=self.user)
@property
def xlsx_filename(self):
return f"{self.user.username}_invalid_score.xlsx"
class PlayerKyuScore(PlayerScore): class PlayerKyuScore(PlayerScore):
template_name = 'mahjong_ranking/player_kyu_score.html' template_name = 'mahjong_ranking/player_kyu_score.html'
@@ -354,7 +366,7 @@ class PlayerKyuScore(PlayerScore):
@property @property
def xlsx_filename(self): def xlsx_filename(self):
return "{username}_kyu_score.xlsx".format(username=self.user.username) return f"{self.user.username}_kyu_score.xlsx"
class PlayerLadderScore(PlayerScore): class PlayerLadderScore(PlayerScore):
@@ -370,7 +382,6 @@ class PlayerLadderScore(PlayerScore):
return context return context
def get_queryset(self, **kwargs): def get_queryset(self, **kwargs):
self.season = int(self.request.GET.get('season', date.today().year))
hanchan_list = models.Hanchan.objects.season_hanchans( hanchan_list = models.Hanchan.objects.season_hanchans(
user=self.user, user=self.user,
season=self.season season=self.season
@@ -408,7 +419,4 @@ class PlayerLadderScore(PlayerScore):
@property @property
def xlsx_filename(self): def xlsx_filename(self):
return "{username}_ladder_score_{season}.xlsx".format( return f"{self.user.username}_ladder_{self.season}_score.xlsx"
username=self.user.username,
season=self.season
)

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: kasu.mahjong_ranking\n" "Project-Id-Version: kasu.mahjong_ranking\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-09 22:00+0200\n" "POT-Creation-Date: 2023-07-26 18:31+0200\n"
"PO-Revision-Date: 2016-09-28 00:24+0200\n" "PO-Revision-Date: 2016-09-28 00:24+0200\n"
"Last-Translator: Christian Berg <xeniac.at@gmail.com>\n" "Last-Translator: Christian Berg <xeniac.at@gmail.com>\n"
"Language-Team: Kasu <verein@kasu.at>\n" "Language-Team: Kasu <verein@kasu.at>\n"
@@ -79,6 +79,30 @@ msgstr "Saison"
msgid "Mai-Star Game with {0} from {1:%Y-%m-%d}" msgid "Mai-Star Game with {0} from {1:%Y-%m-%d}"
msgstr "Mai-Star Spiel mit {0} vom {1:%Y-%m-%d}" msgstr "Mai-Star Spiel mit {0} vom {1:%Y-%m-%d}"
#: templates/maistar_ranking/game_confirm_delete.html:4
#: templates/maistar_ranking/game_confirm_delete.html:9
msgid "Delete game"
msgstr "Spiel löschen"
#: templates/maistar_ranking/game_confirm_delete.html:12
#: templates/maistar_ranking/game_list.html:14
msgid "Place"
msgstr "Platz"
#: templates/maistar_ranking/game_confirm_delete.html:18
#: templates/maistar_ranking/game_list.html:19
#: templates/maistar_ranking/player_game_list.html:36
msgid "Points"
msgstr "Punkte"
#: templates/maistar_ranking/game_confirm_delete.html:23
msgid "Cancel"
msgstr "Abbrechen"
#: templates/maistar_ranking/game_confirm_delete.html:25
msgid "Delete"
msgstr "Löschen"
#: templates/maistar_ranking/game_form.html:5 #: templates/maistar_ranking/game_form.html:5
#: templates/maistar_ranking/game_form.html:16 #: templates/maistar_ranking/game_form.html:16
#: templates/maistar_ranking/game_list.html:27 #: templates/maistar_ranking/game_list.html:27
@@ -113,15 +137,6 @@ msgstr "Gespielte Mai-Star Spiele"
msgid "Game" msgid "Game"
msgstr "Spiel" msgstr "Spiel"
#: templates/maistar_ranking/game_list.html:14
msgid "Place"
msgstr "Platz"
#: templates/maistar_ranking/game_list.html:19
#: templates/maistar_ranking/player_game_list.html:36
msgid "Points"
msgstr "Punkte"
#: templates/maistar_ranking/game_list.html:24 #: templates/maistar_ranking/game_list.html:24
#: templates/maistar_ranking/player_game_list.html:41 #: templates/maistar_ranking/player_game_list.html:41
msgid "Delete Game" msgid "Delete Game"
@@ -135,19 +150,6 @@ msgstr "Für diese Veranstaltung wurden noch keine Mai-Star Spiele erfasst."
msgid "Edit Event" msgid "Edit Event"
msgstr "Veranstaltung bearbeiten" msgstr "Veranstaltung bearbeiten"
#: templates/maistar_ranking/hanchan_confirm_delete.html:4
#: templates/maistar_ranking/hanchan_confirm_delete.html:10
msgid "Delete game"
msgstr "Spiel löschen"
#: templates/maistar_ranking/hanchan_confirm_delete.html:13
msgid "Cancel"
msgstr "Abbrechen"
#: templates/maistar_ranking/hanchan_confirm_delete.html:14
msgid "Delete"
msgstr "Löschen"
#: templates/maistar_ranking/page.html:5 #: templates/maistar_ranking/page.html:5
msgid "Archive" msgid "Archive"
msgstr "Archiv" msgstr "Archiv"

View File

@@ -0,0 +1,30 @@
{% extends "base.html" %}
{% load i18n humanize thumbnail %}
{% block meta_title %}{% trans 'Delete game' %}{% endblock %}
{% block maincontent %}
<form method="post">
{% csrf_token %}
<h2 class="grid_12">{% trans "Delete game" %}</h2>
{% for player in game.player_list %}
<div class="grid_2 center">
<h4>{{ player.placement|ordinal }} {% trans 'Place' %}</h4>
<a class="avatar player"
href="{% url 'maistar-player-games' username=player.user.username season=game.season %}"><img
src="{% thumbnail player.user.avatar|default:'unknown_profile.jpg' 'avatar' %}"
width="70" height="70" alt=""/></a>
<p><a href="{% url 'maistar-player-games' username=player.user.username season=game.season %}">{{player.user.username}}</a><br/>
{{player.score}} {% trans 'Points' %}</p>
</div>
{% endfor %}
{% include 'form.html' %}
<p class="buttonbar grid_12">
<button type="button" onclick="window.history.back()"><span class="fa fa-close"></span>{% trans 'Cancel' %}
</button>
<button type="submit"><span class="fa fa-trash"></span>{% trans 'Delete' %}</button>
</p>
</form>
{% endblock %}
{% block buttonbar %}{% endblock %}

View File

@@ -1,20 +0,0 @@
{% extends "base.html" %}
{% load i18n comments %}
{% block meta_title %}{% trans 'Delete game' %}{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
<fieldset>
<legend>{% trans "Delete game" %}</legend>
{% include 'form.html' %}
<p class="buttonbar">
<button type="button" onclick="window.history.back()"><span class="fa fa-close"></span>{% trans 'Cancel' %}</button>
<button type="submit"><span class="fa fa-trash"></span>{% trans 'Delete' %}</button>
</p>
</fieldset>
</form>
{% endblock %}
{% block buttonbar %}{% endblock %}

View File

@@ -73,7 +73,7 @@
<select id="season" name="season" size="1" onChange="window.location.href = document.season_select.season.options[document.season_select.season.selectedIndex].value;"> <select id="season" name="season" size="1" onChange="window.location.href = document.season_select.season.options[document.season_select.season.selectedIndex].value;">
{% for season_link in season_list%} {% for season_link in season_list%}
<option <option
{% if season == season_link %} selected="selected"{% endif %} selected="selected"
value="{% url 'maistar-ranking' season=season_link %}" >{{ season_link }}</option> value="{% url 'maistar-ranking' season=season_link %}" >{{ season_link }}</option>
{% endfor %} {% endfor %}
</select> </select>

View File

@@ -6,11 +6,11 @@ from . import views
urlpatterns = [ urlpatterns = [
path("", views.ListRankings.as_view()), path("", views.ListRankings.as_view()),
path('event/<int:event>/maistar/', views.ListGames.as_view(), name="maistar-game-list"), path('event/<int:event>/maistar/', views.ListGames.as_view(), name="maistar-game-list"),
path('event/<int:event>/maistar/add/$', views.GameForm.as_view(), name="maistar-add-game"), path('event/<int:event>/maistar/add/', views.GameForm.as_view(), name="maistar-add-game"),
path('maistar/', views.ListRankings.as_view(), name="maistar-ranking"), path('maistar/', views.ListRankings.as_view(), name="maistar-ranking"),
path('maistar/<int:season>/', views.ListRankings.as_view(), name="maistar-ranking"),
path('maistar/<int:game>/edit/', views.GameForm.as_view(), name="maistar-edit-game"), path('maistar/<int:game>/edit/', views.GameForm.as_view(), name="maistar-edit-game"),
path('maistar/<int:game>/delete/', views.DeleteGame.as_view(), name="maistar-delete-game"), path('maistar/<int:game>/delete/', views.DeleteGame.as_view(), name="maistar-delete-game"),
path('maistar/<int:season>/', views.ListRankings.as_view(), name="maistar-ranking"),
path('player/<slug:username>/maistar/', views.ListPlayerGames.as_view(), name="maistar-player-games"), path('player/<slug:username>/maistar/', views.ListPlayerGames.as_view(), name="maistar-player-games"),
path('player/<slug:username>/maistar/<int:season>/', views.ListPlayerGames.as_view(), name="maistar-player-games"), path('player/<slug:username>/maistar/<int:season>/', views.ListPlayerGames.as_view(), name="maistar-player-games"),
] ]

View File

@@ -31,11 +31,11 @@ class GameForm(EventDetailMixin, PermissionRequiredMixin, generic.UpdateView):
class DeleteGame(EventDetailMixin, PermissionRequiredMixin, generic.DeleteView): class DeleteGame(EventDetailMixin, PermissionRequiredMixin, generic.DeleteView):
""" """
Fragt zuerst nach, ob die Hanchan wirklich gelöscht werden soll. Fragt zuerst nach, ob die Hanchan wirklich gelöscht werden soll.
Wir die Frage mit "Ja" beantwortet, wird die die Hanchan gelöscht. Wir die Frage mit "Ja" beantwortet, wird die Hanchan gelöscht.
""" """
model = models.Game model = models.Game
permission_required = 'maistar_ranking.delete_game' permission_required = 'maistar_ranking.delete_game'
pk_url_kwarg = 'hanchan' pk_url_kwarg = 'game'
def get_success_url(self): def get_success_url(self):
return reverse( return reverse(
@@ -46,11 +46,12 @@ class DeleteGame(EventDetailMixin, PermissionRequiredMixin, generic.DeleteView):
class UpdateGame(EventDetailMixin, PermissionRequiredMixin, generic.UpdateView): class UpdateGame(EventDetailMixin, PermissionRequiredMixin, generic.UpdateView):
""" """
Ein Formular um eine neues Spiel anzulegen, bzw. eine bestehendes zu Ein Formular um ein neues Spiel anzulegen, bzw. eine bestehendes zu
bearbeiten. bearbeiten.
""" """
model = models.Game model = models.Game
permission_required = 'maistar_ranking.update_game' permission_required = 'maistar_ranking.update_game'
pk_url_kwarg = 'game'
def get_object(self, queryset=None): # @UnusedVariable def get_object(self, queryset=None): # @UnusedVariable
game = models.Game.objects.get(id=self.kwargs['game']) game = models.Game.objects.get(id=self.kwargs['game'])