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']
def __unicode__(self):
return self.name
return '%s (%s)' % (self.name, self.camp)
def save(self, **kwargs):
if not self.slug:

View file

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

View file

@ -2,17 +2,15 @@
{% 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>
<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 %}
{% endblock schedule_content %}

View file

@ -87,9 +87,19 @@ class ProgramDayView(CampViewMixin, TemplateView):
timeslots.append(timeslot)
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
class EventDetailView(CampViewMixin, DetailView):
model = models.Event
template_name = 'program_event_detail.html'

View file

@ -1,5 +1,6 @@
{% load static from staticfiles %}
{% load bootstrap3 %}
{% load menubutton %}
{% static "" as baseurl %}
<!DOCTYPE html>
@ -33,13 +34,13 @@
</button>
<a class="navbar-brand" href="/">
{% if request.resolver_match.kwargs.camp_slug %}
<img src="{% static camp.logo_small %}" class="img-responsive" />
<img src="{% static camp.logo_small %}" class="img-responsive" />
{% else %}
<img src="{% static 'img/logo-small.png' %}" class="img-responsive" />
{% endif %}
</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="{% url 'news:index' %}">News</a></li>
<li><a href="{% url 'shop:index' %}">Shop</a></li>
@ -51,7 +52,7 @@
{% endfor %}
</ul>
</li>
<li><a href="{% url 'contact' %}">Contact</a></li>
<li><a href="{% url 'contact' %}">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %}
@ -63,19 +64,19 @@
</div>
</div>
</nav>
<div id="main" class="container container-fluid">
{% if camp %}
<div class="row">
<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 {% 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 {% 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 {% 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 {% 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 'camps' %}" href="{% url 'camp_detail' camp_slug=camp.slug %}">{{ camp.title }}</a>
<a class="btn {% menubuttonclass 'info' %}" href="{% url 'info' camp_slug=camp.slug %}">Info</a></li>
<a class="btn {% menubuttonclass 'villages' %}" href="{% url 'village_list' camp_slug=camp.slug %}">Villages</a>
<a class="btn {% menubuttonclass 'program' %}" href="{% url 'schedule_index' camp_slug=camp.slug %}">Schedule</a>
<a class="btn {% menubuttonclass 'sponsors' %}" href="{% url 'sponsors' camp_slug=camp.slug %}">Sponsors</a>
</div>
<p>
</div>
<p>
</div>
{% endif %}
{% bootstrap_messages %}
{% block content %}{% endblock %}
@ -93,3 +94,4 @@
{% bootstrap_javascript jquery=1 %}
</body>
</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"