delete unused imports and _-translation

This commit is contained in:
2022-10-21 08:10:56 +00:00
parent 6d72c7a2d3
commit 77d6536c61
24 changed files with 114 additions and 170 deletions

View File

@@ -1,5 +1,6 @@
import ldap3
import logging
import ldap3
from ldap3.core.exceptions import LDAPBindError
logger = logging.getLogger(__name__)

View File

@@ -1,5 +1,4 @@
from django import forms
from django.utils.translation import gettext_lazy as _
from .models import JobPosting
@@ -17,16 +16,14 @@ class JobPostingForm(forms.ModelForm):
]
labels = {
"company_name": _("Firmenname"),
"job_name": _("Berufsbezeichnung"),
"salary": _("monatliches Gehalt (brutto)/Stundenlohn"),
"pdf_location": _("Stellenausschreibung"),
"publish_date": _("Veröffentlichung"),
"company_name": "Firmenname",
"job_name": "Berufsbezeichnung",
"salary": "monatliches Gehalt (brutto)/Stundenlohn",
"pdf_location": "Stellenausschreibung",
"publish_date": "Veröffentlichung",
}
help_texts = {
"pdf_location": _("Verwendbares Format: PDF."),
"salary": _(
"in Euro angeben; monatliches Gehalt bei >1h, sonst Stundenlohn."
),
"pdf_location": "Verwendbares Format: PDF.",
"salary": "in Euro angeben; monatliches Gehalt bei >1h, sonst Stundenlohn.",
}

View File

@@ -1,14 +1,9 @@
import locale
import logging
import os
from os.path import splitext, basename
from django.conf import settings
from django.core.validators import ValidationError, FileExtensionValidator
from django.core.validators import FileExtensionValidator
from django.db import models
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
logger = logging.getLogger("blackboard")

View File

@@ -1,15 +1,14 @@
from ckeditor_uploader.widgets import CKEditorUploadingWidget
from django import forms
from django.utils.translation import gettext_lazy as _
from .models import CustomFlatPage
class FlatPageForm(forms.ModelForm):
__choices = [
("flatpages/default.html", _("default.html")),
("flatpages/social_media.html", _("social_media.html")),
("flatpages/default.html", "default.html"),
("flatpages/social_media.html", "social_media.html"),
]
template_name = forms.ChoiceField(choices=__choices)

View File

@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

View File

@@ -1,6 +1,5 @@
from ckeditor_uploader.widgets import CKEditorUploadingWidget
from django import forms
from django.utils.translation import gettext_lazy as _
from .models import Album
@@ -13,13 +12,11 @@ class AlbumAdminForm(forms.ModelForm):
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
labels = {
"slug": _("Permalink"),
"description": _("Beschreibung"),
"slug": "Permalink",
"description": "Beschreibung",
}
help_texts = {
"folder_name": _("Füge den Ordnername (ohne Pfade) ein."),
"thumbnail": _(
"Füge den vollständigen Dateiname (ohne Pfade) ein, wenn dieser als Thumbnail verwendet werden soll."
),
"folder_name": "Füge den Ordnername (ohne Pfade) ein.",
"thumbnail": "Füge den vollständigen Dateiname (ohne Pfade) ein, wenn dieser als Thumbnail verwendet werden soll.",
}

View File

@@ -3,7 +3,6 @@ from django.db import models
from django.urls import reverse
from django.utils import timezone
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from .utils import get_image_list
@@ -39,8 +38,8 @@ class Album(models.Model):
objects = models.Manager()
class Meta:
verbose_name = _("Album")
verbose_name_plural = _("Alben")
verbose_name = "Album"
verbose_name_plural = "Alben"
def __str__(self):
return self.title

View File

@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -1,4 +1,3 @@
import os
from collections import deque
from random import randint

View File

@@ -3,7 +3,6 @@ from ckeditor_uploader.widgets import CKEditorUploadingWidget
from django import forms
from django.forms.widgets import HiddenInput
from django.utils.translation import gettext_lazy as _
from tasks.models import Task, TaskList
from .models import TopicGroup, Topic, Attachment, Etherpad, FileUpload
@@ -19,10 +18,10 @@ class TopicGroupAdminForm(forms.ModelForm):
fields = "__all__"
labels = {
"title": _("Titel"),
"shortterm": _("Kürzel für Link"),
"slug": _("Permalink"),
"short_description": _("Kurzbeschreibung"),
"title": "Titel",
"shortterm": "Kürzel für Link",
"slug": "Permalink",
"short_description": "Kurzbeschreibung",
}
@@ -32,10 +31,10 @@ class TopicAdminForm(forms.ModelForm):
fields = "__all__"
labels = {
"title": _("Titel"),
"slug": _("Permalink"),
"task_list": _("Aufgabenbereich"),
"description": _("Beschreibung"),
"title": "Titel",
"slug": "Permalink",
"task_list": "Aufgabenbereich",
"description": "Beschreibung",
}
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
@@ -47,10 +46,10 @@ class AttachmentAdminForm(forms.ModelForm):
fields = "__all__"
labels = {
"title": _("Titel"),
"slug": _("Permalink"),
"topic": _("Thema"),
"description": _("Beschreibung"),
"title": "Titel",
"slug": "Permalink",
"topic": "Thema",
"description": "Beschreibung",
}
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
@@ -66,8 +65,8 @@ class EtherpadAdminForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"attachment": _("Anhang Ordner"),
"title": "Titel",
"attachment": "Anhang Ordner",
}
@@ -81,8 +80,8 @@ class FileUploadAdminForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"attachment": _("Anhang Ordner"),
"title": "Titel",
"attachment": "Anhang Ordner",
}
@@ -94,7 +93,7 @@ class TopicInlineForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"title": "Titel",
}
@@ -106,7 +105,7 @@ class AttachmentInlineForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"title": "Titel",
}
@@ -120,8 +119,8 @@ class EtherpadInlineForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"date": _("Datum"),
"title": "Titel",
"date": "Datum",
}
@@ -134,7 +133,7 @@ class FileUploadInlineForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"title": "Titel",
}
@@ -148,8 +147,8 @@ class TopicCreateForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"description": _("Beschreibung"),
"title": "Titel",
"description": "Beschreibung",
}
widgets = {
@@ -168,8 +167,8 @@ class TopicUpdateForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"description": _("Beschreibung"),
"title": "Titel",
"description": "Beschreibung",
}
widgets = {
@@ -189,8 +188,8 @@ class AttachmentCreateForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"description": _("Beschreibung"),
"title": "Titel",
"description": "Beschreibung",
}
widgets = {
@@ -210,8 +209,8 @@ class AttachmentUpdateForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"description": _("Beschreibung"),
"title": "Titel",
"description": "Beschreibung",
}
widgets = {
@@ -231,8 +230,8 @@ class EtherpadForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"date": _("Datum"),
"title": "Titel",
"date": "Datum",
}
widgets = {

View File

@@ -8,7 +8,6 @@ from django.db.models.constraints import UniqueConstraint
from django.urls import reverse
from django.utils import timezone
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from documents import create_pad, get_pad_html
from documents.api import get_pad_link

View File

@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -1,17 +1,14 @@
import logging
from collections import deque
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db.models import F, Q
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from django.urls import reverse_lazy, reverse
from authentications.decorators import authenticated_user
from documents.api import get_pad_link
from documents.etherpadlib import add_ep_cookie
from fet2020.utils import add_log_action
from tasks.forms import InternTaskCreateForm

View File

@@ -1,18 +1,17 @@
from django.contrib import admin
from django.utils.translation import gettext as _
from .forms import JobForm, JobGroupForm, JobInlineForm, MemberForm
from .models import Job, JobGroup, JobMember, Member
class MemberRoleFilter(admin.SimpleListFilter):
title = _("Rolle")
title = "Rolle"
parameter_name = "role"
def lookups(self, request, model_admin):
return (
("A", _("Aktiv")),
("P", _("Pension")),
("A", "Aktiv"),
("P", "Pension"),
)
def queryset(self, request, queryset):

View File

@@ -1,7 +1,6 @@
from ckeditor_uploader.widgets import CKEditorUploadingWidget
from django import forms
from django.utils.translation import gettext_lazy as _
from .models import Member, Job, JobGroup
@@ -18,19 +17,16 @@ class MemberForm(forms.ModelForm):
model = Member
help_texts = {
"image": _(
"Mindestdimension: 150*150 px, maximale Größe: 10MB, "
"erlaubtes Format: Bildformate."
),
"mailaccount": _("Die Mailadresse mit '@fet.at' angeben."),
"image": "Mindestdimension: 150*150 px, maximale Größe: 10MB, erlaubtes Format: Bildformate.",
"mailaccount": "Die Mailadresse mit '@fet.at' angeben.",
}
labels = {
"description": _("Beschreibung zu der Person"),
"image": _("Porträt"),
"birthday": _("Geburtstag"),
"phone": _("Telefonnummer"),
"address": _("Wohnadresse"),
"description": "Beschreibung zu der Person",
"image": "Porträt",
"birthday": "Geburtstag",
"phone": "Telefonnummer",
"address": "Wohnadresse",
}
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
@@ -42,9 +38,9 @@ class JobForm(forms.ModelForm):
model = Job
labels = {
"shortterm": _("Kürzel der Tätigkeit"),
"slug": _("Permalink"),
"job_group": _("Tätigkeitsbereich"),
"shortterm": "Kürzel der Tätigkeit",
"slug": "Permalink",
"job_group": "Tätigkeitsbereich",
}
@@ -54,9 +50,9 @@ class JobGroupForm(forms.ModelForm):
model = JobGroup
labels = {
"shortterm": _("Kürzel des Tätigkeitsbereichs"),
"slug": _("Permalink"),
"description": _("Beschreibung des Tätigkeitsbereichs"),
"shortterm": "Kürzel des Tätigkeitsbereichs",
"slug": "Permalink",
"description": "Beschreibung des Tätigkeitsbereichs",
}
widgets = {"description": CKEditorUploadingWidget(config_name="default")}

View File

@@ -7,7 +7,6 @@ from django.core.validators import ValidationError, validate_email
from django.db import models
from django.urls import reverse
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from .managers import (
ActiveJobMemberManager,
@@ -40,13 +39,13 @@ class Member(models.Model):
max_length=128,
validators=[validate_email, validate_domainonly_email],
error_messages={
"unique": _("Diese Mailadresse existiert schon."),
"unique": "Diese Mailadresse existiert schon.",
},
)
class MemberRole(models.TextChoices):
ACTIVE = "A", _("Active")
PENSION = "P", _("Pension")
ACTIVE = "A", "Active"
PENSION = "P", "Pension"
role = models.CharField(
"Rolle",
@@ -92,7 +91,7 @@ class Member(models.Model):
def clean(self):
if not self.image:
raise ValidationError(_("Es fehlt das Profilbild."))
raise ValidationError("Es fehlt das Profilbild.")
if self.username:
try:
@@ -182,12 +181,12 @@ class JobMember(models.Model):
job_end = models.DateField("Job Ende", null=True, blank=True)
class JobRole(models.TextChoices):
PRESIDENT = ("10", _("Vorsitz"))
VICE_PRESIDENT = ("20", _("Stv. Vorsitz"))
SECOND_VICE_PRESIDENT = ("30", _("2. Stv. Vorsitz"))
PERSON_RESPONSIBLE = ("40", _("Verantwortliche_r"))
MEMBER = ("50", _("Mitglied"))
SUBSTITUTE_MEMBER = ("60", _("Ersatzmitglied"))
PRESIDENT = ("10", "Vorsitz")
VICE_PRESIDENT = ("20", "Stv. Vorsitz")
SECOND_VICE_PRESIDENT = ("30", "2. Stv. Vorsitz")
PERSON_RESPONSIBLE = ("40", "Verantwortliche_r")
MEMBER = ("50", "Mitglied")
SUBSTITUTE_MEMBER = ("60", "Ersatzmitglied")
job_role = models.CharField(
max_length=2, choices=JobRole.choices, default=JobRole.MEMBER

View File

@@ -1,31 +1,27 @@
from django.core.validators import RegexValidator, ValidationError
from django.utils.deconstruct import deconstructible
from django.utils.translation import gettext_lazy as _
@deconstructible
class PhoneNumberValidator(RegexValidator):
regex = r"^\+?1?\d{9,15}$"
message = _(
"Telefonnummer muss in diesem Format +999999999999 eingegeben werden. "
"Bis zu 15 Zahlen sind erlaubt."
)
message = "Telefonnummer muss in diesem Format +999999999999 eingegeben werden. Bis zu 15 Zahlen sind erlaubt."
def validate_domainonly_email(value):
if not "fet.at" in value:
raise ValidationError(_("In der Mailadresse fehlt die richtige Domäne."))
raise ValidationError("In der Mailadresse fehlt die richtige Domäne.")
def validate_file_size(value):
if value.size > 10 * 1024 * 1024:
raise ValidationError(_("Die maximale Dateigröße ist 10MB."))
raise ValidationError("Die maximale Dateigröße ist 10MB.")
def validate_image_dimension(value):
if value.height < 150 or value.width < 150:
raise ValidationError(
_("Das Bild ist zu klein. (Höhe: %(height)s, Breite: %(width)s)"),
"Das Bild ist zu klein. (Höhe: %(height)s, Breite: %(width)s)",
params={
"height": value.height,
"width": value.width,

View File

@@ -1,5 +1,4 @@
from django.contrib import admin, messages
from django.utils.translation import gettext_lazy as _
from documents.api import create_pad
from .forms import EventForm, FetMeetingForm, NewsForm, PostForm
@@ -13,7 +12,7 @@ def make_fetmeeting(self, request, queryset):
if not agenda_key:
self.message_user(
request,
_("Das Agenda konnte nicht erstellt werden. Error: %s") % str(e),
f"Das Agenda konnte nicht erstellt werden. Error: {str(e)}",
messages.ERROR,
)
return
@@ -22,7 +21,7 @@ def make_fetmeeting(self, request, queryset):
if not protocol_key:
self.message_user(
request,
_("Das Protokoll konnte nicht erstellt werden. Error: %s") % str(e),
f"Das Protokoll konnte nicht erstellt werden. Error: {str(e)}",
messages.ERROR,
)
return
@@ -36,8 +35,7 @@ def make_fetmeeting(self, request, queryset):
)
self.message_user(
request,
_("Das Event %s wurde erfolgreich in eine FET Sitzung konvertiert.")
% (qs.title),
f"Das Event qs.title wurde erfolgreich in eine FET Sitzung konvertiert.",
messages.SUCCESS,
)

View File

@@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View File

@@ -1,3 +0,0 @@
from django.db import models
# Create your models here.

View File

@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -6,7 +6,6 @@ from django.contrib.auth.models import User
from django.core.validators import ValidationError
from django.forms.widgets import HiddenInput
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from .models import Task, TaskList, Document
@@ -24,7 +23,7 @@ class DocumentInlineForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"title": "Titel",
}
@@ -41,9 +40,9 @@ class TaskListAdminForm(forms.ModelForm):
fields = "__all__"
labels = {
"name": _("Titel"),
"shortterm": _("Kürzel für den Link"),
"slug": _("Permalink"),
"name": "Titel",
"shortterm": "Kürzel für den Link",
"slug": "Permalink",
}
@@ -53,16 +52,16 @@ class TaskAdminForm(forms.ModelForm):
fields = "__all__"
labels = {
"title": _("Titel"),
"shortterm": _("Kürzel für den Link"),
"slug": _("Permalink"),
"task_list": _("Aufgabenbereich"),
"due_date": _("Fälligkeit"),
"completed": _("Abgeschlossen"),
"completed_date": _("Datum der Fertigstellung"),
"assigned_to": _("Zuweisen an"),
"note": _("Notizen"),
"priority": _("Priorität"),
"title": "Titel",
"shortterm": "Kürzel für den Link",
"slug": "Permalink",
"task_list": "Aufgabenbereich",
"due_date": "Fälligkeit",
"completed": "Abgeschlossen",
"completed_date": "Datum der Fertigstellung",
"assigned_to": "Zuweisen an",
"note": "Notizen",
"priority": "Priorität",
}
widgets = {
@@ -90,11 +89,11 @@ class TaskCreateForm(forms.ModelForm):
]
labels = {
"title": _("Titel des Tasks"),
"task_list": _("Task-Gruppe"),
"assigned_to": _("Zuweisen an"),
"due_date": _("Fälligkeitsdatum"),
"note": _("Notizen"),
"title": "Titel des Tasks",
"task_list": "Task-Gruppe",
"assigned_to": "Zuweisen an",
"due_date": "Fälligkeitsdatum",
"note": "Notizen",
}
widgets = {
@@ -146,11 +145,11 @@ class TaskUpdateForm(forms.ModelForm):
]
labels = {
"assigned_to": _("Zuweisen an"),
"due_date": _("Fälligkeitsdatum"),
"completed": _("Abgeschlossen"),
"completed_date": _("Datum der Fertigstellung"),
"note": _("Notizen"),
"assigned_to": "Zuweisen an",
"due_date": "Fälligkeitsdatum",
"completed": "Abgeschlossen",
"completed_date": "Datum der Fertigstellung",
"note": "Notizen",
}
widgets = {
@@ -185,8 +184,8 @@ class DocumentCreateForm(forms.ModelForm):
]
labels = {
"title": _("Titel"),
"date": _("Datum"),
"title": "Titel",
"date": "Datum",
}
widgets = {
@@ -209,10 +208,10 @@ class InternTaskCreateForm(TaskCreateForm):
]
labels = {
"title": _("Titel des Tasks"),
"task_list": _("Task-Gruppe"),
"due_date": _("Fälligkeitsdatum"),
"assigned_to": _("Zuweisen an"),
"title": "Titel des Tasks",
"task_list": "Task-Gruppe",
"due_date": "Fälligkeitsdatum",
"assigned_to": "Zuweisen an",
}
widgets = {

View File

@@ -9,7 +9,6 @@ from django.db.models.constraints import UniqueConstraint
from django.urls import reverse
from django.utils import timezone
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from documents import create_pad
from documents.api import get_pad_link
@@ -135,14 +134,11 @@ class Document(models.Model):
pad_name = slugify(str(self.slug_id) + "-" + self.title[:40])
if len(pad_name) > 50:
raise ValidationError(
_(
"Name zum Erstellen des Etherpads ist zu lange - max. 50 Zeichen. (Länge: %(length)s, Name: %(pad_name)s)"
),
params={"length": len(pad_name), "pad_name": pad_name},
f"Name zum Erstellen des Etherpads ist zu lange - max. 50 Zeichen. (Länge: {len(pad_name)}, Name: {pad_name})"
)
self.etherpad_key = create_pad(pad_name)
if not self.etherpad_key:
raise ValidationError(
_(f"Etherpad '{pad_name}' konnte nicht erstellt werden."),
f"Etherpad '{pad_name}' konnte nicht erstellt werden."
)