Skip to content

Commit 867ac0e

Browse files
authored
Merge pull request #131 from PythonBalkan/timetable
Timetable
2 parents a4e6a87 + ca01b56 commit 867ac0e

10 files changed

Lines changed: 142 additions & 45 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.1.2 on 2018-11-11 18:11
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('conference', '0005_auto_20180804_2148'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='conference',
15+
name='timetable_pdf',
16+
field=models.FileField(blank=True, null=True, upload_to=''),
17+
),
18+
]

pyconbalkan/conference/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class Conference(SingleActiveModel, ModelMeta):
3434
twitter = models.URLField(blank=True, null=True)
3535
instagram = models.URLField(blank=True, null=True)
3636

37+
# timetable
38+
timetable_pdf = models.FileField(blank=True, null=True)
39+
40+
3741
_metadata = {
3842
'title': 'get_meta_title',
3943
'description': 'get_meta_description',

pyconbalkan/core/static/css/components/button.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
.button--yellow {
3636
color: #000;
37-
background-color: #F3D66C;
37+
background-color: #F3D66C !important;
3838
}
3939

4040
.button--blue {

pyconbalkan/core/static/css/components/timetable.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@
5252
font-size: 1.8em;
5353
font-weight: bold;
5454
}
55+
56+
.hidden {
57+
display: none;
58+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$(".btn-room").click(function() {
2+
let roomNumber = this.innerHTML;
3+
$(".btn-room").removeClass('button--yellow');
4+
$(".presentations").addClass('hidden');
5+
$("." + roomNumber).removeClass('hidden');
6+
$(".btn-" + roomNumber).addClass('button--yellow');
7+
});

pyconbalkan/core/templates/includes/header.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
</div>
2222
</li>
2323
<li class="menu__list__item">
24+
{% if conference.timetable_pdf %}
25+
<a class="menu__list__link {% if request.path == conference.timetable_pdf.url %}active{% endif %}" href="{{ conference.timetable_pdf.url }}" role="button">Timetable</a>
26+
{% else %}
2427
<a class="menu__list__link {% if request.path == '/timetable' %}active{% endif %}" href="{% url 'timetable' %}" role="button">Timetable</a>
28+
{% endif %}
2529
</li>
2630
<li class="menu__list__item">
2731
<a class="menu__list__link {% if request.path == '/info' %}active{% endif %}" href="/info" role="button">Info</a>

pyconbalkan/core/views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,3 @@ def home(request):
3030
'meta': conference.first().as_meta(),
3131
}
3232
return render(request, 'home.html', context)
33-
34-
Lines changed: 75 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,84 @@
11
{% extends "base.html" %}
2+
{% load static %}
23

34
{% block main_content %}
4-
5-
{# Timetable #}
6-
7-
<h1 class="title title--yellow mb-xs-40">Timetable</h1>
8-
<hr class="line line--blue line--short line--spaced">
9-
<div class="rooms">
5+
{# Timetable #}
6+
<h1 class="title title--yellow mb-xs-40">Timetable</h1>
7+
<hr class="line line--blue line--short line--spaced">
8+
<div class="rooms">
109
{% if rooms %}
1110
<ul>
12-
{% for room in rooms %}
13-
<li class="button button--blue">{{ room.name }}</li>
14-
{% endfor %}
11+
{% for room in rooms %}
12+
<li class="button button--blue btn-room btn-{{ room.name }}">{{ room.name }}</li>
13+
{% endfor %}
1514
</ul>
1615
{% endif %}
17-
</div>
18-
<div class="presentations">
19-
{% if presentations %}
20-
{% for presentation in presentations %}
21-
<div class="presentation">
22-
<div class="pre-side"><img src="../static/img/clock.svg" width="20px" height="20px"></div>
23-
<div class="presentation-card">
24-
<img src={{ presentation.speaker.image }} width="80px" height="80px" alt="avatar">
25-
<div>
26-
<h2 class="name">{{ presentation.speaker.name }}</h2>
27-
<hr/>
28-
<span class="subtitle">{{ presentation.speaker.job }}</span>
29-
</div>
30-
<p class="description">{{ presentation.description }}</p>
31-
</div>
32-
</div>
33-
{% endfor %}
34-
{% else %}
16+
</div>
17+
<div class="presentations main-presentation">
18+
{% if slots %}
19+
{% for slot in slots %}
20+
<div class="presentation">
21+
<div class="pre-side"><img src="../static/img/clock.svg" width="20px" height="20px"></div>
22+
<div class="presentation-card">
23+
<ul>
24+
{% for key, value in DAYS.items %}
25+
{% if key == slot.from_date.date %}
26+
<li class="button button--blue pull-right">{{ value }}, {{ slot.from_date.time }} to {{ slot.to_date.time }}</li>
27+
{% endif %}
28+
{% endfor %}
29+
</ul>
30+
31+
{% if slot.talk.speaker.name %}
32+
<div>
33+
<h2 class="name">{{ slot.talk.speaker.name }}</h2>
34+
<hr/>
35+
{% if slot.talk.speaker.job %}
36+
<span class="subtitle">{{ slot.talk.speaker.job }}</span>
37+
{% endif %}
38+
</div>
39+
{% endif %}
40+
<p class="description">{% if slot.talk.speaker %} {% if slot.talk.type == 0 %} Talk: {% elif slot.talk.type == 1 %} Workshop: {{ slot.talk.description }} {% elif slot.talk.type == 2 %} Keynote: {% endif %} {% endif %} {{ slot.talk.description }}</p>
41+
</div>
42+
</div>
43+
{% endfor %}
44+
{% else %}
3545
<h2 class="title title--white title--medium title--uppercase mt-xs-20">
36-
<span class="featured-letter featured-letter--blue">C</span>oming <span class="featured-letter featured-letter--yellow">S</span>oon
37-
</h2>
38-
{% endif %}
46+
<span class="featured-letter featured-letter--blue">C</span>oming <span class="featured-letter featured-letter--yellow">S</span>oon
47+
</h2>
48+
{% endif %}
49+
</div>
50+
{% if slots_by_rooms %}
51+
{% for room, slots in slots_by_rooms.items %}
52+
<div class="presentations {{ room }} hidden">
53+
{% for slot in slots %}
54+
<div class="presentation">
55+
<div class="pre-side"><img src="../static/img/clock.svg" width="20px" height="20px"></div>
56+
<div class="presentation-card">
57+
<ul>
58+
{% for key, value in DAYS.items %}
59+
{% if key == slot.from_date.date %}
60+
<li class="button button--blue pull-right">{{ value }}, {{ slot.from_date.time }} to {{ slot.to_date.time }}</li>
61+
{% endif %}
62+
{% endfor %}
63+
</ul>
64+
65+
{% if slot.talk.speaker.name %}
66+
<div>
67+
<h2 class="name">{{ slot.talk.speaker.name }}</h2>
68+
<hr/>
69+
{% if slot.talk.speaker.job %}
70+
<span class="subtitle">{{ slot.talk.speaker.job }}</span>
71+
{% endif %}
72+
</div>
73+
{% endif %}
74+
<p class="description">{% if slot.talk.speaker %} {% if slot.talk.type == 0 %} Talk: {% elif slot.talk.type == 1 %} Workshop: {{ slot.talk.description }} {% elif slot.talk.type == 2 %} Keynote: {% endif %} {% endif %} {{ slot.talk.description }}</p>
75+
</div>
3976
</div>
40-
41-
{% endblock %}
77+
{% endfor %}
78+
</div>
79+
{% endfor %}
80+
{% endif %}
81+
{% endblock main_content %}
82+
{% block scripts %}
83+
<script src="{% static 'js/timetable.js' %}" type="text/javascript"></script>
84+
{% endblock %}

pyconbalkan/timetable/views.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
1+
2+
from django.shortcuts import render
13
from rest_framework import viewsets
2-
from pyconbalkan.timetable.models import Timetable, Presentation, Room
4+
5+
from pyconbalkan.timetable.models import Room, Slot, Timetable
36
from pyconbalkan.timetable.serializers import TimetableSerializer
4-
from django.shortcuts import render
57

68

79
class TimetableViewSet(viewsets.ModelViewSet):
810
queryset = Timetable.objects.all()
9-
serializer_class = TimetableSerializer
11+
serializer_class = TimetableSerializer
1012

1113

1214
def timetable_view(request):
13-
presentations = Presentation.objects.all()
15+
slots_by_rooms = {}
1416
rooms = Room.objects.all()
15-
context = {'presentations': presentations, 'rooms': rooms}
17+
slots = Slot.objects.all()
18+
slots_order_by_date = slots.order_by('from_date')
19+
for room in rooms:
20+
slots_by_rooms[room.name] = slots_order_by_date.filter(room=room)
21+
days_count = 0
22+
DAYS = {}
23+
for slot in slots:
24+
if slot.from_date.date() not in DAYS:
25+
DAYS[slot.from_date.date()] = 'Day {}'.format(days_count + 1)
26+
days_count += 1
27+
context = {
28+
'slots': slots_order_by_date,
29+
'slots_by_rooms': slots_by_rooms,
30+
'rooms': rooms,
31+
'DAYS': DAYS
32+
}
1633
return render(request, 'timetable.html', context)

pyconbalkan/urls.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from django.urls import path
44
from django.views.generic import TemplateView
55
from django.views.static import serve
6-
from markdownx import urls as markdownx
76

7+
from markdownx import urls as markdownx
88
from pyconbalkan.about.api_urls import router as about
99
from pyconbalkan.about.views import about_view
1010
from pyconbalkan.cfp.api_urls import router as cfp
1111
from pyconbalkan.cfp.views import cfp_detail, cfp_list, cfp_view
1212
from pyconbalkan.coc.api_urls import router as coc
13-
from pyconbalkan.coc.views import response_guide, coc_view
13+
from pyconbalkan.coc.views import coc_view, response_guide
1414
from pyconbalkan.conference.api_urls import router as conference
1515
from pyconbalkan.contact.api_urls import router as contact
1616
from pyconbalkan.contact.views import contact_view
@@ -19,11 +19,13 @@
1919
from pyconbalkan.news.api_urls import router as news
2020
from pyconbalkan.news.views import *
2121
from pyconbalkan.organizers.api_urls import router as organizers
22-
from pyconbalkan.organizers.views import organizer_view, volunteers_createview, organizers_list
22+
from pyconbalkan.organizers.views import (organizer_view, organizers_list,
23+
volunteers_createview)
2324
from pyconbalkan.settings import PDF_ROOT
2425
from pyconbalkan.speaker.api_urls import router as speaker
2526
from pyconbalkan.speaker.views import *
2627
from pyconbalkan.sponsors.api_urls import router as sponsors
28+
2729
from pyconbalkan.timetable.views import timetable_view
2830
from pyconbalkan.faq.views import faq_view
2931
from pyconbalkan.faq.api_urls import router as faq
@@ -66,12 +68,12 @@
6668
path('admin/', admin.site.urls),
6769
path('api/', include(router.urls)), # API
6870
path('markdownx/', include(markdownx)),
71+
path('timetable/', timetable_view, name='timetable')
6972
path('faq', faq_view, name='faq'),
7073
path('timetable/', serve, {'path': 'pycon-balkan-2018-timetable.pdf', 'document_root': PDF_ROOT}, name='timetable'),
71-
# path('timetable/', timetable_view, name='timetable')
7274
]
7375

7476
# Add Django site authentication urls (for login, logout, password management)
7577
urlpatterns += [
7678
path('accounts/', include('django.contrib.auth.urls')),
77-
]
79+
]

0 commit comments

Comments
 (0)