From 508080f78e3b77d275822ebcf58593cfd859cc7b Mon Sep 17 00:00:00 2001
From: Michael Hall
Date: Sat, 12 May 2018 17:11:43 -0400
Subject: [PATCH] move comment posting view into get_together so we can have it
send emails to attendees. Fixes #87
---
events/views.py | 36 -----------
.../get_together/emails/event_comment.html | 12 ++++
.../get_together/emails/event_comment.txt | 10 ++++
.../get_together/events/show_event.html | 2 +-
get_together/urls.py | 4 +-
get_together/views/events.py | 60 +++++++++++++++++++
6 files changed, 85 insertions(+), 39 deletions(-)
create mode 100644 get_together/templates/get_together/emails/event_comment.html
create mode 100644 get_together/templates/get_together/emails/event_comment.txt
diff --git a/events/views.py b/events/views.py
index 13b23bf..4e0995a 100644
--- a/events/views.py
+++ b/events/views.py
@@ -115,39 +115,3 @@ def leave_team(request, team_id):
messages.add_message(request, messages.SUCCESS, message=_('You are no longer on this team.'))
return redirect('show-team', team_id=team_id)
-def attend_event(request, event_id):
- event = Event.objects.get(id=event_id)
- if request.user.is_anonymous:
- messages.add_message(request, messages.WARNING, message=_("You must be logged in to say you're attending."))
- return redirect(event.get_absolute_url())
-
- try:
- attendee = Attendee.objects.get(event=event, user=request.user.profile)
- except:
- attendee = Attendee(event=event, user=request.user.profile, role=Attendee.NORMAL)
-
- attendee.status = Attendee.YES
- if request.GET.get('response', None) == 'maybe':
- attendee.status = Attendee.MAYBE
- if request.GET.get('response', None) == 'no':
- attendee.status = Attendee.NO
- attendee.save()
- if attendee.status == Attendee.YES:
- messages.add_message(request, messages.SUCCESS, message=_("We'll see you there!"))
- return redirect(event.get_absolute_url())
-
-def comment_event(request, event_id):
- event = Event.objects.get(id=event_id)
- if request.user.is_anonymous:
- messages.add_message(request, messages.WARNING, message=_("You must be logged in to comment."))
- return redirect(event.get_absolute_url())
-
- if request.method == 'POST':
- new_comment = EventComment(author=request.user.profile, event=event)
- comment_form = EventCommentForm(request.POST, instance=new_comment)
- if comment_form.is_valid():
- new_comment = comment_form.save()
- return redirect(event.get_absolute_url()+'#comment-%s'%new_comment.id)
-
- return redirect(event.get_absolute_url())
-
diff --git a/get_together/templates/get_together/emails/event_comment.html b/get_together/templates/get_together/emails/event_comment.html
new file mode 100644
index 0000000..e36c6de
--- /dev/null
+++ b/get_together/templates/get_together/emails/event_comment.html
@@ -0,0 +1,12 @@
+{% extends "get_together/emails/base.html" %}
+
+{% block content %}
+Comment on {{comment.event.name|striptags}}
+
+By: {{ comment.author }} - {{comment.created_time}}
+
+{{comment.body|striptags}}
+
+View this comment.
+
+{% endblock %}
diff --git a/get_together/templates/get_together/emails/event_comment.txt b/get_together/templates/get_together/emails/event_comment.txt
new file mode 100644
index 0000000..433d7b8
--- /dev/null
+++ b/get_together/templates/get_together/emails/event_comment.txt
@@ -0,0 +1,10 @@
+{% block content %}
+== Comment on {{comment.event.name|striptags}} ==
+
+By {{ comment.author }} - {{comment.created_time}}
+
+{{comment.body}}
+
+Click here to view this event: {{comment.event.get_full_url}}#comment-{{comment.id}}
+
+{% endblock %}
diff --git a/get_together/templates/get_together/events/show_event.html b/get_together/templates/get_together/events/show_event.html
index 39fb079..12edde8 100644
--- a/get_together/templates/get_together/events/show_event.html
+++ b/get_together/templates/get_together/events/show_event.html
@@ -200,7 +200,7 @@
{% load mptt_tags %}
{% recursetree event.comments.all %}
-
+