Skip to content

Commit

Permalink
Add plugins to autodeployment with docker (#112)
Browse files Browse the repository at this point in the history
* add plugin for auto deployment
  • Loading branch information
odkhang authored Jul 2, 2024
1 parent c3d82bd commit 4cdd9f1
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 1 deletion.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ RUN pip3 install -U pip setuptools wheel typing && \
pip3 install pylibmc && \
pip3 install gunicorn


RUN python3 -m pretalx makemigrations
RUN python3 -m pretalx migrate

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ dependencies = [
"vobject~=0.9.0",
"whitenoise~=6.6.0",
"zxcvbn~=4.4.0",
'pretalx_pages @ git+https://github.com/fossasia/eventyay-talk-pages.git@main',
'pretalx_venueless @ git+https://github.com/fossasia/eventyay-talk-video.git@main'
]

[project.optional-dependencies]
Expand Down
46 changes: 46 additions & 0 deletions src/pretalx/common/models/mixins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import json

from django.contrib.contenttypes.models import ContentType
from i18nfield.utils import I18nJSONEncoder

SENSITIVE_KEYS = ["password", "secret", "api_key"]


class LogMixin:
def log_action(self, action, data=None, person=None, orga=False):
if not self.pk:
return

from pretalx.common.models import ActivityLog

if data and isinstance(data, dict):
for key, value in data.items():
if any(sensitive_key in key for sensitive_key in SENSITIVE_KEYS):
value = data[key]
data[key] = "********" if value else value
data = json.dumps(data, cls=I18nJSONEncoder)
elif data:
raise TypeError(
f"Logged data should always be a dictionary, not {type(data)}."
)

return ActivityLog.objects.create(
event=getattr(self, "event", None),
person=person,
content_object=self,
action_type=action,
data=data,
is_orga_action=orga,
)

def logged_actions(self):
from pretalx.common.models import ActivityLog

return (
ActivityLog.objects.filter(
content_type=ContentType.objects.get_for_model(type(self)),
object_id=self.pk,
)
.select_related("event", "person")
.prefetch_related("content_object")
)
103 changes: 103 additions & 0 deletions src/pretalx/common/text/phrases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import random
from abc import ABCMeta

from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy

_phrase_book = {}


class PhrasesMetaClass(ABCMeta): # noqa
def __new__(cls, class_name, bases, namespace, app):
new = super().__new__(cls, class_name, bases, namespace)
_phrase_book[app] = new()
return new

def __init__(cls, *args, app, **kwargs):
super().__init__(*args, **kwargs)


class Phrases(metaclass=PhrasesMetaClass, app=""):
def __getattribute__(self, attribute):
result = super().__getattribute__(attribute)
if isinstance(result, (list, tuple)):
return random.choice(result)
return result


class PhraseBook:
def __getattribute__(self, attribute):
return _phrase_book.get(attribute)


phrases = PhraseBook()


class BasePhrases(Phrases, app="base"):
"""
This class contains base phrases that are guaranteed to remain the same.
"""

send = _("Send")
save = _("Save")
cancel = _("Cancel")
edit = _("Edit")
all_choices = _("all")
back_button = _("Back")
delete_button = _("Delete")

delete_confirm_heading = _("Confirm deletion")
delete_warning = _(
"Please make sure that this is the item you want to delete. This action cannot be undone!"
)

saved = _("Your changes have been saved.")
back_try_again = _("Please go back and try again.")
bad_request = _("Bad request.")
error_sending_mail = _(
"There was an error sending the mail. Please try again later."
)
error_saving_changes = _(
"We had trouble saving your input – Please see below for details."
)
error_permissions_action = _("You do not have permission to perform this action.")

permission_denied = _("Permission denied.")
permission_denied_long = (
_("Sorry, you do not have the required permissions to access this page."),
)
not_found = _("Page not found.")
not_found_long = [
_("This page does not exist."),
_("Huh, I could have sworn there was something here."),
"",
_("This page is no more."),
_("This page has ceased to be."),
_("Huh."),
]

enter_email = _("Email address")
new_password = _("New password")
password_repeat = _("New password (again)")
passwords_differ = _(
"You entered two different passwords. Please enter the same one twice!"
)
password_reset_heading = pgettext_lazy("noun / heading", "Reset password")
password_reset_question = _("Forgot your password?")
password_reset_action = _("Let me set a new one!")
password_reset_nearly_done = _(
"Now you just need to choose your new password and you are ready to go."
)
password_reset_success = _("The password was reset.")

use_markdown = _("You can use {link_start}Markdown{link_end} here.").format(
link_start='<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="noopener">',
link_end="</a>",
)
public_content = _("This content will be shown publicly.")
quotation_open = pgettext_lazy("opening quotation mark", "“")
quotation_close = pgettext_lazy("closing quotation mark", "”")
language = _("Language")
general = _("General")
email_subject = pgettext_lazy("email subject", "Subject")
text_body = _("Text")

0 comments on commit 4cdd9f1

Please sign in to comment.