Add ability to accept or decline proposed talks
This commit is contained in:
parent
f5ac0c2fdd
commit
a81c9fddf7
7 changed files with 144 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -29,6 +29,7 @@ ALLOWED_HOSTS = []
|
|||
SITE_ID=1
|
||||
ADMINS = [ 'mhall119' ]
|
||||
|
||||
EVENTS_TEAMS_DEFAULT_PREMIUM=False
|
||||
|
||||
# Application definition
|
||||
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
{% extends "get_together/base.html" %}
|
||||
{% load static tz %}
|
||||
|
||||
{% block styles %}
|
||||
<link href="{% static 'css/bootstrap-album.css' %}" rel="stylesheet"/>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if talks_count == 0 %}
|
||||
<div class="alerts">
|
||||
<div class="alert alert-info">No talks have been proposed for this event.</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{% for presentation in pending_talks %}
|
||||
<form action="{% url 'schedule-event-talks' event.id %}" method="POST">
|
||||
<input type="hidden" name="presentation_id" value="{{presentation.id}}"/>
|
||||
{% csrf_token %}
|
||||
<div class="col-md-4">
|
||||
<div class="card mb-4 box-shadow" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<p class="card-title" style="height: 2rem;"><strong><a href="{% url 'show-talk' presentation.talk.id %}">{{presentation.talk.title}}</a></strong></p>
|
||||
<div class="card-text">
|
||||
<small class="text-muted mb-1">{{ presentation.talk.speaker }}</small>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-success" type="submit" name="action" value="accept">Accept</button>
|
||||
<button class="btn btn-sm btn-danger" type="submit" name="action" value="decline">Decline</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if accepted_talks %}
|
||||
<hr/>
|
||||
<div class="row">
|
||||
{% for presentation in accepted_talks %}
|
||||
<form action="{% url 'schedule-event-talks' event.id %}" method="POST">
|
||||
<input type="hidden" name="presentation_id" value="{{presentation.id}}"/>
|
||||
{% csrf_token %}
|
||||
<div class="col-md-4">
|
||||
<div class="card mb-4 box-shadow" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<p class="card-title" style="height: 2rem;">
|
||||
<strong><a href="{% url 'show-talk' presentation.talk.id %}">{{presentation.talk.title}}</a></strong>
|
||||
{% if presentation.status == -1 %}
|
||||
<span class="badge badge-danger" >Declined</span>
|
||||
{% elif presentation.status == 1 %}
|
||||
<span class="badge badge-success" >Accepted</span>
|
||||
{% else %}
|
||||
<span class="badge badge-info" >Submitted</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
<div class="card-text">
|
||||
<small class="text-muted mb-1">{{ presentation.talk.speaker }}</small>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-dark" type="submit" name="action" value="propose">Reset</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if declined_talks %}
|
||||
<hr/>
|
||||
<div class="row">
|
||||
{% for presentation in declined_talks %}
|
||||
<form action="{% url 'schedule-event-talks' event.id %}" method="POST">
|
||||
<input type="hidden" name="presentation_id" value="{{presentation.id}}"/>
|
||||
{% csrf_token %}
|
||||
<div class="col-md-4">
|
||||
<div class="card mb-4 box-shadow" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<p class="card-title" style="height: 2rem;">
|
||||
<strong><a href="{% url 'show-talk' presentation.talk.id %}">{{presentation.talk.title}}</a></strong>
|
||||
{% if presentation.status == -1 %}
|
||||
<span class="badge badge-danger" >Declined</span>
|
||||
{% elif presentation.status == 1 %}
|
||||
<span class="badge badge-success" >Accepted</span>
|
||||
{% else %}
|
||||
<span class="badge badge-info" >Submitted</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
<div class="card-text">
|
||||
<small class="text-muted mb-1">{{ presentation.talk.speaker }}</small>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-dark" type="submit" name="action" value="propose">Reset</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<a href="{{event.get_absolute_url}}" class="btn btn-primary">Done</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="editMenuButton">
|
||||
<a href="{% url 'edit-event' event.id %}" class="dropdown-item">Event Details</a>
|
||||
<a href="{% url 'edit-event' event.id %}" class="dropdown-item">Speakers</a>
|
||||
<a href="{% url 'schedule-event-talks' event.id %}" class="dropdown-item">Talks</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -155,6 +155,9 @@
|
|||
<div><a href="{% url 'show-talk' presentation.talk.id %}">{{presentation.talk.title}}</a> by <a href="{% url 'show-profile' presentation.talk.speaker.user.id %}">{{presentation.talk.speaker.user}}</a>, {{presentation.talk.speaker.title}}</div>
|
||||
{% endfor %}
|
||||
<a class="btn btn-primary btn-sm" href="{% url 'propose-event-talk' event.id %}">Propose a talk</a>
|
||||
{% if pending_presentations %}
|
||||
<a class="btn btn-success btn-sm" href="{% url 'schedule-event-talks' event.id %}">{{pending_presentations}} proposed talks</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 <a href="/about/premium">Premium</a> 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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue