diff --git a/src/content/feeds.py b/src/content/feeds.py index 87a884d..c3df1f6 100644 --- a/src/content/feeds.py +++ b/src/content/feeds.py @@ -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. -# Start ignoring PyLintBear (R0201) +# noinspection PyMethodMayBeStatic class LatestNews(Feed): """ An Feed with the latest news from this site """ - link = "http://www.kasu.at/" description = _("Current news from Kasu") - title = "Kasu - traditonelle asiatische Spielkultur" + link = "http://www.kasu.at/" + title = _("Current news from Kasu") feed_type = Rss201rev2Feed - def items(self): + def items(self) -> object: """get the newest published news articles for the feed.""" return Article.objects.published()[:MAX_ARTICLE_ITEMS] @@ -77,6 +77,4 @@ class LatestComments(Feed): return 'From %(user_name)s in %(content_object)s' % { 'user_name': item.user_name, 'content_object': item.content_object - } - -# Stop ignoring + } \ No newline at end of file diff --git a/src/content/locale/de/LC_MESSAGES/django.po b/src/content/locale/de/LC_MESSAGES/django.po index 1d9b63d..00899f0 100644 --- a/src/content/locale/de/LC_MESSAGES/django.po +++ b/src/content/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: kasu.content\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" "Last-Translator: b'Christian Berg '\n" "Language-Team: Deutsch <>\n" @@ -210,21 +210,23 @@ msgstr "Teile auf" msgid "Edit Article" 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 msgid "German" 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 msgid "English" 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" 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" msgstr "Speichern" diff --git a/src/content/models.py b/src/content/models.py index 9dc09e0..55b5fec 100644 --- a/src/content/models.py +++ b/src/content/models.py @@ -111,6 +111,7 @@ class Article(models.Model): """Returns the headline of this article.""" return self.headline + # noinspection PyUnresolvedReferences @property def get_image(self): """Return the article image, or the category image if unset.""" @@ -169,6 +170,7 @@ class Category(models.Model): return self.name +# noinspection PyUnresolvedReferences class Page(models.Model): """A page on this homepage. It can have a "static" HTML page, the URL of a dynamic Django view, or a PDF document. @@ -317,12 +319,12 @@ class Page(models.Model): raise ValidationError( _(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. - 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 '/' + self.path + CONTENT_TYPE_EXTENSIONS[self.content_type] + :return: string with the absolute URL of this page.""" + return '/' + str(self.path) + CONTENT_TYPE_EXTENSIONS[self.content_type] class Meta(object): """Set default ordering and an unique priamry key to avoid dupes.""" diff --git a/src/content/sitemaps.py b/src/content/sitemaps.py index e1bc67a..b9efa92 100644 --- a/src/content/sitemaps.py +++ b/src/content/sitemaps.py @@ -8,7 +8,7 @@ class ArticleSitemap(GenericSitemap): min_priority = 0.25 @staticmethod - def items(): + def items(**kwargs): """only add published articles to the sitemap""" return Article.objects.published() @@ -18,6 +18,6 @@ class PageSitemap(GenericSitemap): min_priority = 0.5 @staticmethod - def items(): + def items(**kwargs): """add all pages to the sitemap.""" return Page.objects.all() diff --git a/src/content/templates/content/article_archive.html b/src/content/templates/content/article_archive.html index e13aa0e..c395999 100755 --- a/src/content/templates/content/article_archive.html +++ b/src/content/templates/content/article_archive.html @@ -53,10 +53,10 @@ {% block navigation %} {% endblock %} diff --git a/src/content/templates/content/article_form.html b/src/content/templates/content/article_form.html index cc602f5..5067e9b 100755 --- a/src/content/templates/content/article_form.html +++ b/src/content/templates/content/article_form.html @@ -9,56 +9,44 @@ {% endblock %} {% 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.media }} {% csrf_token %} + {{ form.media }} {% csrf_token %} -
-
- - {{ form.category }} - {% if form.category.help_text %}

{{form.category.help_text}}

{% endif %} - {% if form.category.errors %}{{ form.category.errors }}{% endif %} -
-
- - {{ form.image }} - {% if form.image.help_text %}

{{form.image.help_text}}

{% endif %} - {% if form.image.errors %}{{ form.image.errors }}{% endif %} -
+
+ {% with fieldset_common as form %}{% include "form.html" %}{% endwith %} +
-
+ - - -

{{ form.headline_de }}

- -
-
-
- Deutsch - -

{{ form.headline_de }}

-
- {{ form.content_de }} +
+
+
+ {% trans "German" %} + {% with fieldset_de as form %}{% include "form.html" %}{% endwith %} +
+
+ {{form.content_de}} +
+
+
+ {% trans "English" %} + {% with fieldset_en as form %}{% include "form.html" %}{% endwith %} +
+
+ {{form.content_en}} +
-
-

English

- -

{{ form.headline_en }}

-

 

- {{ form.content_en }} -
-
-

- - -

+

+ + +

{% endblock %} {% block buttonbar %}{% endblock %} \ No newline at end of file diff --git a/src/content/templates/content/page_pdf.html b/src/content/templates/content/page_pdf.html deleted file mode 100755 index 03dabe2..0000000 --- a/src/content/templates/content/page_pdf.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -{% block title %}{{page.title}}{% endblock %} - - - - -

{{ page.title }}

- {{ page.content }} - - - - \ No newline at end of file diff --git a/src/content/views.py b/src/content/views.py index 01ac00f..9074ce9 100644 --- a/src/content/views.py +++ b/src/content/views.py @@ -19,7 +19,7 @@ class WYSIWYGEditorMixin(PermissionRequiredMixin): @csp_update(SCRIPT_SRC="'unsafe-eval'") 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. :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 :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') @@ -90,7 +90,7 @@ class ArticleArchiveIndex(ArticleArchiveMixin, generic.ArchiveIndexView): 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) @@ -113,7 +113,7 @@ class ArticleYearArchive(ArticleArchiveMixin, generic.YearArchiveView): 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) @@ -138,6 +138,7 @@ class ArticleDetail(generic.DetailView): """ Render the news Article, but only if it got published. """ + def get_queryset(self): queryset = models.Article.objects.filter(status=models.STATUS_PUBLISHED) queryset = queryset.filter(date_created__year=self.kwargs['year']) @@ -173,7 +174,7 @@ class ArticleForm(WYSIWYGEditorMixin, generic.UpdateView): 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.""" form_class = forms.PageForm @@ -195,7 +196,7 @@ class PageAddForm(WYSIWYGEditorMixin, generic.CreateView): 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 model = models.Page @@ -204,7 +205,7 @@ class PageEditForm(WYSIWYGEditorMixin, generic.UpdateView): def get_object(self, queryset=None): """ 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. :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): """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. - :return: an HTTPResponse with PDF Content or an Http404 exception + :return: an HTTPResponse with PDF Content or a Http404 exception """ try: with open(self.object.pdf_file.path, 'rb') as pdf_file: @@ -285,8 +286,8 @@ class PagePdf(generic.DeleteView): **response_kwargs ) return response - except: - raise Http404('File not Found %s.pdf' % self.kwargs['path']) + except FileExistsError: + raise Http404('File %s.pdf not found' % self.kwargs['path']) class StartPage(generic.TemplateView): @@ -294,7 +295,7 @@ class StartPage(generic.TemplateView): template_name = 'index.html' 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 """ diff --git a/src/events/admin.py b/src/events/admin.py index 03ffc73..7b5a1fe 100644 --- a/src/events/admin.py +++ b/src/events/admin.py @@ -1,6 +1,6 @@ """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.utils.translation import gettext as _ @@ -8,7 +8,7 @@ from events.models import Event, Photo, Location 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 fields = ('name', 'start', 'end') verbose_name_plural = _('Event Series') diff --git a/src/events/context_processors.py b/src/events/context_processors.py index 1fd11c9..0013b45 100644 --- a/src/events/context_processors.py +++ b/src/events/context_processors.py @@ -1,20 +1,20 @@ """ Content processor to display upcoming events on every page you want. """ from django.core.cache import cache +from django.http import HttpRequest 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. For speed reasons everything will be cached for an hour. the following variables will be added to the template context: - * current_event: If an event is running at this moment, the correspondi - event object. + * current_event: If an event is running at this moment, the corresponding event object. * next_event: the next event that is 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 """ current_event = cache.get('current_event', False) diff --git a/src/events/gallery_urls.py b/src/events/gallery_urls.py index bd29e91..557c846 100644 --- a/src/events/gallery_urls.py +++ b/src/events/gallery_urls.py @@ -1,4 +1,3 @@ -""" urls for the event gallery part of the events app. """ from django.urls import path from . import views diff --git a/src/events/locale/de/LC_MESSAGES/django.po b/src/events/locale/de/LC_MESSAGES/django.po index 8418cd4..3761cb9 100644 --- a/src/events/locale/de/LC_MESSAGES/django.po +++ b/src/events/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: kasu.events\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" "Last-Translator: b'Christian Berg '\n" "Language-Team: Kasu \n" @@ -35,7 +35,7 @@ msgstr "Beginn" msgid "end" msgstr "Ende" -#: mixins.py:86 +#: mixins.py:87 msgid "Event does not exist" msgstr "Veranstaltung gibt es nicht" diff --git a/src/events/mixins.py b/src/events/mixins.py index be2d124..ab49bec 100644 --- a/src/events/mixins.py +++ b/src/events/mixins.py @@ -1,4 +1,5 @@ """Mixins for Events.""" +from django.core.exceptions import ImproperlyConfigured from django.db.models import Q from django.http import Http404 from django.shortcuts import get_object_or_404 @@ -32,8 +33,7 @@ class EventDetailMixin(object): event = None def get_context_data(self, **kwargs): - """Add self.event or the related event of self.object to the template - context. + """Add this event or the related event of the given object to the template context. :return: TemplateContext object""" context = super(EventDetailMixin, self).get_context_data(**kwargs) diff --git a/src/events/models.py b/src/events/models.py index c7e691c..9698c61 100644 --- a/src/events/models.py +++ b/src/events/models.py @@ -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 from ckeditor.fields import RichTextField @@ -16,14 +16,15 @@ from utils import COUNTRIES, OverwriteStorage 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. - 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. - @param instance: an Django Object for which the Image has been uploaded. - @type instance: a instace of an models.Model sub-class. + @return: String: path for the image. + @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. @type filename: String """ @@ -48,7 +49,7 @@ def get_upload_path(instance, filename): 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) description = RichTextField(_("Description"), blank=True) location = models.ForeignKey('Location', on_delete=models.PROTECT) @@ -131,7 +132,7 @@ class Event(models.Model): 'year': self.start.strftime('%Y'), 'month': self.start.strftime('%m') } - return reverse('eventseries-form', kwargs=kwargs) + return reverse('event-series-form', kwargs=kwargs) def get_edit_url(self): kwargs = { @@ -167,7 +168,7 @@ class Event(models.Model): self.photo_count = self.photo_set.count() super(Event, self).save(**kwargs) - # Update the Hanchans if necesery: + # Update the Hanchans if necessary: for hanchan in self.hanchan_set.all(): hanchan.save() @@ -267,7 +268,7 @@ class Photo(models.Model): return os.path.basename(self.image.name) 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. if rotate == 'clockwise': pass diff --git a/src/events/sitemaps.py b/src/events/sitemaps.py index e839bb7..deecdf7 100644 --- a/src/events/sitemaps.py +++ b/src/events/sitemaps.py @@ -1,4 +1,3 @@ -"""To geneate a Sitemap with all events.""" from kasu.sitemaps import GenericSitemap from django.utils import timezone from .models import Event @@ -6,11 +5,13 @@ from .models import Event class EventSitemap(GenericSitemap): """sitemap to help indexing all events on this site.""" - changefreq = "never" - protocol = 'https' - priority_field = 'start' + changefreq: str = "never" + protocol: str = 'https' + priority_field: str = 'start' @staticmethod - def items(): - """add all upcoming and archived events to the sitemap.""" + def items(**kwargs) -> Event: + """add all upcoming and archived events to the sitemap. + @param **kwargs: + """ return Event.objects.all() diff --git a/src/events/templates/events/event_archive.html b/src/events/templates/events/event_archive.html index b3897ec..c597a44 100755 --- a/src/events/templates/events/event_archive.html +++ b/src/events/templates/events/event_archive.html @@ -58,7 +58,7 @@
  • {{ comment_count }}
  • {{ event.photo_count }}
  • {{ event.hanchan_set.count }}
  • -
  • {{ event.maistargame_set.count }}
  • +
  • {{ event.maistargame_set.count }}
  • {% if perms.events.change_event %}

    @@ -66,4 +66,5 @@
    {% endfor %} {% endfor %} +{% block form %}{% endblock %} {% endblock %} diff --git a/src/events/templates/events/event_form.html b/src/events/templates/events/event_form.html index 55ff52a..c40df0d 100755 --- a/src/events/templates/events/event_form.html +++ b/src/events/templates/events/event_form.html @@ -10,7 +10,7 @@ {% include "form.html" %} {% if event.id and event.event_set.count %}

    - Achtung! Das ist eine Veranstaltungsreihe! Diese kann man im Moment nur im Admin-Interface vernünfig bearbeiten.
    + Achtung! Das ist eine Veranstaltungsreihe! Diese kann man im Moment nur im Admin-Interface vernünftig bearbeiten.
    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.

    {% endif %} diff --git a/src/events/templates/events/photo_confirm_delete.html b/src/events/templates/events/photo_confirm_delete.html index a162d6a..b8e8703 100755 --- a/src/events/templates/events/photo_confirm_delete.html +++ b/src/events/templates/events/photo_confirm_delete.html @@ -5,7 +5,7 @@
    {% csrf_token %}
    -

    Dieses Photo wirklich löschen?

    +

    Dieses Foto wirklich löschen?

    Sind Sie sicher, dass Sie das Bild “{{photo.name}}” löschen wollen?

    {{photo.name}} diff --git a/src/events/templates/events/photo_detail.html b/src/events/templates/events/photo_detail.html index 792483f..33664f5 100755 --- a/src/events/templates/events/photo_detail.html +++ b/src/events/templates/events/photo_detail.html @@ -59,9 +59,6 @@ if ($('a.next').attr('href')) { Facebook - - Google+ - Twitter diff --git a/src/events/templates/events/photo_upload.html b/src/events/templates/events/photo_upload.html index 0db68d4..3040a08 100755 --- a/src/events/templates/events/photo_upload.html +++ b/src/events/templates/events/photo_upload.html @@ -1,46 +1,10 @@ -{% extends "base.html" %} +{% extends "events/event_archive.html" %} {% load i18n comments thumbnail %} -{% block maincontent %} - {% for event in event_list %} - {% get_comment_count for event as comment_count %} - {% ifchanged %}

    {{ event.start|date:'F Y' }}

    {% endifchanged %} -
    - -
    -

    {{ event.name }}

    -
    - -{{ 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 %} -
    -{% if event.description %}

    {{event.description}}

    {% endif %} - -

    - {% if perms.events.add_photo %} - - - {%trans "Upload" %} - {% endif %} -

    -
    -{% endfor %} - +{% block bottom %} {% csrf_token %} -
    +
    Photos hochladen {% include "form.html" %}

    @@ -52,5 +16,5 @@

    {% endblock %} - - +{% block buttonbar %} +{% endblock %} diff --git a/src/events/tests.py b/src/events/tests.py index 3569882..61027f9 100644 --- a/src/events/tests.py +++ b/src/events/tests.py @@ -1,20 +1,19 @@ """ This file should test the functionality of the events app using the unittest module. These will pass when you run "manage.py test". - -Usefull tests have to been written yet. sorry! +useful tests have to be written yet. sorry! """ from django.test import 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): - """ Here we should test the creation and modifiaction of Locations. """ + """ Here we should test the creation and modification of Locations. """ class PhotoTest(TestCase): - """ Here we should test the creation and modifiaction of Photos. """ + """ Here we should test the creation and modification of Photos. """ diff --git a/src/events/urls.py b/src/events/urls.py index 88e9468..182a1d3 100644 --- a/src/events/urls.py +++ b/src/events/urls.py @@ -8,7 +8,7 @@ urlpatterns = [ path('/', views.EventArchiveYear.as_view(), name='event-archive'), path('//', views.EventArchiveMonth.as_view(), name='event-archive'), path('///', views.EventDetail.as_view(), name='event-detail'), - path('///add_dates/', views.EventSeriesForm.as_view(), name='eventseries-form'), + path('///add_dates/', views.EventSeriesForm.as_view(), name='event-series-form'), path('///edit/', 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'), diff --git a/src/events/views.py b/src/events/views.py index d9cfbcf..dd4a6a3 100644 --- a/src/events/views.py +++ b/src/events/views.py @@ -50,19 +50,15 @@ class EventDetail(mixins.EventDetailMixin, generic.DetailView): class EventForm(PermissionRequiredMixin, mixins.EventDetailMixin, generic.UpdateView): - """Frontend formular to add or edit a Event.""" + """Frontend formular to add or edit an Event.""" form_class = forms.EventForm template_name = 'events/event_form.html' permission_required = 'events.add_event' def get_context_data(self, **kwargs): - """Dynamicle set the title to Add or Edit Event, depanding if an - event ID was given, or not.""" + """set the title to add or edit Event, depending on the fact if an event ID was given.""" context = super(EventForm, self).get_context_data(**kwargs) - if self.kwargs.get('pk'): - context['title'] = _("Edit Event") - else: - context['title'] = _("Add Event") + context['title'] = _("Edit Event") if self.kwargs.get('pk') else _("Add Event") return context def get_object(self, queryset=None): @@ -74,7 +70,7 @@ class EventForm(PermissionRequiredMixin, mixins.EventDetailMixin, 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' paginate_by = 24 @@ -89,7 +85,7 @@ class EventGallery(generic.ListView): 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): """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): - """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' event = None paginate_by = 36 diff --git a/src/kasu/locale/de/LC_MESSAGES/django.po b/src/kasu/locale/de/LC_MESSAGES/django.po index 29eb629..e817ddd 100644 --- a/src/kasu/locale/de/LC_MESSAGES/django.po +++ b/src/kasu/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: kasu.utils\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" "Last-Translator: b' '\n" "Language-Team: Kasu \n" @@ -215,11 +215,11 @@ msgstr "Besuche uns auf" msgid "Add Article" msgstr "Artikel hinzufügen" -#: templates/paginator.html:8 +#: templates/paginator.html:7 msgid "Previous" msgstr "Vorherige" -#: templates/paginator.html:20 +#: templates/paginator.html:18 msgid "Next" msgstr "Nächste" diff --git a/src/kasu/templates/base.html b/src/kasu/templates/base.html index bd8dc00..fce2402 100644 --- a/src/kasu/templates/base.html +++ b/src/kasu/templates/base.html @@ -37,7 +37,7 @@ {% block extra_head %}{% endblock %} - +
    {{comment.user}} -
    +
    {{comment}}
    diff --git a/src/kasu/templates/django/forms/widgets/html5input.html b/src/kasu/templates/django/forms/widgets/html5input.html index f23b0ad..8980709 100644 --- a/src/kasu/templates/django/forms/widgets/html5input.html +++ b/src/kasu/templates/django/forms/widgets/html5input.html @@ -1 +1,2 @@ - + diff --git a/src/kasu/templates/form.html b/src/kasu/templates/form.html index b3a070d..d9e3135 100644 --- a/src/kasu/templates/form.html +++ b/src/kasu/templates/form.html @@ -2,7 +2,7 @@ {% for hidden in form.hidden_fields %}{{ hidden }}{% endfor %} {% for field in form.visible_fields %}
    - {{ field }} {% if field.field.widget.input_type == 'checkbox' %} diff --git a/src/kasu/templates/paginator.html b/src/kasu/templates/paginator.html index 72c6aa2..e4b3ba0 100644 --- a/src/kasu/templates/paginator.html +++ b/src/kasu/templates/paginator.html @@ -1,22 +1,22 @@ {% load i18n %} \ No newline at end of file diff --git a/src/kasu/urls.py b/src/kasu/urls.py index d8ff86f..37b4a5a 100644 --- a/src/kasu/urls.py +++ b/src/kasu/urls.py @@ -20,7 +20,7 @@ admin.autodiscover() sitemaps = { 'event_rankings': EventRankingSitemap, 'event_hanchans': EventHanchanSitemap, - 'mahjong_seasons': MajongSeasonSitemap, + 'mahjong_seasons': MahjongSeasonSitemap, 'maistar_games': MaistarGamesSitemap, 'articles': ArticleSitemap, 'events': EventSitemap, diff --git a/src/mahjong_ranking/admin.py b/src/mahjong_ranking/admin.py index 45035a5..116e0af 100644 --- a/src/mahjong_ranking/admin.py +++ b/src/mahjong_ranking/admin.py @@ -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.utils.translation import gettext as _ @@ -36,14 +36,14 @@ def confirm(modeladmin, request, queryset): # Ignore PyLintBear (W0613) 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. """ for hanchan in queryset: hanchan.confirmed = False hanchan.save() -unconfirm.short_description = _('Set unconfirmed') +reject.short_description = _('Reject') class EventRankingAdmin(admin.ModelAdmin): @@ -57,7 +57,7 @@ class EventRankingAdmin(admin.ModelAdmin): class HanchanAdmin(admin.ModelAdmin): """ To administrate the stored Hanchans. """ - actions = [recalculate, confirm, unconfirm] + actions = [recalculate, confirm, reject] date_hierarchy = 'start' list_filter = ('season', 'event', 'confirmed') search_fields = ('player_names',) diff --git a/src/mahjong_ranking/forms.py b/src/mahjong_ranking/forms.py index ab2c243..6c2658b 100644 --- a/src/mahjong_ranking/forms.py +++ b/src/mahjong_ranking/forms.py @@ -64,7 +64,7 @@ class HanchanAdminForm(HanchanForm): """ Extends the HanchanForm for users with admin privileges. 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): """ Extend the formfields to add the confirmed checkbox. """ diff --git a/src/mahjong_ranking/locale/de/LC_MESSAGES/django.po b/src/mahjong_ranking/locale/de/LC_MESSAGES/django.po index 1e48a75..e1d0968 100644 --- a/src/mahjong_ranking/locale/de/LC_MESSAGES/django.po +++ b/src/mahjong_ranking/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: kasu.mahjong_ranking\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" "Last-Translator: b'Christian Berg '\n" "Language-Team: Kasu \n" diff --git a/src/mahjong_ranking/management/commands/exportranking.py b/src/mahjong_ranking/management/commands/exportranking.py index b6e3dbd..7c2b4b4 100644 --- a/src/mahjong_ranking/management/commands/exportranking.py +++ b/src/mahjong_ranking/management/commands/exportranking.py @@ -1,4 +1,4 @@ -"""Export Mahjong Rankings as excel files.""" +"""Export Mahjong Rankings as Excel files.""" import os from datetime import date, time, datetime diff --git a/src/mahjong_ranking/managers.py b/src/mahjong_ranking/managers.py index c343b80..0728ac7 100644 --- a/src/mahjong_ranking/managers.py +++ b/src/mahjong_ranking/managers.py @@ -74,12 +74,13 @@ class HanchanManager(models.Manager): [hanchan.get_playerdata(user) for hanchan in 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. :param user: Only return Hanchans where this user participated. - :param season: the year of the wanted season, current year if None. - :return: QuerySet Object + :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 """ try: season = season or until.year @@ -92,6 +93,7 @@ class HanchanManager(models.Manager): :param user: Return Hanchans where this user participated. :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. :return: a QuerySet Object """ @@ -199,10 +201,8 @@ class SeasonRankingManager(models.Manager): class KyuDanRankingManager(models.Manager): def json_data(self): """ Get all Rankings for a given Season and return them as a list of - dict objects, suitable for JSON exports and other processings. - - :param season: Season that should be exported, current season if empty - :return: a list() of dict() objects suiteable for JSON export. + dict objects, suitable for JSON exports and other processing. + :return: a list() of dict() objects suitable for JSON export. """ json_data = list() values = self.all() diff --git a/src/mahjong_ranking/models.py b/src/mahjong_ranking/models.py index 22b976d..82ca9dc 100644 --- a/src/mahjong_ranking/models.py +++ b/src/mahjong_ranking/models.py @@ -48,11 +48,11 @@ class EventRanking(models.Model): 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 - sie zwischen zu speichern. + sie zwischenzuspeichern. """ LOGGER.info( u'Recalculate EventRanking for Player %s in %s', @@ -291,9 +291,8 @@ class Hanchan(models.Model): self.bonus_points = getattr(self, '%s_bonus_points' % player) self.player_comment = getattr(self, '%s_comment' % player) - def update_playerdata(self, user, **kwargs): - """i small workaround to access score, placement of a specific user - prominent from a in the user templates""" + def update_player_data(self, user, **kwargs): + """to access scores and placement of a specific user from templates""" for player in ('player1', 'player2', 'player3', 'player4'): if getattr(self, player) == user: setattr(self, '%s_input_score' % player, self.input_score) @@ -423,7 +422,7 @@ class KyuDanRanking(models.Model): 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 gewonnen hat. :param hanchan: Ein Player Objekt @@ -525,7 +524,7 @@ class KyuDanRanking(models.Model): self.append_tournament_bonuspoints(hanchan) self.update_rank() self.append_3_in_a_row_bonuspoints(hanchan) - hanchan.update_playerdata(self.user) + hanchan.update_player_data(self.user) hanchan.save(recalculate=False) self.won_hanchans += 1 if hanchan.placement == 1 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. :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.dan_points = None diff --git a/src/mahjong_ranking/sitemaps.py b/src/mahjong_ranking/sitemaps.py index ccd216d..510e70a 100644 --- a/src/mahjong_ranking/sitemaps.py +++ b/src/mahjong_ranking/sitemaps.py @@ -11,38 +11,42 @@ from .models import SeasonRanking class EventRankingSitemap(GenericSitemap): @staticmethod - def items(): - """add all upcoming and archived events to the sitemap.""" + def items(**kwargs): + """add all upcoming and archived events to the sitemap. + @param **kwargs: + """ return Event.objects.all().exclude(eventranking=None) @staticmethod - def location(event): + def location(event, **kwargs): return reverse('event-ranking', kwargs={'event': event.id}) class EventHanchanSitemap(GenericSitemap): @staticmethod - def items(): - """add all upcoming and archived events to the sitemap.""" + def items(**kwargs): + """add all upcoming and archived events to the sitemap. + @param **kwargs: + """ return Event.objects.all().exclude(eventranking=None) @staticmethod - def location(event): + def location(event, **kwargs): return reverse('event-hanchan-list', kwargs={'event': event.id}) -class MajongSeasonSitemap(Sitemap): +class MahjongSeasonSitemap(Sitemap): priority = 0.5 @staticmethod - def items(): + def items(**kwargs): seasons = SeasonRanking.objects.all().distinct('season').order_by( 'season') seasons = seasons.values_list('season', flat=True) return seasons @staticmethod - def location(season): + def location(season, **kwargs): return reverse('mahjong-ladder', kwargs={'season': season}) @staticmethod diff --git a/src/mahjong_ranking/templates/mahjong_ranking/eventhanchan_form.html b/src/mahjong_ranking/templates/mahjong_ranking/eventhanchan_form.html index 1ae7d4f..c71fee7 100755 --- a/src/mahjong_ranking/templates/mahjong_ranking/eventhanchan_form.html +++ b/src/mahjong_ranking/templates/mahjong_ranking/eventhanchan_form.html @@ -18,7 +18,7 @@
    {% for hidden in form.hidden_fields %} {{ hidden }} {% endfor %}

    - + {{ form.start }} {{ form.start.errors }}

    diff --git a/src/mahjong_ranking/templates/mahjong_ranking/hanchan_confirm_delete.html b/src/mahjong_ranking/templates/mahjong_ranking/hanchan_confirm_delete.html index a66d0f2..6e3c3b5 100755 --- a/src/mahjong_ranking/templates/mahjong_ranking/hanchan_confirm_delete.html +++ b/src/mahjong_ranking/templates/mahjong_ranking/hanchan_confirm_delete.html @@ -33,7 +33,7 @@ {% trans "Delete Hanchan" %} {% include 'form.html' %} -

    Bist du sicher dass du diese Hanchan und alle Ergebnisse und Wertungen welche sich hierauf beziehen löschen möchtest?

    +

    Bist du sicher, dass du diese Hanchan und alle Ergebnisse und Wertungen, welche sich hierauf beziehen löschen möchtest?


    diff --git a/src/mahjong_ranking/templates/mahjong_ranking/ladder_redbox.html b/src/mahjong_ranking/templates/mahjong_ranking/ladder_redbox.html index 2d00b8b..8fe8a09 100755 --- a/src/mahjong_ranking/templates/mahjong_ranking/ladder_redbox.html +++ b/src/mahjong_ranking/templates/mahjong_ranking/ladder_redbox.html @@ -31,7 +31,7 @@ {% for season_link in season_list%} {% endfor %} diff --git a/src/mahjong_ranking/templates/mahjong_ranking/player_dan_score.html b/src/mahjong_ranking/templates/mahjong_ranking/player_dan_score.html index 82aba0f..4a0dfda 100755 --- a/src/mahjong_ranking/templates/mahjong_ranking/player_dan_score.html +++ b/src/mahjong_ranking/templates/mahjong_ranking/player_dan_score.html @@ -52,7 +52,7 @@ {% if kyu_dan_ranking.legacy_date %} -

    Frühere Dan Punkte vom {{ kyu_dan_ranking.legacy_date|date }}: {{kyu_dan_ranking.legacy_dan_points }}

    +

    Frühere Dan Punkte vom {{kyu_dan_ranking.legacy_date|date}}: {{kyu_dan_ranking.legacy_dan_points}}

    {% endif %} {% endblock %} diff --git a/src/mahjong_ranking/templates/mahjong_ranking/player_ladder_score.html b/src/mahjong_ranking/templates/mahjong_ranking/player_ladder_score.html index 5ee1651..27e637b 100755 --- a/src/mahjong_ranking/templates/mahjong_ranking/player_ladder_score.html +++ b/src/mahjong_ranking/templates/mahjong_ranking/player_ladder_score.html @@ -64,8 +64,8 @@ @@ -75,5 +75,5 @@ {% endblock %} {% block buttonbar %} - Download -{% endblock %} + Download +{% endblock %} \ No newline at end of file diff --git a/src/mahjong_ranking/templates/mahjong_ranking/seasonranking_list.html b/src/mahjong_ranking/templates/mahjong_ranking/seasonranking_list.html index 657eb86..e2f1fbb 100755 --- a/src/mahjong_ranking/templates/mahjong_ranking/seasonranking_list.html +++ b/src/mahjong_ranking/templates/mahjong_ranking/seasonranking_list.html @@ -50,7 +50,7 @@ {% empty %} 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. {% endfor %} diff --git a/src/mahjong_ranking/views.py b/src/mahjong_ranking/views.py index 073036b..b5da33b 100644 --- a/src/mahjong_ranking/views.py +++ b/src/mahjong_ranking/views.py @@ -45,7 +45,7 @@ def get_kyu_dan_ranking(user=None): class DeleteHanchan(EventDetailMixin, PermissionRequiredMixin, 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 model = models.Hanchan permission_required = 'mahjong_ranking.delete_hanchan' @@ -53,7 +53,7 @@ class DeleteHanchan(EventDetailMixin, PermissionRequiredMixin, 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 reverse('event-hanchan-list', @@ -71,7 +71,7 @@ class HanchanForm(SuccessMessageMixin, EventDetailMixin, 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.HanchanAdminForm if self.request.user.has_perm( @@ -123,27 +123,27 @@ class HanchanForm(SuccessMessageMixin, EventDetailMixin, class EventHanchanForm(EventDetailMixin, PermissionRequiredMixin, generic.TemplateView): """Display a Formset to add and Edit Hanchans of the specific Event.""" + formset: forms.HanchanFormset permission_required = 'mahjong_ranking.add_hanchan' template_name = 'mahjong_ranking/eventhanchan_form.html' model = models.Hanchan def get_context_data(self, **kwargs): 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['formset'] = self.formset return context def get(self, request, *args, **kwargs): self.get_queryset() - self.formset = forms.HanchanFormset( - instance=self.event, - initial=[{'start': self.event.start}] - ) context = self.get_context_data(**kwargs) return self.render_to_response(context) def post(self, request, *args, **kwargs): - print("ICH WURDE GEPOSTET!!!!") self.get_queryset() self.formset = forms.HanchanFormset( self.request.POST, @@ -172,9 +172,9 @@ class EventRankingList(EventDetailMixin, 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 - paginate_by = 25 + paginate_by = 100 def dispatch(self, request, *args, **kwargs): """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): model = models.SeasonRanking - paginate_by = 25 + paginate_by = 100 season = None def get_queryset(self): @@ -205,18 +205,23 @@ class SeasonRankingList(MahjongMixin, generic.ListView): class PlayerScore(LoginRequiredMixin, generic.ListView): - paginate_by = 25 + paginate_by: int = 100 user = auth.get_user_model() + kyu_dan_ranking = None + season = None def get(self, request, *args, **kwargs): user_model = auth.get_user_model() try: self.user = user_model.objects.get( 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: raise django.http.Http404( _("No user found matching the name {}").format( self.kwargs.get('username'))) + if request.GET.get('download') == 'xlsx': return self.get_xlsx(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( user=self.user) except models.KyuDanRanking.DoesNotExist: - context['ranking'] = None + context['kyu_dan_ranking'] = None try: context['ladder_ranking'] = models.SeasonRanking.objects.get( user=self.user, @@ -238,27 +243,31 @@ class PlayerScore(LoginRequiredMixin, generic.ListView): return context def get_xlsx(self, request, *args, **kwargs): - self.object_list = self.get_queryset() response = django.http.HttpResponse( content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') - response['Content-Disposition'] = 'attachment; ' \ - 'filename="{xlsx_filename}"'.format( - xlsx_filename=self.xlsx_filename) - xlxs_workbook = xlsx.Workbook() - xlxs_workbook.generate_sheet( + response['Content-Disposition'] = f'attachment; filename="{self.xlsx_filename}"' + xlsx_workbook = xlsx.Workbook() + xlsx_workbook.generate_sheet( title=self.xlsx_filename.split('.')[0], 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 + @property + def xlsx_columns(self): + return {} + + @property + def xlsx_filename(self): + return "" + class PlayerDanScore(PlayerScore): template_name = 'mahjong_ranking/player_dan_score.html' def get_queryset(self): - self.kyu_dan_ranking = get_kyu_dan_ranking(user=self.user) return models.Hanchan.objects.dan_hanchans( user=self.user, since=self.kyu_dan_ranking.legacy_date) @@ -298,17 +307,20 @@ class PlayerDanScore(PlayerScore): @property 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): template_name = 'mahjong_ranking/player_invalid_score.html' + def get_queryset(self): - self.xlsx_filename = "{username}_invalid_score.xlsx".format( - username=self.user.username) return models.Hanchan.objects.unconfirmed(user=self.user) + @property + def xlsx_filename(self): + return f"{self.user.username}_invalid_score.xlsx" + class PlayerKyuScore(PlayerScore): template_name = 'mahjong_ranking/player_kyu_score.html' @@ -354,7 +366,7 @@ class PlayerKyuScore(PlayerScore): @property 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): @@ -370,7 +382,6 @@ class PlayerLadderScore(PlayerScore): return context def get_queryset(self, **kwargs): - self.season = int(self.request.GET.get('season', date.today().year)) hanchan_list = models.Hanchan.objects.season_hanchans( user=self.user, season=self.season @@ -408,7 +419,4 @@ class PlayerLadderScore(PlayerScore): @property def xlsx_filename(self): - return "{username}_ladder_score_{season}.xlsx".format( - username=self.user.username, - season=self.season - ) + return f"{self.user.username}_ladder_{self.season}_score.xlsx" \ No newline at end of file diff --git a/src/maistar_ranking/locale/de/LC_MESSAGES/django.po b/src/maistar_ranking/locale/de/LC_MESSAGES/django.po index 788b070..3df2a82 100644 --- a/src/maistar_ranking/locale/de/LC_MESSAGES/django.po +++ b/src/maistar_ranking/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: kasu.mahjong_ranking\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" "Last-Translator: Christian Berg \n" "Language-Team: Kasu \n" @@ -79,6 +79,30 @@ msgstr "Saison" msgid "Mai-Star Game with {0} from {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:16 #: templates/maistar_ranking/game_list.html:27 @@ -113,15 +137,6 @@ msgstr "Gespielte Mai-Star Spiele" msgid "Game" 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/player_game_list.html:41 msgid "Delete Game" @@ -135,19 +150,6 @@ msgstr "Für diese Veranstaltung wurden noch keine Mai-Star Spiele erfasst." msgid "Edit Event" 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 msgid "Archive" msgstr "Archiv" diff --git a/src/maistar_ranking/templates/maistar_ranking/game_confirm_delete.html b/src/maistar_ranking/templates/maistar_ranking/game_confirm_delete.html new file mode 100755 index 0000000..d779e37 --- /dev/null +++ b/src/maistar_ranking/templates/maistar_ranking/game_confirm_delete.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} +{% load i18n humanize thumbnail %} + +{% block meta_title %}{% trans 'Delete game' %}{% endblock %} + +{% block maincontent %} +
    + {% csrf_token %} +

    {% trans "Delete game" %}

    + {% for player in game.player_list %} +
    +

    {{ player.placement|ordinal }} {% trans 'Place' %}

    + +

    {{player.user.username}}
    + {{player.score}} {% trans 'Points' %}

    +
    + {% endfor %} + {% include 'form.html' %} +

    + + +

    +
    +{% endblock %} + +{% block buttonbar %}{% endblock %} \ No newline at end of file diff --git a/src/maistar_ranking/templates/maistar_ranking/hanchan_confirm_delete.html b/src/maistar_ranking/templates/maistar_ranking/hanchan_confirm_delete.html deleted file mode 100755 index 697952b..0000000 --- a/src/maistar_ranking/templates/maistar_ranking/hanchan_confirm_delete.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "base.html" %} -{% load i18n comments %} - -{% block meta_title %}{% trans 'Delete game' %}{% endblock %} - -{% block content %} -
    -{% csrf_token %} -
    -{% trans "Delete game" %} -{% include 'form.html' %} -

    - - -

    -
    -
    -{% endblock %} - -{% block buttonbar %}{% endblock %} \ No newline at end of file diff --git a/src/maistar_ranking/templates/maistar_ranking/ranking_list.html b/src/maistar_ranking/templates/maistar_ranking/ranking_list.html index 848f172..58a1214 100755 --- a/src/maistar_ranking/templates/maistar_ranking/ranking_list.html +++ b/src/maistar_ranking/templates/maistar_ranking/ranking_list.html @@ -73,8 +73,8 @@ diff --git a/src/maistar_ranking/urls.py b/src/maistar_ranking/urls.py index 758e3da..d447129 100644 --- a/src/maistar_ranking/urls.py +++ b/src/maistar_ranking/urls.py @@ -6,11 +6,11 @@ from . import views urlpatterns = [ path("", views.ListRankings.as_view()), path('event//maistar/', views.ListGames.as_view(), name="maistar-game-list"), - path('event//maistar/add/$', views.GameForm.as_view(), name="maistar-add-game"), + path('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//edit/', views.GameForm.as_view(), name="maistar-edit-game"), path('maistar//delete/', views.DeleteGame.as_view(), name="maistar-delete-game"), - path('maistar//', views.ListRankings.as_view(), name="maistar-ranking"), path('player//maistar/', views.ListPlayerGames.as_view(), name="maistar-player-games"), path('player//maistar//', views.ListPlayerGames.as_view(), name="maistar-player-games"), ] diff --git a/src/maistar_ranking/views.py b/src/maistar_ranking/views.py index 115c1a9..4e82124 100644 --- a/src/maistar_ranking/views.py +++ b/src/maistar_ranking/views.py @@ -31,11 +31,11 @@ class GameForm(EventDetailMixin, PermissionRequiredMixin, generic.UpdateView): class DeleteGame(EventDetailMixin, PermissionRequiredMixin, generic.DeleteView): """ 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 permission_required = 'maistar_ranking.delete_game' - pk_url_kwarg = 'hanchan' + pk_url_kwarg = 'game' def get_success_url(self): return reverse( @@ -46,11 +46,12 @@ class DeleteGame(EventDetailMixin, PermissionRequiredMixin, generic.DeleteView): 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. """ model = models.Game permission_required = 'maistar_ranking.update_game' + pk_url_kwarg = 'game' def get_object(self, queryset=None): # @UnusedVariable game = models.Game.objects.get(id=self.kwargs['game'])