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.
# 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
}

View File

@@ -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 <kasu@xendynastie.at>'\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"

View File

@@ -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."""

View File

@@ -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()

View File

@@ -53,10 +53,10 @@
{% block navigation %}
<ul id="navigation">
<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 %}
<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 %}
</ul>
{% endblock %}

View File

@@ -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 action="" method="post" enctype="multipart/form-data">
{{ form.media }} {% csrf_token %}
{{ form.media }} {% csrf_token %}
<fieldset>
<div>
<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>
{% with fieldset_common as form %}{% include "form.html" %}{% endwith %}
</fieldset>
</fieldset>
<ul class="tabs">
<li><a href="#de">{% trans "German" %}</a></li>
<li><a href="#en">{% trans "English" %}</a></li>
</ul>
<ul class="tabs grid_12">
<li><a href="#de">{% trans "German" %}</a></li>
<li><a href="#en">{% trans "English" %}</a></li>
</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 id="de" class="tab_content">
<fieldset>
<legend>Deutsch</legend>
<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>
</fieldset>
{{ form.content_de }}
<div class="tab_container">
<section id="de" class="tab_content">
<fieldset class="grid_12">
<legend>{% trans "German" %}</legend>
{% with fieldset_de as form %}{% include "form.html" %}{% endwith %}
</fieldset>
<br>
{{form.content_de}}
</section>
<section id="en" class="tab_content">
<fieldset class="grid_12">
<legend>{% trans "English" %}</legend>
{% with fieldset_en as form %}{% include "form.html" %}{% endwith %}
</fieldset>
<br>
{{form.content_en}}
</section>
</div>
<div id="en" class="tab_content">
<h3 class="grid_12">English</h3>
<label for="id_{{ form.headline_en.html_name }}" class="grid_2 {{ form.headline_en.css_classes }}">
{{ form.headline_en.label }}</label>
<p class="grid_10">{{ form.headline_en }}</p>
<p>&nbsp;</p>
{{ form.content_en }}
</div>
</div>
<p class="buttonbar">
<button type="reset"><span class="fa fa-undo"></span> {% trans 'reset' %}</button>
<button type="submit"><span class="fa fa-hdd-o"></span> {% trans 'save' %}</button>
</p>
<p class="buttonbar">
<button type="reset"><span class="fa fa-undo"></span> {% trans 'reset' %}</button>
<button type="submit"><span class="fa fa-hdd-o"></span> {% trans 'save' %}</button>
</p>
</form>{% endblock %}
{% block buttonbar %}{% endblock %}

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'")
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
"""