Skip to content

Commit

Permalink
Notify on attending
Browse files Browse the repository at this point in the history
  • Loading branch information
blopker committed Nov 3, 2023
1 parent 1dc7d8d commit 6e98790
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
{
"command": "./manage.py totem_tasks",
"schedule": "*/10 * * * *"
},
{
"command": "./manage.py clearsessions",
"schedule": "@daily"
}
]
}
1 change: 0 additions & 1 deletion compose/local/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ RUN sed -i 's/\r$//g' /start
RUN chmod +x /start



# copy application code to WORKDIR
COPY . ${APP_HOME}

Expand Down
4 changes: 1 addition & 3 deletions compose/production/django/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions totem/circles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion totem/utils/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

0 comments on commit 6e98790

Please sign in to comment.