code formatting (black, isort and flake8)
This commit is contained in:
@@ -15,15 +15,15 @@ def get_ep_client():
|
||||
|
||||
# Get api key from settings
|
||||
if not os.path.isfile(api_key_path):
|
||||
logger.info(f"API Key file is missing. Path: {api_key_path}")
|
||||
logger.info("API Key file is missing. Path: %s", api_key_path)
|
||||
return None
|
||||
|
||||
with open(os.path.abspath(api_key_path), "r") as f:
|
||||
with open(os.path.abspath(api_key_path)) as f:
|
||||
api_key = f.read()
|
||||
api_key = api_key.rstrip()
|
||||
|
||||
if api_key == "":
|
||||
logger.info(f"API Key is missing. Path: {api_key_path}")
|
||||
logger.info("API Key is missing. Path: %s", api_key_path)
|
||||
return None
|
||||
|
||||
# Connection to Etherpad Client
|
||||
@@ -36,7 +36,7 @@ def get_ep_client():
|
||||
api_version="1.2.14",
|
||||
)
|
||||
except EtherpadException as e:
|
||||
logger.info(f"Connection to Etherpad Client failed. Error: {e}")
|
||||
logger.info("Connection to Etherpad Client failed. Error: %s", e)
|
||||
return None
|
||||
|
||||
return ep_c
|
||||
@@ -56,8 +56,8 @@ def get_ep_group(ep_group_name: str = "fet") -> dict[str, str]:
|
||||
return ep_group
|
||||
|
||||
|
||||
def ep_pad_exists(pad_id: str | None = None) -> (bool | None):
|
||||
""" Check if pad exists.
|
||||
def ep_pad_exists(pad_id: str | None = None) -> bool | None:
|
||||
"""Check if pad exists.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -82,10 +82,10 @@ def ep_pad_exists(pad_id: str | None = None) -> (bool | None):
|
||||
|
||||
lists = ep_c.listPads(groupID=ep_group["groupID"])
|
||||
if any(pad_id in s for s in lists["padIDs"]):
|
||||
logger.info(f"Etherpad exists. Pad: {pad_id}")
|
||||
logger.info("Etherpad exists. Pad: %s", pad_id)
|
||||
return True
|
||||
|
||||
logger.info(f"Etherpad doesn't exist. Pad: {pad_id}")
|
||||
logger.info("Etherpad doesn't exist. Pad: %s", pad_id)
|
||||
return False
|
||||
|
||||
|
||||
@@ -106,13 +106,13 @@ def ep_create_new_pad(pad_id: str | None, text="helloworld"):
|
||||
|
||||
if ep_pad_exists(pad_id) is False:
|
||||
ep_c.createGroupPad(groupID=ep_group["groupID"], padName=pad_id, text=text)
|
||||
logger.info(f"Create new etherpad. Pad: {pad_id}")
|
||||
logger.info("Create new etherpad. Pad: %s", pad_id)
|
||||
return pad_id
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def ep_get_html(pad_id: str | None) -> (str | None):
|
||||
def ep_get_html(pad_id: str | None) -> str | None:
|
||||
if (ep_c := get_ep_client()) is None:
|
||||
return None
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ class BillCreateForm(forms.ModelForm):
|
||||
iban_text = forms.CharField(required=False, label="IBAN", initial="", max_length=34)
|
||||
bic_text = forms.CharField(required=False, label="BIC", initial="", max_length=11)
|
||||
saving = forms.BooleanField(
|
||||
required=False, label="Bankdaten für die nächsten Rechnungen speichern.", initial=False
|
||||
required=False,
|
||||
label="Bankdaten für die nächsten Rechnungen speichern.",
|
||||
initial=False,
|
||||
)
|
||||
|
||||
# Resolution
|
||||
@@ -138,7 +140,9 @@ class BillUpdateForm(forms.ModelForm):
|
||||
iban_text = forms.CharField(required=False, label="IBAN", initial="", max_length=34)
|
||||
bic_text = forms.CharField(required=False, label="BIC", initial="", max_length=11)
|
||||
saving = forms.BooleanField(
|
||||
required=False, label="Bankdaten für die nächsten Rechnungen speichern.", initial=False
|
||||
required=False,
|
||||
label="Bankdaten für die nächsten Rechnungen speichern.",
|
||||
initial=False,
|
||||
)
|
||||
|
||||
# only digital bill
|
||||
@@ -401,7 +405,7 @@ class BillAdminForm(forms.ModelForm):
|
||||
qs = qs.filter(status=Wiref.Status.OPENED)
|
||||
|
||||
# add wiref id if wiref is already transferred.
|
||||
bill = kwargs.get("instance", None)
|
||||
bill = kwargs.get("instance")
|
||||
if bill is not None and bill.wiref is not None and bill.wiref.status != Wiref.Status.OPENED:
|
||||
qs |= self.fields["wiref"].queryset.filter(wiref_id=bill.wiref.wiref_id)
|
||||
|
||||
@@ -425,7 +429,7 @@ class ResolutionAdminForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
|
||||
resolution = kwargs.get("instance", None)
|
||||
resolution = kwargs.get("instance")
|
||||
bills = Bill.objects.filter(resolution=resolution)
|
||||
total = 0
|
||||
for elem in bills:
|
||||
@@ -475,7 +479,7 @@ class WirefAdminForm(forms.ModelForm):
|
||||
|
||||
self.fields["wiref_id"].required = True
|
||||
|
||||
wiref = kwargs.get("instance", None)
|
||||
wiref = kwargs.get("instance")
|
||||
total = 0
|
||||
|
||||
if wiref is not None:
|
||||
|
||||
@@ -121,7 +121,11 @@ class Wiref(models.Model):
|
||||
class Bill(models.Model):
|
||||
# members can be deleted but never their bills
|
||||
bill_creator = models.ForeignKey(
|
||||
Member, on_delete=models.PROTECT, blank=True, null=True, verbose_name="Verantwortliche:r"
|
||||
Member,
|
||||
on_delete=models.PROTECT,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name="Verantwortliche:r",
|
||||
)
|
||||
|
||||
bankdata = models.ForeignKey(
|
||||
|
||||
@@ -4,7 +4,6 @@ from django.core.management.base import BaseCommand
|
||||
|
||||
from gallery.utils import create_thumbs, get_folder_list
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from collections import deque
|
||||
from django import template
|
||||
from django.db.models import F
|
||||
|
||||
from members.models import JobMember, JobGroup
|
||||
from members.models import JobGroup, JobMember
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ class Post(models.Model):
|
||||
articles = ArticleManager()
|
||||
|
||||
def __str__(self):
|
||||
return "Post (%s, %s): %s" % (
|
||||
return "Post ({}, {}): {}".format(
|
||||
self.slug,
|
||||
self.public_date.strftime("%d.%m.%Y"),
|
||||
self.title,
|
||||
@@ -151,7 +151,7 @@ class Post(models.Model):
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def agenda_html(self) -> (str | None):
|
||||
def agenda_html(self) -> str | None:
|
||||
"Agenda HTML from Etherpad Pad"
|
||||
if self.agenda_key in [None, "#"]:
|
||||
return None
|
||||
@@ -159,7 +159,7 @@ class Post(models.Model):
|
||||
return ep_get_html(self.agenda_key)
|
||||
|
||||
@property
|
||||
def protocol_html(self) -> (str | None):
|
||||
def protocol_html(self) -> str | None:
|
||||
"Protocol HTML from Etherpad Pad"
|
||||
if self.protocol_key in [None, "#"]:
|
||||
return None
|
||||
@@ -167,7 +167,7 @@ class Post(models.Model):
|
||||
return ep_get_html(self.protocol_key)
|
||||
|
||||
@agenda_html.setter
|
||||
def agenda_html(self, value: str) -> (str | None):
|
||||
def agenda_html(self, value: str) -> str | None:
|
||||
if self.agenda_key is None:
|
||||
self.create_agenda_key()
|
||||
|
||||
@@ -175,11 +175,11 @@ class Post(models.Model):
|
||||
return None
|
||||
|
||||
ep_set_html(self.agenda_key, value)
|
||||
request_logger.info(f"Set agenda etherpad. Post: {self.slug}. Key: {self.agenda_key}")
|
||||
request_logger.info("Set agenda etherpad. Post: %s. Key: %s", self.slug, self.agenda_key)
|
||||
return value
|
||||
|
||||
@protocol_html.setter
|
||||
def protocol_html(self, value: str) -> (str | None):
|
||||
def protocol_html(self, value: str) -> str | None:
|
||||
if self.protocol_key is None:
|
||||
self.create_protocol_key()
|
||||
|
||||
@@ -187,14 +187,16 @@ class Post(models.Model):
|
||||
return None
|
||||
|
||||
ep_set_html(self.protocol_key, value)
|
||||
request_logger.info(f"Set protocol etherpad. Post: {self.slug}. Key: {self.protocol_key}")
|
||||
request_logger.info(
|
||||
"Set protocol etherpad. Post: %s. Key: %s", self.slug, self.protocol_key
|
||||
)
|
||||
return value
|
||||
|
||||
_agenda_filename = None
|
||||
_agenda_url = None
|
||||
|
||||
@property
|
||||
def agenda_url(self) -> (str | None):
|
||||
def agenda_url(self) -> str | None:
|
||||
if self.has_agenda is not True:
|
||||
self._agenda_url = None
|
||||
self._agenda_filename = None
|
||||
@@ -213,7 +215,7 @@ class Post(models.Model):
|
||||
return self._agenda_url
|
||||
|
||||
@property
|
||||
def agenda_filename(self) -> (str | None):
|
||||
def agenda_filename(self) -> str | None:
|
||||
if self._agenda_filename is not None:
|
||||
return self._agenda_filename
|
||||
|
||||
@@ -226,7 +228,7 @@ class Post(models.Model):
|
||||
_protocol_url = None
|
||||
|
||||
@property
|
||||
def protocol_url(self) -> (str | None):
|
||||
def protocol_url(self) -> str | None:
|
||||
if self.has_protocol is not True:
|
||||
self._protocol_url = None
|
||||
self._protocol_filename = None
|
||||
@@ -245,7 +247,7 @@ class Post(models.Model):
|
||||
return self._protocol_url
|
||||
|
||||
@property
|
||||
def protocol_filename(self) -> (str | None):
|
||||
def protocol_filename(self) -> str | None:
|
||||
if self._protocol_filename is not None:
|
||||
return self._protocol_filename
|
||||
|
||||
|
||||
@@ -11,6 +11,4 @@ register = template.Library()
|
||||
@stringfilter
|
||||
def tags_to_url(value):
|
||||
# return "Tag to url: %s" % value
|
||||
return mark_safe(
|
||||
re.sub(r"\#([\d\w-]+)", r'<a href="/posts/t/\g<1>">#\g<1></a>', value)
|
||||
)
|
||||
return mark_safe(re.sub(r"\#([\d\w-]+)", r'<a href="/posts/t/\g<1>">#\g<1></a>', value))
|
||||
|
||||
Reference in New Issue
Block a user