Adding ics button, also some ScheduleView refactor.
This commit is contained in:
parent
5e322472e2
commit
222b995766
|
@ -4,7 +4,7 @@
|
||||||
{% block program_content %}
|
{% block program_content %}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-12">
|
||||||
<form method="get" id="filter" class="form-inline">
|
<form method="get" id="filter" class="form-inline">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<select id="day" name="day" class="form-control filter-control">
|
<select id="day" name="day" class="form-control filter-control">
|
||||||
|
@ -35,6 +35,10 @@
|
||||||
<option value="{{ loc.slug }}" {% if location and location == loc %}selected{% endif %}>&#x{{ loc.icon }}; {{ loc.name }}</option>
|
<option value="{{ loc.slug }}" {% if location and location == loc %}selected{% endif %}>&#x{{ loc.icon }}; {{ loc.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<a href="{% url 'ics_view' camp_slug=camp.slug %}{{ get_string }}" class="btn btn-default form-control filter-control">
|
||||||
|
<i class="fa fa-calendar"></i> ICS file for this filter
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -230,33 +230,41 @@ class ScheduleView(CampViewMixin, TemplateView):
|
||||||
return 'schedule_overview.html'
|
return 'schedule_overview.html'
|
||||||
|
|
||||||
def get_context_data(self, *args, **kwargs):
|
def get_context_data(self, *args, **kwargs):
|
||||||
if 'type' in self.request.GET:
|
context = super(ScheduleView, self).get_context_data(**kwargs)
|
||||||
|
eventinstances = models.EventInstance.objects.filter(event__in=self.camp.events.all())
|
||||||
|
type_slug = self.request.GET.get('type', None)
|
||||||
|
location_slug = self.request.GET.get('location', None)
|
||||||
|
|
||||||
|
if type_slug:
|
||||||
try:
|
try:
|
||||||
eventtype = models.EventType.objects.get(
|
eventtype = models.EventType.objects.get(
|
||||||
slug=self.request.GET['type']
|
slug=type_slug
|
||||||
)
|
)
|
||||||
except models.EventType.DoesNotExist:
|
except models.EventType.DoesNotExist:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
if 'location' in self.request.GET:
|
context['eventtype'] = eventtype
|
||||||
|
context['get_string'] = '?type={}'.format(type_slug)
|
||||||
|
eventinstances = eventinstances.filter(event__event_type=eventtype)
|
||||||
|
|
||||||
|
if location_slug:
|
||||||
try:
|
try:
|
||||||
eventlocation = models.EventLocation.objects.get(
|
eventlocation = models.EventLocation.objects.get(
|
||||||
slug=self.request.GET['location'],
|
slug=location_slug,
|
||||||
camp=self.camp,
|
camp=self.camp,
|
||||||
)
|
)
|
||||||
except models.EventLocation.DoesNotExist:
|
except models.EventLocation.DoesNotExist:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
context = super(ScheduleView, self).get_context_data(**kwargs)
|
|
||||||
eventinstances = models.EventInstance.objects.filter(event__in=self.camp.events.all())
|
|
||||||
|
|
||||||
if 'type' in self.request.GET:
|
|
||||||
context['eventtype'] = eventtype
|
|
||||||
eventinstances = eventinstances.filter(event__event_type=eventtype)
|
|
||||||
|
|
||||||
if 'location' in self.request.GET:
|
|
||||||
context['location'] = eventlocation
|
context['location'] = eventlocation
|
||||||
|
get_part = 'location={}'.format(location_slug)
|
||||||
|
if 'get_string' in context:
|
||||||
|
context['get_string'] = context['get_string'] + '&{}'.format(get_part)
|
||||||
|
else:
|
||||||
|
context['get_string'] = '?{}'.format(get_part)
|
||||||
|
|
||||||
eventinstances = eventinstances.filter(location=eventlocation)
|
eventinstances = eventinstances.filter(location=eventlocation)
|
||||||
|
|
||||||
context['eventinstances'] = eventinstances
|
context['eventinstances'] = eventinstances
|
||||||
|
|
||||||
# Do stuff if we are dealing with a day schedule
|
# Do stuff if we are dealing with a day schedule
|
||||||
|
|
Loading…
Reference in a new issue