working on speaker and event list

This commit is contained in:
Thomas Steen Rasmussen 2016-08-08 19:36:13 +02:00
parent 562356cf6b
commit 4da3b61a89
8 changed files with 66 additions and 8 deletions

View file

@ -44,7 +44,7 @@
<li><a href="{% url 'shop:index' %}">Shop</a></li> <li><a href="{% url 'shop:index' %}">Shop</a></li>
{% endif %} {% endif %}
<li><a href="{% url 'villages:list' %}">Villages</a></li> <li><a href="{% url 'villages:list' %}">Villages</a></li>
<li><a href="{% url 'call-for-speakers' %}">Speakers</a></li> <li><a href="{% url 'schedule:index' %}">Schedule</a></li>
<li><a href="{% url 'call-for-sponsors' %}">Sponsors</a></li> <li><a href="{% url 'call-for-sponsors' %}">Sponsors</a></li>
<li><a href="{% url 'contact' %}">Contact</a></li> <li><a href="{% url 'contact' %}">Contact</a></li>
{% if user.is_authenticated %} {% if user.is_authenticated %}

View file

@ -79,8 +79,8 @@ urlpatterns = [
include('villages.urls', namespace='villages') include('villages.urls', namespace='villages')
), ),
url( url(
r'^program/', r'^schedule/',
include('program.urls', namespace='program') include('program.urls', namespace='schedule')
), ),
url(r'^accounts/', include('allauth.urls')), url(r'^accounts/', include('allauth.urls')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),

View file

@ -23,9 +23,12 @@ class Event(CreatedUpdatedModel):
slug = models.SlugField(blank=True, max_length=255) slug = models.SlugField(blank=True, max_length=255)
abstract = models.TextField() abstract = models.TextField()
event_type = models.ForeignKey(EventType) event_type = models.ForeignKey(EventType)
days = models.ManyToManyField('camps.Day') days = models.ManyToManyField('camps.Day', null=True, blank=True)
start = models.TimeField() start = models.TimeField(null=True, blank=True)
end = models.TimeField() end = models.TimeField(null=True, blank=True)
class Meta:
ordering = ['title']
def __str__(self): def __str__(self):
return self.title return self.title
@ -41,6 +44,7 @@ class Speaker(CreatedUpdatedModel):
name = models.CharField(max_length=150) name = models.CharField(max_length=150)
biography = models.TextField() biography = models.TextField()
picture = models.ImageField(null=True, blank=True) picture = models.ImageField(null=True, blank=True)
slug = models.SlugField(blank=True, max_length=255)
events = models.ManyToManyField( events = models.ManyToManyField(
Event, Event,
related_name='speakers', related_name='speakers',
@ -48,5 +52,14 @@ class Speaker(CreatedUpdatedModel):
blank=True, blank=True,
) )
class Meta:
ordering = ['name']
def __str__(self): def __str__(self):
return self.name return self.name
def save(self, **kwargs):
if not self.slug:
self.slug = slugify(self.name)
super(Event, self).save(**kwargs)

View file

@ -0,0 +1,16 @@
{% extends 'base.html' %}
{% block content %}
<p class="lead">
An alphabetical list of all talks, workshops, keynotes and other events
at BornHack 2016.
</p>
<div class="list-group">
{% for event in event_list %}
<a href="{% url 'program:event' slug=event.slug %}" class="list-group-item">
{{ event.title }}
</a>
{% endfor %}
</div>
{% endblock content %}

View file

@ -1,6 +1,9 @@
{% extends 'program_base.html' %} {% extends 'program_base.html' %}
{% block program_content %} {% block program_content %}
<a href="{% url 'call-for-speakers' %}" class="btn">Call for Speakers</a>
<a href="{% url 'program:speakers_index' %}" class="btn">Speakers</a>
<a href="{% url 'program:events_index' %}" class="btn">Talks &amp; Events</a>
<a href="{% url 'program:index' %}" style="background-color: black; border: 0; color: white; display: inline-block; padding: 5px;"> <a href="{% url 'program:index' %}" style="background-color: black; border: 0; color: white; display: inline-block; padding: 5px;">
All All

View file

@ -0,0 +1,16 @@
{% extends 'base.html' %}
{% block content %}
<p class="lead">
An alphabetical list of all speakers, workshop hosts and other
event anchors at BornHack 2016.
</p>
<div class="list-group">
{% for speaker in speaker_list %}
<a href="{% url 'program:speaker_detail' slug=speaker.slug %}" class="list-group-item">
{{ speaker.name }}
</a>
{% endfor %}
</div>
{% endblock content %}

View file

@ -2,7 +2,10 @@ from django.conf.urls import url
from . import views from . import views
urlpatterns = [ urlpatterns = [
url(r'^(?P<slug>[-_\w+]+)/$', views.EventDetailView.as_view(), name='event'), url(r'^(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})/$', views.ProgramDayView.as_view(), name='day'),
url(r'^(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})$', views.ProgramDayView.as_view(), name='day'),
url(r'^$', views.ProgramOverviewView.as_view(), name='index'), url(r'^$', views.ProgramOverviewView.as_view(), name='index'),
url(r'^speakers/$', views.SpeakerListView.as_view(), name='speaker_index'),
url(r'speakers/(?P<slug>[-_\w+]+)/$', views.SpeakerDetail.as_view(), name='speaker_detail'),
url(r'^events/$', views.EventListView.as_view(), name='events_index'),
url(r'^(?P<slug>[-_\w+]+)/$', views.EventDetailView.as_view(), name='event'),
] ]

View file

@ -6,6 +6,13 @@ from django.views.generic import ListView, TemplateView, DetailView
from camps.models import Day from camps.models import Day
from . import models from . import models
class SpeakerListView(ListView):
model = models.Speaker
template_name = 'speaker_list.html'
class EventListView(ListView):
model = models.Event
template_name = 'event_list.html'
class ProgramOverviewView(ListView): class ProgramOverviewView(ListView):
model = models.Event model = models.Event