Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions ephios/core/forms/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import re
from datetime import datetime, timedelta

from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Field, Layout, Submit
from django import forms
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
Expand All @@ -25,7 +22,6 @@
from ephios.core.signup.structure import enabled_shift_structures, shift_structure_from_slug
from ephios.core.widgets import MultiUserProfileWidget
from ephios.extra.colors import clear_eventtype_color_css_fragment_cache
from ephios.extra.crispy import AbortLink
from ephios.extra.permissions import get_groups_with_perms
from ephios.extra.widgets import CustomDateInput, CustomTimeInput, MarkdownTextarea, RecurrenceField
from ephios.modellogging.log import add_log_recorder, update_log
Expand Down Expand Up @@ -315,40 +311,3 @@ def is_function_active(self):
With the default template, if this is True, the collapse is expanded on page load.
"""
return False


class EventNotificationForm(forms.Form):
NEW_EVENT = "new"
REMINDER = "remind"
PARTICIPANTS = "participants"
action = forms.ChoiceField(
choices=[
(NEW_EVENT, _("Send notification about new event to everyone")),
(REMINDER, _("Send reminder to everyone that is not participating")),
(PARTICIPANTS, _("Send a message to all participants")),
],
widget=forms.RadioSelect,
label=False,
)
mail_content = forms.CharField(required=False, widget=forms.Textarea, label=_("Mail content"))

def __init__(self, *args, **kwargs):
self.event = kwargs.pop("event")
super().__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.layout = Layout(
Field("action"),
Field("mail_content"),
FormActions(
Submit("submit", _("Send"), css_class="float-end"),
AbortLink(href=self.event.get_absolute_url()),
),
)

def clean(self):
if (
self.cleaned_data.get("action") == self.PARTICIPANTS
and not self.cleaned_data["mail_content"]
):
raise ValidationError(_("You cannot send an empty mail."))
return super().clean()
Empty file.
32 changes: 16 additions & 16 deletions ephios/core/services/health/healthchecks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# health checks are meant to monitor the health of the application while it is running
# in contrast there are django checks which are meant to check the configuration of the application

# pylint: disable=broad-exception-raised, broad-exception-caught


def run_healthchecks():
for _, healthchecks in register_healthchecks.send(None):
Expand Down Expand Up @@ -128,26 +130,24 @@ class CronJobHealthCheck(AbstractHealthCheck):

def check(self):
last_call = LastRunPeriodicCall.get_last_call()
if LastRunPeriodicCall.is_stuck():
if last_call:
return (
HealthCheckStatus.WARNING,
mark_safe(
_("Cronjob stuck, last run {last_call}.").format(
last_call=naturaltime(last_call),
)
),
)
else:
return (
HealthCheckStatus.ERROR,
mark_safe(_("Cronjob stuck, no last run.")),
)
else:
if not LastRunPeriodicCall.is_stuck():
return (
HealthCheckStatus.OK,
mark_safe(_("Last run {last_call}.").format(last_call=naturaltime(last_call))),
)
if last_call:
return (
HealthCheckStatus.WARNING,
mark_safe(
_("Cronjob stuck, last run {last_call}.").format(
last_call=naturaltime(last_call),
)
),
)
return (
HealthCheckStatus.ERROR,
mark_safe(_("Cronjob stuck, no last run.")),
)


class DiskSpaceHealthCheck(AbstractHealthCheck):
Expand Down
Empty file.
7 changes: 4 additions & 3 deletions ephios/core/services/mail/cid.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# source:
# https://github.com/pretix/pretix/blob/a08272571b7b67a3f41e02cf05af8183e3f94a02/src/pretix/base/services/mail.py

# pylint: disable = logging-not-lazy, missing-timeout, bare-except


class CustomEmail(EmailMultiAlternatives):
def _create_mime_attachment(self, content, mimetype):
Expand All @@ -31,7 +33,7 @@ def _create_mime_attachment(self, content, mimetype):
If the mimetype is message/rfc822, content may be an
email.Message or EmailMessage object, as well as a str.
"""
basetype, subtype = mimetype.split("/", 1)
basetype, __ = mimetype.split("/", 1)
if basetype == "multipart" and isinstance(content, SafeMIMEMultipart):
return content
return super()._create_mime_attachment(content, mimetype)
Expand All @@ -50,8 +52,7 @@ def replace_images_with_cid_paths(body_html):
cid_id = "image_%s" % (len(cid_images) - 1)
image["src"] = "cid:%s" % cid_id
return str(email), cid_images
else:
return body_html, []
return body_html, []


def attach_cid_images(msg, cid_images, verify_ssl=True):
Expand Down
3 changes: 2 additions & 1 deletion ephios/core/services/notifications/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def enabled_notification_backends():
def send_all_notifications():
CACHE_LOCK_KEY = "notification_sending_running"
if cache.get(CACHE_LOCK_KEY):
logger.warning("Previous notification sending job not finished. Skipping...")
return
cache.set(CACHE_LOCK_KEY, str(uuid.uuid4()), timeout=1800) # will be cleared if no errors occur
backends = set(installed_notification_backends())
Expand Down Expand Up @@ -168,7 +169,7 @@ def send(cls, notification):
payload = {
"head": str(notification.subject),
"body": notification.body,
"icon": as_brand_static_path("appicon-prod.svg"),
"icon": as_brand_static_path("appicon-svg-prod.svg"),
}
if actions := notification.get_actions():
payload["url"] = actions[0][1]
Expand Down
Loading