Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugins to autodeployment with docker #112

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ COPY src /pretalx/src
COPY deployment/docker/pretalx.bash /usr/local/bin/pretalx
COPY deployment/docker/supervisord.conf /etc/supervisord.conf

RUN pip3 install -U pip setuptools wheel typing && \
RUN pip3 install -U pip setuptools wheel typing poetry && \
pip3 install -e /pretalx/[mysql,postgres,redis] && \
pip3 install pylibmc && \
pip3 install gunicorn

RUN cd /pretalx && \
poetry install && \
rm -rf ~/.cache/poetry

RUN python3 -m pretalx makemigrations
RUN python3 -m pretalx migrate
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,14 @@ ignore = [
"src/tests/*",
"SECURITY.md",
]

[tool.poetry]
name = "pretalx"
version = "2024.2.0.dev0"
description = "Conference organisation: CfPs, scheduling, much more"
authors = ["Eventyay <[email protected]>"]

[tool.poetry.dependencies]
hongquan marked this conversation as resolved.
Show resolved Hide resolved
python = ">=3.9"
pretalx_pages = { git = "https://github.com/fossasia/eventyay-talk-pages.git", branch = "main" }
pretalx_venueless = { git = "https://github.com/fossasia/eventyay-talk-video.git", branch = "main" }
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")
Loading