diff --git a/app.json b/app.json index 4ce40639..3e9e7351 100644 --- a/app.json +++ b/app.json @@ -14,6 +14,10 @@ { "command": "./manage.py totem_tasks", "schedule": "*/10 * * * *" + }, + { + "command": "./manage.py clearsessions", + "schedule": "@daily" } ] } diff --git a/compose/local/django/Dockerfile b/compose/local/django/Dockerfile index d1594414..1740f491 100644 --- a/compose/local/django/Dockerfile +++ b/compose/local/django/Dockerfile @@ -60,7 +60,6 @@ RUN sed -i 's/\r$//g' /start RUN chmod +x /start - # copy application code to WORKDIR COPY . ${APP_HOME} diff --git a/compose/production/django/Dockerfile b/compose/production/django/Dockerfile index c9b0ba62..4311a285 100644 --- a/compose/production/django/Dockerfile +++ b/compose/production/django/Dockerfile @@ -1,5 +1,5 @@ # define an alias for the specfic python version used in this file. -FROM python:3.11.4-slim-bullseye as python +FROM python:3.11.6-slim-bullseye as python # Python build stage FROM python as python-build-stage @@ -55,12 +55,10 @@ COPY --from=python-build-stage /usr/src/app/wheels /wheels/ RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \ && rm -rf /wheels/ - COPY --chown=django:django ./compose/production/django/entrypoint /entrypoint RUN sed -i 's/\r$//g' /entrypoint RUN chmod +x /entrypoint - COPY --chown=django:django ./compose/production/django/start /start RUN sed -i 's/\r$//g' /start RUN chmod +x /start diff --git a/totem/circles/models.py b/totem/circles/models.py index a4522ecb..70855434 100644 --- a/totem/circles/models.py +++ b/totem/circles/models.py @@ -19,6 +19,7 @@ from totem.utils.hash import basic_hash, hmac from totem.utils.md import MarkdownField, MarkdownMixin from totem.utils.models import AdminURLMixin, SluggedModel +from totem.utils.slack import notify_slack from totem.utils.utils import full_url from .calendar import calendar @@ -167,6 +168,7 @@ def add_attendee(self, user): if self.can_attend(user=user): self.attendees.add(user) self.save() + notify_slack(f"New Circle attendee: {user.email} for {self.circle.title} by {self.circle.author.name}") def started(self): return self.start < timezone.now() diff --git a/totem/utils/slack.py b/totem/utils/slack.py index b3bf34c8..5f37c612 100644 --- a/totem/utils/slack.py +++ b/totem/utils/slack.py @@ -3,6 +3,8 @@ import requests from django.conf import settings +requests_session = requests.Session() + def notify_slack(message): if settings.SLACK_WEBHOOK_URL is None: @@ -16,4 +18,4 @@ def notify_slack(message): "text": message, } - requests.post(settings.SLACK_WEBHOOK_URL, headers=headers, data=json.dumps(json_data), timeout=10) + requests_session.post(settings.SLACK_WEBHOOK_URL, headers=headers, data=json.dumps(json_data), timeout=10)