From a81c9fddf78f389b1298c5c83154338c878258a6 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Fri, 27 Apr 2018 22:12:37 -0400 Subject: [PATCH] Add ability to accept or decline proposed talks --- events/models/profiles.py | 2 +- get_together/environ_settings.py | 1 + get_together/settings.py | 1 + .../events/schedule_event_talks.html | 112 ++++++++++++++++++ .../get_together/events/show_event.html | 5 +- get_together/views/events.py | 1 + get_together/views/speakers.py | 27 ++++- 7 files changed, 144 insertions(+), 5 deletions(-) create mode 100644 get_together/templates/get_together/events/schedule_event_talks.html diff --git a/events/models/profiles.py b/events/models/profiles.py index 836b44c..7751fbf 100644 --- a/events/models/profiles.py +++ b/events/models/profiles.py @@ -224,7 +224,7 @@ class Team(models.Model): category = models.ForeignKey('Category', on_delete=models.SET_NULL, blank=False, null=True) topics = models.ManyToManyField('Topic', blank=True) - is_premium = models.BooleanField(default=False) + is_premium = models.BooleanField(default=settings.EVENTS_TEAMS_DEFAULT_PREMIUM) premium_by = models.ForeignKey(UserProfile, related_name='premium_teams', null=True, on_delete=models.SET_NULL) premium_started = models.DateTimeField(blank=True, null=True) premium_expires = models.DateTimeField(blank=True, null=True) diff --git a/get_together/environ_settings.py b/get_together/environ_settings.py index de0ff71..4bd2279 100644 --- a/get_together/environ_settings.py +++ b/get_together/environ_settings.py @@ -15,3 +15,4 @@ DATABASES['default'].update(dj_database_url.config()) MEDIA_URL = os.environ.get('MEDIA_URL', '/media/') STATIC_URL = os.environ.get('STATIC_URL', '/static/') +EVENTS_TEAMS_DEFAULT_PREMIUM = os.environ.get('EVENTS_TEAMS_DEFAULT_PREMIUM', False) diff --git a/get_together/settings.py b/get_together/settings.py index 9e04858..83146c0 100644 --- a/get_together/settings.py +++ b/get_together/settings.py @@ -29,6 +29,7 @@ ALLOWED_HOSTS = [] SITE_ID=1 ADMINS = [ 'mhall119' ] +EVENTS_TEAMS_DEFAULT_PREMIUM=False # Application definition diff --git a/get_together/templates/get_together/events/schedule_event_talks.html b/get_together/templates/get_together/events/schedule_event_talks.html new file mode 100644 index 0000000..218dd6b --- /dev/null +++ b/get_together/templates/get_together/events/schedule_event_talks.html @@ -0,0 +1,112 @@ +{% extends "get_together/base.html" %} +{% load static tz %} + +{% block styles %} + + +{% endblock %} + +{% block content %} +{% if talks_count == 0 %} +
+
No talks have been proposed for this event.
+
+{% endif %} +
+
+{% for presentation in pending_talks %} +
+ + {% csrf_token %} +
+
+
+

{{presentation.talk.title}}

+
+ {{ presentation.talk.speaker }} +
+ + +
+
+
+
+
+
+{% endfor %} +
+{% if accepted_talks %} +
+
+{% for presentation in accepted_talks %} +
+ + {% csrf_token %} +
+
+
+

+ {{presentation.talk.title}} + {% if presentation.status == -1 %} + Declined + {% elif presentation.status == 1 %} + Accepted + {% else %} + Submitted + {% endif %} +

+
+ {{ presentation.talk.speaker }} +
+ +
+
+
+
+
+
+{% endfor %} +
+{% endif %} +{% if declined_talks %} +
+
+{% for presentation in declined_talks %} +
+ + {% csrf_token %} +
+
+
+

+ {{presentation.talk.title}} + {% if presentation.status == -1 %} + Declined + {% elif presentation.status == 1 %} + Accepted + {% else %} + Submitted + {% endif %} +

+
+ {{ presentation.talk.speaker }} +
+ +
+
+
+
+
+
+{% endfor %} +
+{% endif %} +
+
+ Done +
+
+
+ +{% endblock %} + diff --git a/get_together/templates/get_together/events/show_event.html b/get_together/templates/get_together/events/show_event.html index 5380b49..74530f4 100644 --- a/get_together/templates/get_together/events/show_event.html +++ b/get_together/templates/get_together/events/show_event.html @@ -94,7 +94,7 @@ {% endif %} @@ -155,6 +155,9 @@
{{presentation.talk.title}} by {{presentation.talk.speaker.user}}, {{presentation.talk.speaker.title}}
{% endfor %} Propose a talk + {% if pending_presentations %} + {{pending_presentations}} proposed talks + {% endif %} {% endif %} diff --git a/get_together/views/events.py b/get_together/views/events.py index 6d54f85..64fb18f 100644 --- a/get_together/views/events.py +++ b/get_together/views/events.py @@ -66,6 +66,7 @@ def show_event(request, event_id, event_slug): 'is_attending': request.user.profile in event.attendees.all(), 'attendee_list': Attendee.objects.filter(event=event), 'presentation_list': event.presentations.filter(status=Presentation.ACCEPTED).order_by('start_time'), + 'pending_presentations': event.presentations.filter(status=Presentation.PROPOSED).count(), 'can_edit_event': request.user.profile.can_edit_event(event), } return render(request, 'get_together/events/show_event.html', context) diff --git a/get_together/views/speakers.py b/get_together/views/speakers.py index 41dd20e..96d7938 100644 --- a/get_together/views/speakers.py +++ b/get_together/views/speakers.py @@ -1,5 +1,5 @@ from django.utils.translation import ugettext_lazy as _ - +from django.utils.safestring import mark_safe from django.contrib import messages from django.contrib.auth import logout as logout_user from django.shortcuts import render, redirect, get_object_or_404 @@ -210,7 +210,7 @@ def delete_talk(request, talk_id): def propose_event_talk(request, event_id): event = get_object_or_404(Event, id=event_id) if not event.team.is_premium: - messages.add_message(request, messages.ERROR, message=_("You can not propose a talk to this team's events.")) + messages.add_message(request, messages.ERROR, message=_("You can not manage talks for this event.")) return redirect(event.get_absolute_url()) if request.method == 'GET': @@ -242,6 +242,27 @@ def propose_event_talk(request, event_id): redirect('home') def schedule_event_talks(request, event_id): - pass + event = get_object_or_404(Event, id=event_id) + if not event.team.is_premium: + messages.add_message(request, messages.ERROR, message=mark_safe(_('Upgrade this team to a Premium account to use this feature.'))) + return redirect(event.get_absolute_url()) + if request.method == 'POST': + presentation = get_object_or_404(Presentation, id=request.POST.get('presentation_id')) + if request.POST.get('action') == 'accept': + presentation.status = Presentation.ACCEPTED + elif request.POST.get('action') == 'decline': + presentation.status = Presentation.DECLINED + elif request.POST.get('action') == 'propose': + presentation.status = Presentation.PROPOSED + presentation.save() + + context = { + 'event': event, + 'talks_count': event.presentations.count(), + 'accepted_talks': event.presentations.filter(status=Presentation.ACCEPTED).order_by('start_time'), + 'pending_talks': event.presentations.filter(status=Presentation.PROPOSED).order_by('start_time'), + 'declined_talks': event.presentations.filter(status=Presentation.DECLINED).order_by('start_time'), + } + return render(request, 'get_together/events/schedule_event_talks.html', context)