Program pages are beginning to look like something
This commit is contained in:
parent
7a78c4f9d6
commit
e8476bea51
|
@ -113,3 +113,10 @@ footer {
|
||||||
.nav li a {
|
.nav li a {
|
||||||
padding: 30px 7px;
|
padding: 30px 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.event {
|
||||||
|
width: 100px;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 5px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
19
camps/migrations/0006_auto_20160804_1705.py
Normal file
19
camps/migrations/0006_auto_20160804_1705.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.6 on 2016-08-04 17:05
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('camps', '0005_auto_20160510_2011'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='day',
|
||||||
|
options={'ordering': ['date'], 'verbose_name': 'Day', 'verbose_name_plural': 'Days'},
|
||||||
|
),
|
||||||
|
]
|
|
@ -8,6 +8,15 @@ class EventTypeAdmin(admin.ModelAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Speaker)
|
||||||
|
class SpeakerAdmin(admin.ModelAdmin):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SpeakerInline(admin.StackedInline):
|
||||||
|
model = Speaker.events.through
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Event)
|
@admin.register(Event)
|
||||||
class EventAdmin(admin.ModelAdmin):
|
class EventAdmin(admin.ModelAdmin):
|
||||||
list_display = [
|
list_display = [
|
||||||
|
@ -15,7 +24,7 @@ class EventAdmin(admin.ModelAdmin):
|
||||||
'event_type',
|
'event_type',
|
||||||
'get_days',
|
'get_days',
|
||||||
'start',
|
'start',
|
||||||
'end'
|
'end',
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_days(self, obj):
|
def get_days(self, obj):
|
||||||
|
@ -24,9 +33,9 @@ class EventAdmin(admin.ModelAdmin):
|
||||||
for day in obj.days.all()
|
for day in obj.days.all()
|
||||||
])
|
])
|
||||||
|
|
||||||
|
inlines = [
|
||||||
@admin.register(Speaker)
|
SpeakerInline
|
||||||
class SpeakerAdmin(admin.ModelAdmin):
|
]
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
21
program/migrations/0002_eventtype_color.py
Normal file
21
program/migrations/0002_eventtype_color.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.6 on 2016-08-04 17:05
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('program', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='eventtype',
|
||||||
|
name='color',
|
||||||
|
field=models.CharField(default='#ff0000', max_length=50),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
20
program/migrations/0003_eventtype_light_writing.py
Normal file
20
program/migrations/0003_eventtype_light_writing.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.6 on 2016-08-04 17:11
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('program', '0002_eventtype_color'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='eventtype',
|
||||||
|
name='light_writing',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
20
program/migrations/0004_auto_20160804_1712.py
Normal file
20
program/migrations/0004_auto_20160804_1712.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.6 on 2016-08-04 17:12
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('program', '0003_eventtype_light_writing'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='eventtype',
|
||||||
|
old_name='light_writing',
|
||||||
|
new_name='light_text',
|
||||||
|
),
|
||||||
|
]
|
|
@ -8,6 +8,8 @@ class EventType(CreatedUpdatedModel):
|
||||||
""" Every event needs to have a type. """
|
""" Every event needs to have a type. """
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
slug = models.SlugField()
|
slug = models.SlugField()
|
||||||
|
color = models.CharField(max_length=50)
|
||||||
|
light_text = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -34,7 +36,8 @@ class Speaker(CreatedUpdatedModel):
|
||||||
events = models.ManyToManyField(
|
events = models.ManyToManyField(
|
||||||
Event,
|
Event,
|
||||||
related_name='speakers',
|
related_name='speakers',
|
||||||
related_query_name='speaker'
|
related_query_name='speaker',
|
||||||
|
blank=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
{% for day, events in days.items %}
|
|
||||||
<div class="row">
|
|
||||||
{{ day }} <br />
|
|
||||||
{% for event in events %}
|
|
||||||
<div class="btn btn-default">
|
|
||||||
{{ event }}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
<hr />
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
|
23
program/templates/program_base.html
Normal file
23
program/templates/program_base.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<a href="{% url 'program:index' %}" class="btn btn-default" style="display: inline-block; padding: 5px;">
|
||||||
|
Overview
|
||||||
|
</a>
|
||||||
|
{% for day in days %}
|
||||||
|
{% with day.date|date:"m" as month_padded %}
|
||||||
|
{% with day.date|date:"d" as day_padded %}
|
||||||
|
<a href="{% url 'program:day' year=day.date.year month=month_padded day=day_padded %}" class="btn btn-default" style="display: inline-block; padding: 5px;">
|
||||||
|
{{ day.date|date:"l" }}
|
||||||
|
</a>
|
||||||
|
{% endwith %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
{% block program_content %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% endblock %}
|
9
program/templates/program_day.html
Normal file
9
program/templates/program_day.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{% extends 'program_base.html' %}
|
||||||
|
|
||||||
|
{% block program_content %}
|
||||||
|
|
||||||
|
{% for event in events %}
|
||||||
|
{{ event }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endblock %}
|
30
program/templates/program_overview.html
Normal file
30
program/templates/program_overview.html
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{% extends 'program_base.html' %}
|
||||||
|
|
||||||
|
{% block program_content %}
|
||||||
|
|
||||||
|
<a href="{% url 'program:index' %}" style="background-color: black; border: 0; color: white; display: inline-block; padding: 5px;">
|
||||||
|
All
|
||||||
|
</a>
|
||||||
|
{% for event_type in event_types %}
|
||||||
|
<a href="{% url 'program:index' %}?type={{ event_type.slug }}" style="background-color: {{ event_type.color }}; border: 0; {% if event_type.light_text %}color: white;{% endif %}; display: inline-block; padding: 5px;">
|
||||||
|
{{ event_type.name }}
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
{% for day, events in day_events.items %}
|
||||||
|
{{ day.date|date:"D d/m" }} <br />
|
||||||
|
<div style="display: flex; flex-wrap: wrap;">
|
||||||
|
{% for event in events %}
|
||||||
|
<div class="event"
|
||||||
|
style="background-color: {{ event.event_type.color }}; border: 0; {% if event.event_type.light_text %}color: white;{% endif %};">
|
||||||
|
<small>{{ event.start|date:"H:i" }} - {{ event.end|date:"H:i" }}</small>
|
||||||
|
{{ event }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -2,5 +2,6 @@ from django.conf.urls import url
|
||||||
from views import *
|
from views import *
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', ProgramView.as_view(), name='index')
|
url(r'^(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})$', ProgramDayView.as_view(), name='day'),
|
||||||
|
url(r'^$', ProgramOverviewView.as_view(), name='index'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,26 +1,59 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from django.views.generic import ListView
|
import datetime
|
||||||
|
from django.views.generic import ListView, TemplateView
|
||||||
|
|
||||||
from camps.models import Day
|
from camps.models import Day
|
||||||
from . import models
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
class ProgramView(ListView):
|
class ProgramOverviewView(ListView):
|
||||||
model = models.Event
|
model = models.Event
|
||||||
template_name = 'program.html'
|
template_name = 'program_overview.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(
|
context = super(
|
||||||
ProgramView, self
|
ProgramOverviewView, self
|
||||||
).get_context_data(**kwargs)
|
).get_context_data(**kwargs)
|
||||||
|
|
||||||
days = Day.objects.all()
|
days = Day.objects.all()
|
||||||
|
context['days'] = days
|
||||||
|
|
||||||
context['days'] = OrderedDict([
|
filter = {}
|
||||||
(day, self.get_queryset().filter(days__in=[day]))
|
if 'type' in self.request.GET:
|
||||||
|
event_type = self.request.GET['type']
|
||||||
|
filter["event_type__slug"] = event_type
|
||||||
|
|
||||||
|
context['day_events'] = OrderedDict([
|
||||||
|
(
|
||||||
|
day,
|
||||||
|
self.get_queryset().filter(
|
||||||
|
days__in=[day],
|
||||||
|
**filter
|
||||||
|
).order_by(
|
||||||
|
'start'
|
||||||
|
)
|
||||||
|
)
|
||||||
for day in days
|
for day in days
|
||||||
])
|
])
|
||||||
|
|
||||||
|
context['event_types'] = models.EventType.objects.all()
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class ProgramDayView(TemplateView):
|
||||||
|
template_name = 'program_day.html'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(ProgramDayView, self).get_context_data(**kwargs)
|
||||||
|
year = int(kwargs['year'])
|
||||||
|
month = int(kwargs['month'])
|
||||||
|
day = int(kwargs['day'])
|
||||||
|
date = datetime.date(year=year, month=month, day=day)
|
||||||
|
day = Day.objects.filter(date=date)
|
||||||
|
context['events'] = models.Event.objects.filter(days=day)
|
||||||
|
context['event_types'] = models.EventType.objects.all()
|
||||||
|
context['days'] = Day.objects.filter(date__year=year)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue