more fiddling with schedule layout

This commit is contained in:
Thomas Steen Rasmussen 2017-01-23 23:58:41 +01:00
parent 201de12b49
commit 1908c18530
6 changed files with 84 additions and 41 deletions

View file

@ -102,7 +102,7 @@ class Speaker(CreatedUpdatedModel):
ordering = ['name'] ordering = ['name']
def __unicode__(self): def __unicode__(self):
return self.name return '%s (%s)' % (self.name, self.camp)
def save(self, **kwargs): def save(self, **kwargs):
if not self.slug: if not self.slug:

View file

@ -1,28 +1,49 @@
{% extends 'schedule_base.html' %} {% extends 'schedule_base.html' %}
{% block schedule_content %} {% block schedule_content %}
<div class="row">
<a href="{% url 'schedule_index' camp_slug=camp.slug %}" class="btn btn-default" style="display: inline-block; padding: 5px;">Overview</a> <div class="btn-group btn-group-justified">
{% for day in camp.camp_days %} <a href="{% url 'schedule_index' camp_slug=camp.slug %}{% if eventtype %}?type={{ eventtype.slug }}{% endif %}" class="btn {% if urlyear %}btn-default{% else %}btn-primary{% endif %}">Overview</a>
{% for day in camp.camp_days %}
{% with day.lower.date|date:"m" as month_padded %} {% with day.lower.date|date:"m" as month_padded %}
{% with day.lower.date|date:"d" as day_padded %} {% with day.lower.date|date:"d" as day_padded %}
<a href="{% url 'schedule_day' camp_slug=camp.slug year=day.lower.date.year month=month_padded day=day_padded %}" class="btn btn-default" style="display: inline-block; padding: 5px;"> <a href="{% url 'schedule_day' camp_slug=camp.slug year=day.lower.date.year month=month_padded day=day_padded %}{% if eventtype %}?type={{ eventtype.slug }}{% endif %}" class="btn btn-sm {% if urlyear and urlyear|add:"0" == day.lower.date.year and urlmonth == month_padded and urlday == day_padded %}btn-primary{% else %}btn-default{% endif %}">
{{ day.lower.date|date:"l" }} {{ day.lower.date|date:"l" }}
</a> </a>
{% endwith %} {% endwith %}
{% endwith %} {% endwith %}
{% endfor %} {% endfor %}
</div>
</div>
<hr /> <p>
<a href="{% url 'schedule_index' camp_slug=camp.slug %}" style="background-color: black; border: 0; color: white; display: inline-block; padding: 5px;"> <div class="row">
All <div class="btn-group btn-group-justified">
</a>
{% for event_type in camp.event_types %} {% if not urlyear %}
<a href="{% url 'schedule_index' camp_slug=camp.slug %}?type={{ event_type.slug }}" style="background-color: {{ event_type.color }}; border: 0; color: {% if event_type.light_text %}white{% else %}black{% endif %}; display: inline-block; padding: 5px;"> <a href="{% url 'schedule_index' camp_slug=camp.slug %}" style="background-color: black; border: 0; color: white;" class="btn">
{{ event_type.name }} {% if eventtype %}All{% else %}<b>All</b>{% endif %}
</a> </a>
{% endfor %} {% else %}
<a href="{% url 'schedule_day' camp_slug=camp.slug year=urlyear month=urlmonth day=urlday %}" style="background-color: black; border: 0; color: white;" class="btn">
{% if eventtype %}All{% else %}<b>All</b>{% endif %}
</a>
{% endif %}
{% for event_type in camp.event_types %}
{% if not urlyear %}
<a href="{% url 'schedule_index' camp_slug=camp.slug %}?type={{ event_type.slug }}" style="background-color: {{ event_type.color }}; border: 0; color: {% if event_type.light_text %}white{% else %}black{% endif %};" class="btn">
{% if eventtype and eventtype == event_type %}<b>{{ event_type.name }}</b>{% else %}{{ event_type.name }}{% endif %}
</a>
{% else %}
<a href="{% url 'schedule_day' camp_slug=camp.slug year=urlyear month=urlmonth day=urlday %}?type={{ event_type.slug }}" style="background-color: {{ event_type.color }}; border: 0; color: {% if event_type.light_text %}white{% else %}black{% endif %};" class="btn">
{% if eventtype and eventtype == event_type %}<b>{{ event_type.name }}</b>{% else %}{{ event_type.name }}{% endif %}
</a>
{% endif %}
{% endfor %}
</div>
</div>
<hr /> <hr />

View file

@ -2,17 +2,15 @@
{% block content %} {% block content %}
<hr /> <div class="row">
<div class="btn-group btn-group-justified">
<a href="{% url 'schedule_index' camp_slug=camp.slug %}" class="btn {% if request.resolver_match.url_name == "schedule_index" or urlyear %}btn-primary{% else %}btn-default{% endif %}">Schedule</a>
<a href="{% url 'call_for_speakers' camp_slug=camp.slug %}" class="btn {% if request.resolver_match.url_name == "call_for_speakers" %}btn-primary{% else %}btn-default{% endif %}">Call for Speakers</a>
<a href="{% url 'speaker_index' camp_slug=camp.slug %}" class="btn {% if request.resolver_match.url_name == "speaker_index" %}btn-primary{% else %}btn-default{% endif %}">Speakers</a>
<a href="{% url 'event_index' camp_slug=camp.slug %}" class="btn {% if request.resolver_match.url_name == "event_index" %}btn-primary{% else %}btn-default{% endif %}">Talks &amp; Events</a>
</div>
</div>
<p> <p>
<a href="{% url 'schedule_index' camp_slug=camp.slug %}" class="btn btn-default">Schedule</a>
<a href="{% url 'call_for_speakers' camp_slug=camp.slug %}" class="btn btn-default">Call for Speakers</a>
<a href="{% url 'speaker_index' camp_slug=camp.slug %}" class="btn btn-default">Speakers</a>
<a href="{% url 'event_index' camp_slug=camp.slug %}" class="btn btn-default">Talks &amp; Events</a>
</p>
<hr />
{% block schedule_content %} {% block schedule_content %}
{% endblock schedule_content %} {% endblock schedule_content %}

View file

@ -87,9 +87,19 @@ class ProgramDayView(CampViewMixin, TemplateView):
timeslots.append(timeslot) timeslots.append(timeslot)
context['timeslots'] = timeslots context['timeslots'] = timeslots
# include the components to make the urls
context['urlyear'] = self.kwargs['year']
context['urlmonth'] = self.kwargs['month']
context['urlday'] = self.kwargs['day']
if 'type' in self.request.GET:
context['eventtype'] = models.EventType.objects.get(slug=self.request.GET['type'])
print dir(self.request.resolver_match.func.view_class)
return context return context
class EventDetailView(CampViewMixin, DetailView): class EventDetailView(CampViewMixin, DetailView):
model = models.Event model = models.Event
template_name = 'program_event_detail.html' template_name = 'program_event_detail.html'

View file

@ -1,5 +1,6 @@
{% load static from staticfiles %} {% load static from staticfiles %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load menubutton %}
{% static "" as baseurl %} {% static "" as baseurl %}
<!DOCTYPE html> <!DOCTYPE html>
@ -68,14 +69,14 @@
{% if camp %} {% if camp %}
<div class="row"> <div class="row">
<div class="btn-group btn-group-justified"> <div class="btn-group btn-group-justified">
<a class="btn {% if request.resolver_match.url_name == "camp_detail" %}btn-primary{% else %}btn-default{% endif %}" href="{% url 'camp_detail' camp_slug=camp.slug %}">{{ camp.title }}</a> <a class="btn {% menubuttonclass 'camps' %}" href="{% url 'camp_detail' camp_slug=camp.slug %}">{{ camp.title }}</a>
<a class="btn {% if request.resolver_match.url_name == "info" %}btn-primary{% else %}btn-default{% endif %}" href="{% url 'info' camp_slug=camp.slug %}">Info</a></li> <a class="btn {% menubuttonclass 'info' %}" href="{% url 'info' camp_slug=camp.slug %}">Info</a></li>
<a class="btn {% if request.resolver_match.url_name == "village_list" %}btn-primary{% else %}btn-default{% endif %}" href="{% url 'village_list' camp_slug=camp.slug %}">Villages</a> <a class="btn {% menubuttonclass 'villages' %}" href="{% url 'village_list' camp_slug=camp.slug %}">Villages</a>
<a class="btn {% if request.resolver_match.url_name == "schedule_index" %}btn-primary{% else %}btn-default{% endif %}" href="{% url 'schedule_index' camp_slug=camp.slug %}">Schedule</a> <a class="btn {% menubuttonclass 'program' %}" href="{% url 'schedule_index' camp_slug=camp.slug %}">Schedule</a>
<a class="btn {% if request.resolver_match.url_name == "sponsors" %}btn-primary{% else %}btn-default{% endif %}" href="{% url 'sponsors' camp_slug=camp.slug %}">Sponsors</a> <a class="btn {% menubuttonclass 'sponsors' %}" href="{% url 'sponsors' camp_slug=camp.slug %}">Sponsors</a>
</div>
<p>
</div> </div>
<p>
</div>
{% endif %} {% endif %}
{% bootstrap_messages %} {% bootstrap_messages %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
@ -93,3 +94,4 @@
{% bootstrap_javascript jquery=1 %} {% bootstrap_javascript jquery=1 %}
</body> </body>
</html> </html>

View file

@ -0,0 +1,12 @@
import datetime
from django import template
register = template.Library()
@register.simple_tag(takes_context=True)
def menubuttonclass(context, appname):
if appname == context['request'].resolver_match.func.view_class.__module__.split(".")[0]:
return "btn-primary"
else:
return "btn-default"