This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
155 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.contrib import admin | ||
from core.models import Speaker, Contact | ||
|
||
class ContactInline(admin.TabularInline): | ||
model = Contact | ||
extra = 1 | ||
|
||
class SpeakerAdmin(admin.ModelAdmin): | ||
inlines = [ContactInline,] | ||
prepopulated_fields = {'slug': ('name', )} | ||
|
||
admin.site.register(Speaker, SpeakerAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,85 @@ | ||
from django.db import models | ||
from django.utils.translation import ugettext as _ | ||
import datetime | ||
|
||
# Create your models here. | ||
class Speaker(models.Model): | ||
name = models.CharField(max_length=255) | ||
slug = models.SlugField() | ||
url = models.URLField(verify_exists=False) | ||
description = models.TextField(blank=True) | ||
avatar = models.FileField(upload_to='palestrantes', blank=True, null=True) | ||
|
||
class Meta: | ||
verbose_name = 'Palestrante' | ||
verbose_name_plural = 'Palestrantes' | ||
|
||
def __unicode__(self): | ||
return self.name | ||
|
||
class KindContactManager(models.Manager): | ||
def __init__(self, kind): | ||
super(KindContactManager, self).__init__() | ||
self.kind = kind | ||
|
||
def get_query_set(self): | ||
qs = super(KindContactManager, self).get_query_set() | ||
qs.filter = kind=self.kind | ||
return qs | ||
|
||
class Contact(models.Model): | ||
KINDS = ( | ||
('P', _('Telefone')), | ||
('E', _('E-mail')), | ||
('F', _('Fax'))) | ||
speaker = models.ForeignKey(Speaker, verbose_name=_('Palestrante')) | ||
kind = models.CharField(max_length=1, choices=KINDS) | ||
value = models.CharField(max_length=255) | ||
|
||
objects = models.Manager() | ||
phones = KindContactManager('P') | ||
emails = KindContactManager('E') | ||
faxes = KindContactManager('F') | ||
|
||
class Meta: | ||
verbose_name = 'Contato' | ||
verbose_name_plural = 'Contatos' | ||
|
||
class PeriodManager(models.Manager): | ||
midday = datetime.time(12) | ||
|
||
def at_morning(self): | ||
qs = self.filter(start_time__lt=self.midday) | ||
qs = self.order_by('start_time') | ||
return qs | ||
|
||
def at_afternoon(self): | ||
qs = self.filter(start_time__gt=self.midday) | ||
qs = self.order_by('start_time') | ||
return qs | ||
|
||
class Talk(models.Model): | ||
title = models.CharField(max_length=200) | ||
description = models.TextField() | ||
start_time = models.TimeField(blank=True) | ||
speakers = models.ManyToManyField('Speaker', verbose_name=_('palestrante')) | ||
|
||
objects = PeriodManager() | ||
|
||
class Meta: | ||
verbose_name = 'Palestra' | ||
verbose_name_plural = 'Palestras' | ||
|
||
def __unicode__(self): | ||
return unicode(self.title) | ||
|
||
class Course(Talk): | ||
slots = models.IntegerField() | ||
notes = models.TextField() | ||
|
||
class Meta: | ||
verbose_name = 'Curso' | ||
verbose_name = 'Cursos' | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
# Create your views here. | ||
|
||
from django.http import HttpResponse | ||
from django.shortcuts import render_to_response | ||
from django.shortcuts import render_to_response, get_object_or_404 | ||
from django.views.generic.simple import direct_to_template | ||
from django.template import RequestContext | ||
from core.models import Talk | ||
|
||
def homepage(request): | ||
context = RequestContext(request) | ||
return render_to_response('homepage.html', context) | ||
|
||
def speaker(request, slug): | ||
speaker = get_object_or_404(Speaker, slug=slug) | ||
context = RequestContext(request, {'speaker': speaker}) | ||
return render_to_response('core/speaker.html', context) | ||
|
||
def talks(request): | ||
return direct_to_template(request, 'core/talks.html', { | ||
'morning_talks': Talk.objects.at_morning(), | ||
'afternoon_talks': Talk.objects.at_afternoon(), }) | ||
|
||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends 'master.html' %} | ||
{% block content %} | ||
|
||
{% if speaker.avatar %} | ||
<p> | ||
<img src="{{ speaker.avatar.url }}" alt="{{ speaker.name }}" /> | ||
</p> | ||
{% endif %} | ||
<h4><a href="{{ speaker.url }}">{{ speaker.name }}</a></h4> | ||
<p>{{ speaker.description</p> | ||
{% endblock content %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% extends 'master.html' %} | ||
{% block content %} | ||
<h3>Manhã</h3> | ||
{% for talk in morning_talks %} | ||
{% include 'core/talks_snippet.html' %} | ||
{% empty %} | ||
<p>Não existem palestras durante a manhã.</p> | ||
{% endfor %} | ||
<hr style="display: block"/> | ||
<h3>Tarde</h3> | ||
{% for talk in afternoon_talks %} | ||
{% include 'core/talks_snippet.html' %} | ||
{% empty %} | ||
<p>Não existem palestras durante a tarde.</p> | ||
{% endfor %} | ||
{% endblock content %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="palestra"> | ||
<h4><a href="{% url core:talk_details talk.id %}"> | ||
{{ talk.start_time }} - {{ talk.title }}</a></h4> | ||
{% for speaker in talk.speaker.all %} | ||
<h5><a href="{% url core:speaker speaker.slug %}" | ||
title="{{ speaker.description|truncatewords:20 }}"> | ||
{{ speaker.name }} | ||
</a></h5> | ||
{% endfor %} | ||
<p>{{ talk.description }}</p> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters