show volunteers in staff area

This commit is contained in:
Élie Bouttier 2017-10-30 14:06:08 +01:00
parent 3bec25bcd9
commit c616a6c3fa
7 changed files with 126 additions and 19 deletions

View File

@ -9,7 +9,8 @@ from django.utils.crypto import get_random_string
from django_select2.forms import ModelSelect2MultipleWidget from django_select2.forms import ModelSelect2MultipleWidget
from .models import Participant, Talk, TalkCategory, Track, Tag, Conference, Room, Volunteer from .models import Participant, Talk, TalkCategory, Track, Tag, \
Conference, Room, Volunteer, Activity
ACCEPTATION_CHOICES = [ ACCEPTATION_CHOICES = [
@ -35,6 +36,20 @@ CONFIRMATION_VALUES = [
] ]
class VolunteerFilterForm(forms.Form):
activity = forms.MultipleChoiceField(
required=False,
widget=forms.CheckboxSelectMultiple,
choices=[],
)
def __init__(self, *args, **kwargs):
site = kwargs.pop('site')
super().__init__(*args, **kwargs)
activities = Activity.objects.filter(site=site)
self.fields['activity'].choices = activities.values_list('slug', 'name')
class TalkForm(forms.ModelForm): class TalkForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
categories = kwargs.pop('categories') categories = kwargs.pop('categories')

View File

@ -43,12 +43,6 @@ class Conference(models.Model):
custom_css = models.TextField(blank=True) custom_css = models.TextField(blank=True)
external_css_link = models.URLField(blank=True) external_css_link = models.URLField(blank=True)
#subscriptions_open = models.BooleanField(default=False) # workshop subscription
#def cfp_is_open(self):
# events = Event.objects.filter(site=self.site)
# return any(map(lambda x: x.is_open(), events))
def volunteers_enrollment_is_open(self): def volunteers_enrollment_is_open(self):
now = timezone.now() now = timezone.now()
opening = self.volunteers_opening_date opening = self.volunteers_opening_date

View File

@ -12,6 +12,7 @@
{% endcomment %} {% endcomment %}
<li{% block talkstab %}{% endblock %}><a href="{% url 'talk-list' %}"><span class="glyphicon glyphicon-blackboard"></span>&nbsp;{% trans "Talks" %}</a></li> <li{% block talkstab %}{% endblock %}><a href="{% url 'talk-list' %}"><span class="glyphicon glyphicon-blackboard"></span>&nbsp;{% trans "Talks" %}</a></li>
<li{% block speakerstab %}{% endblock %}><a href="{% url 'participant-list' %}"><span class="glyphicon glyphicon-bullhorn"></span>&nbsp;{% trans "Speakers" %}</a></li> <li{% block speakerstab %}{% endblock %}><a href="{% url 'participant-list' %}"><span class="glyphicon glyphicon-bullhorn"></span>&nbsp;{% trans "Speakers" %}</a></li>
<li{% block volunteerstab %}{% endblock %}><a href="{% url 'volunteer-list' %}"><span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{% trans "Volunteers" %}</a></li>
<li{% block trackstab %}{% endblock %}><a href="{% url 'track-list' %}"><span class="glyphicon glyphicon-screenshot"></span>&nbsp;{% trans "Tracks" %}</a></li> <li{% block trackstab %}{% endblock %}><a href="{% url 'track-list' %}"><span class="glyphicon glyphicon-screenshot"></span>&nbsp;{% trans "Tracks" %}</a></li>
<li{% block roomstab %}{% endblock %}><a href="{% url 'room-list' %}"><span class="glyphicon glyphicon-tent"></span>&nbsp;{% trans "Rooms" %}</a></li> <li{% block roomstab %}{% endblock %}><a href="{% url 'room-list' %}"><span class="glyphicon glyphicon-tent"></span>&nbsp;{% trans "Rooms" %}</a></li>
<li{% block scheduletab %}{% endblock %}><a href="{% url 'staff-schedule' %}"><span class="glyphicon glyphicon-calendar"></span>&nbsp;{% trans "Schedule" %}</a></li> <li{% block scheduletab %}{% endblock %}><a href="{% url 'staff-schedule' %}"><span class="glyphicon glyphicon-calendar"></span>&nbsp;{% trans "Schedule" %}</a></li>

View File

@ -0,0 +1,73 @@
{% extends 'cfp/staff/base.html' %}
{% load bootstrap3 i18n %}
{% block volunteerstab %} class="active"{% endblock %}
{% block content %}
<h1>{% trans "Volunteers" %}</h1>
<a class="btn btn-primary" role="button" data-toggle="collapse" href="#filter" aria-expanded="{{ show_filters|yesno:"true,false" }}" aria-controles="filter">{% trans "Show filtering options…" %}</a>
<br /><br />
<div class="collapse{{ show_filters|yesno:" in," }}" id="filter">
<div class="well">
<form class="form-horizontal" method="get">
{% bootstrap_form filter_form %}
<input type="submit" class="btn btn-success" value="{% trans "Filter" %}">
</form>
</div>
</div>
<table class="table table-bordered table-hover">
<caption>{% trans "Total:" %} {{ volunteer_list|length }} {% trans "volunteer" %}{{ volunteer_list|length|pluralize }}
</caption>
<thead>
<tr>
<th class="text-center">{% trans "Name" %}</th>
<th class="text-center">{% trans "Email" %}</th>
<th class="text-center">{% trans "Activities" %}</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="7">{% trans "Contact:" %} <a href="{{ contact_link }}">{% trans "link" %}</a></td>
</tr>
</tfoot>
{% for volunteer in volunteer_list %}
{% if forloop.first %}
<tbody>
{% endif %}
<tr>
<td>{{ volunteer.name }}</td>
<td>{{ volunteer.email }}</td>
<td>
{% for activity in volunteer.activities.all %}
<span class="badge">{{ activity }}</span>
{% endfor %}
</td>
</tr>
{% if forloop.last %}
</tbody>
{% endif %}
{% endfor %}
</table>
{% endblock %}
{% block js_end %}
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".clickable-row").click(function() {
window.location = $(this).data("href");
});
var anchor = window.location.hash.replace("#", "");
if (anchor == "filter") {
$("#filter").collapse('show');
}
});
</script>
{% endblock %}

View File

@ -33,6 +33,7 @@ urlpatterns = [
url(r'^staff/rooms/add/$', views.RoomCreate.as_view(), name='room-add'), url(r'^staff/rooms/add/$', views.RoomCreate.as_view(), name='room-add'),
url(r'^staff/rooms/(?P<slug>[-\w]+)/$', views.RoomDetail.as_view(), name='room-details'), url(r'^staff/rooms/(?P<slug>[-\w]+)/$', views.RoomDetail.as_view(), name='room-details'),
url(r'^staff/rooms/(?P<slug>[-\w]+)/edit/$', views.RoomUpdate.as_view(), name='room-edit'), url(r'^staff/rooms/(?P<slug>[-\w]+)/edit/$', views.RoomUpdate.as_view(), name='room-edit'),
url(r'^staff/volunteers/$', views.volunteer_list, name='volunteer-list'),
url(r'^staff/add-user/$', views.create_user, name='create-user'), url(r'^staff/add-user/$', views.create_user, name='create-user'),
url(r'^staff/schedule/((?P<program_format>[\w]+)/)?$', views.staff_schedule, name='staff-schedule'), url(r'^staff/schedule/((?P<program_format>[\w]+)/)?$', views.staff_schedule, name='staff-schedule'),
url(r'^staff/select2/$', views.Select2View.as_view(), name='django_select2-json'), url(r'^staff/select2/$', views.Select2View.as_view(), name='django_select2-json'),

View File

@ -25,7 +25,8 @@ from .utils import is_staff
from .models import Participant, Talk, TalkCategory, Vote, Track, Tag, Room, Volunteer, Activity from .models import Participant, Talk, TalkCategory, Vote, Track, Tag, Room, Volunteer, Activity
from .forms import TalkForm, TalkStaffForm, TalkFilterForm, TalkActionForm, \ from .forms import TalkForm, TalkStaffForm, TalkFilterForm, TalkActionForm, \
ParticipantForm, ParticipantStaffForm, ParticipantFilterForm, \ ParticipantForm, ParticipantStaffForm, ParticipantFilterForm, \
ConferenceForm, CreateUserForm, TrackForm, RoomForm, VolunteerForm, \ ConferenceForm, CreateUserForm, TrackForm, RoomForm, \
VolunteerForm, VolunteerFilterForm, \
ACCEPTATION_VALUES, CONFIRMATION_VALUES ACCEPTATION_VALUES, CONFIRMATION_VALUES
@ -76,8 +77,28 @@ def volunteer_activity(request, volunteer_id, activity, join):
return redirect(reverse('volunteer', kwargs=dict(volunteer_id=volunteer.token))) return redirect(reverse('volunteer', kwargs=dict(volunteer_id=volunteer.token)))
def talk_proposal(request, talk_id=None, participant_id=None): @staff_required
def volunteer_list(request):
site = request.conference.site
show_filters = False
filter_form = VolunteerFilterForm(request.GET or None, site=site)
# Filtering
volunteers = Volunteer.objects.filter(site=site, activities__isnull=False).order_by('pk').distinct()
if filter_form.is_valid():
data = filter_form.cleaned_data
if len(data['activity']):
show_filters = True
volunteers = volunteers.filter(activities__slug__in=data['activity'])
contact_link = 'mailto:' + ','.join([volunteer.email for volunteer in volunteers.all()])
return render(request, 'cfp/staff/volunteer_list.html', {
'volunteer_list': volunteers,
'filter_form': filter_form,
'show_filters': show_filters,
'contact_link': contact_link,
})
def talk_proposal(request, talk_id=None, participant_id=None):
conference = request.conference conference = request.conference
site = conference.site site = conference.site
if is_staff(request, request.user): if is_staff(request, request.user):

View File

@ -17,16 +17,18 @@
</div> </div>
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
{% if conference.home %} {% if conference.home %}<li{% block hometab %}{% endblock %}>
<li{% block hometab %}{% endblock %}><a href="{% url 'home' %}"><span class="glyphicon glyphicon-home"></span>&nbsp;{% trans "Home" %}</a></li> <a href="{% url 'home' %}"><span class="glyphicon glyphicon-home"></span>&nbsp;{% trans "Home" %}</a>
{% endif %} </li>{% endif %}
<li{% block proposetab %}{% endblock %}><a href="{% url 'talk-proposal' %}"><span class="glyphicon glyphicon-bullhorn"></span>&nbsp;{% trans "Call for participation" %}</a></li> <li{% block proposetab %}{% endblock %}>
{% if conference.schedule_available %} <a href="{% url 'talk-proposal' %}"><span class="glyphicon glyphicon-bullhorn"></span>&nbsp;{% trans "Call for participation" %}</a>
<li{% block publicscheduletab %}{% endblock %}><a href="{% url 'public-schedule' %}"><span class="glyphicon glyphicon-calendar"></span>&nbsp;{% trans "Schedule" %}</a></li> </li>
{% endif %} {% if conference.schedule_available %}<li{% block publicscheduletab %}{% endblock %}>
{% if conference.volunteers_enrolement_is_open %} <a href="{% url 'public-schedule' %}"><span class="glyphicon glyphicon-calendar"></span>&nbsp;{% trans "Schedule" %}</a>
<li{% block volunteerstab %}{% endblock %}><a href="{% url 'volunteer-enrole' %}"><span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{% trans "Volunteers" %}</a></li> </li>{% endif %}
{% endif %} {% if conference.volunteers_enrollment_is_open %}<li{% block volunteerstab %}{% endblock %}>
<a href="{% url 'volunteer-enrole' %}"><span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{% trans "Volunteers" %}</a>
</li>{% endif %}
{% comment %} {% comment %}
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
<li{% block exhibitortab %}{% endblock %}><a href="{% url 'participate-as-speaker' %}"><span class="glyphicon glyphicon-bullhorn"></span>&nbsp;{% trans "Exhibitor" %}</a></li> <li{% block exhibitortab %}{% endblock %}><a href="{% url 'participate-as-speaker' %}"><span class="glyphicon glyphicon-bullhorn"></span>&nbsp;{% trans "Exhibitor" %}</a></li>