talk types

This commit is contained in:
Guilhem Saurel 2016-06-12 22:45:22 +02:00
parent b92f79c010
commit d30ce1e3a5
9 changed files with 56 additions and 49 deletions

View File

@ -1,6 +1,6 @@
- [x] enregistrement sur le site (pas d'enregistrement fb/linkedin: on aime le libre ici)
- [ ] permettre de proposer une participation (conférence/atelier/small talk/etc.). Un speaker rentre un abstract et
peur associer un ou des co-speakers.
- [x] permettre de proposer une participation (conférence/atelier/small talk/etc.).
- [ ] Un speaker rentre un abstract et peut associer un ou des co-speakers.
- [ ] l'équipe organisatrice peut voter pour les conférences (avec un commentaire visible uniquement de l'équipe) et
les accepter/refuser
- [ ] pour chaque conférence/conférencier, on permet d'échanger avec le conférencier (lui vois ça comme un mail, mais

View File

@ -5,4 +5,4 @@ from proposals.models import Talk
__all__ = ['TalkForm']
TalkForm = modelform_factory(Talk, fields=['title', 'description', 'topics'])
TalkForm = modelform_factory(Talk, fields=['title', 'description', 'topics', 'event'])

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-06-12 20:26
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('proposals', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='talk',
name='event',
field=models.IntegerField(choices=[(1, 'conference'), (2, 'workshop'), (3, 'stand'), (4, 'other')], default=1),
),
]

View File

@ -1,3 +1,5 @@
from enum import IntEnum
from django.contrib.auth.models import User
from django.contrib.sites.managers import CurrentSiteManager
from django.contrib.sites.models import Site
@ -6,6 +8,8 @@ from django.db import models
from autoslug import AutoSlugField
from accounts.models import enum_to_choices
__all__ = ['Topic', 'Talk', 'Speach']
@ -23,6 +27,8 @@ class Topic(models.Model):
class Talk(models.Model):
EVENTS = IntEnum('Event', 'conference workshop stand other')
site = models.ForeignKey(Site, on_delete=models.CASCADE)
speakers = models.ManyToManyField(User, through='Speach')
@ -30,6 +36,7 @@ class Talk(models.Model):
slug = AutoSlugField(populate_from='title', unique=True)
description = models.TextField(blank=True, verbose_name='Description')
topics = models.ManyToManyField(Topic, blank=True)
event = models.IntegerField(choices=enum_to_choices(EVENTS), default=EVENTS.conference.value)
objects = models.Manager()
on_site = CurrentSiteManager()

View File

@ -0,0 +1,18 @@
<ul>
{% regroup talk_list by event as event_list %}
{% for event in event_list %}
<li>{{ event.list.0.get_event_display }}
<ul>{% for talk in event.list %}
<li>
<a href="{% url 'show-talk' talk.slug %}">{{ talk }}</a>
<i>by</i>
{% for speaker in talk.speakers.all %}
<a href="{% url 'show-speaker' speaker.username %}">{{ speaker }}</a>
{% if forloop.revcounter == 2 %} and {% elif not forloop.last %}, {% endif %}
{% endfor %}
</li>
{% endfor %}
</ul>
{% empty %}Nothing
</li>{% endfor %}
</ul>

View File

@ -8,6 +8,8 @@
<a class="btn btn-primary" href="{% url 'edit-talk' talk.slug %}">edit</a><br />
<p>{{ talk.get_event_display }}</p>
<b>Description:</b>
<p>{{ talk.description }}</p>

View File

@ -6,19 +6,6 @@
<h1>{{ title }}</h1>
<ul>
{% for talk in talk_list %}
<li>
<a href="{% url 'show-talk' talk.slug %}">{{ talk }}</a>
<i>by</i>
{% for speaker in talk.speakers.all %}
<a href="{% url 'show-speaker' speaker.username %}">{{ speaker }}</a>
{% if forloop.revcounter == 2 %} and {% elif not forloop.last %}, {% endif %}
{% endfor %}
</li>
{% empty %}
<li><i>No talk.</i></li>
{% endfor %}
</ul>
{% include "proposals/_talk_list.html" %}
{% endblock %}

View File

@ -8,37 +8,10 @@
<div class="h3">My participing talks:</div>
<ul>
{% for talk in my_talks %}
<li>
<a href="{% url 'show-talk' talk.slug %}">{{ talk }}</a>
<i>by</i>
{% for speaker in talk.speakers.all %}
<a href="{% url 'show-speaker' speaker.username %}">{{ speaker }}</a>
{% if forloop.revcounter == 2 %} and {% elif not forloop.last %}, {% endif %}
{% endfor %}
<a class="btn btn-primary btn-xs" href="{% url 'edit-talk' talk.slug %}">edit</a>
</li>
{% empty %}
<li>No proposed talk.</li>
{% endfor %}
</ul>
{% include "proposals/_talk_list.html" with talk_list=my_talks%}
<div class="h3">Others talks:</div>
<ul>
{% for talk in other_talks %}
<li>
<a href="{% url 'show-talk' talk.slug %}">{{ talk }}</a>
<i>by</i>
{% for speach in talk.speach_set.all %}
<a href="{% url 'show-speaker' speach.username %}">{{ speach.user }}</a>
{% if forloop.revcounter == 2 %} and {% elif not forloop.last %}, {% endif %}
{% endfor %}
</li>
{% empty %}
<li>No other talk.</li>
{% endfor %}
</ul>
{% include "proposals/_talk_list.html" with talk_list=other_talks%}
{% endblock %}

View File

@ -14,10 +14,10 @@ class ProposalsTests(TestCase):
def test_everything(self):
# talk-edit
self.client.login(username='a', password='a')
self.client.post(reverse('add-talk'), {'title': 'super talk', 'description': 'super'})
self.client.post(reverse('add-talk'), {'title': 'super talk', 'description': 'super', 'event': 1})
self.assertEqual(str(Talk.on_site.first()), 'super talk')
self.client.post(reverse('edit-talk', kwargs={'talk': 'super-talk'}),
{'title': 'mega talk', 'description': 'mega'})
{'title': 'mega talk', 'description': 'mega', 'event': 1})
self.assertEqual(str(Talk.on_site.first()), 'mega talk')
# Status Code
@ -32,7 +32,7 @@ class ProposalsTests(TestCase):
self.client.login(username='b', password='b')
self.assertEqual(self.client.post(reverse('edit-talk', kwargs={'talk': 'super-talk'}),
{'title': 'mega talk', 'description': 'mega'}).status_code, 403)
{'title': 'mega talk', 'description': 'mega', 'event': 1}).status_code, 403)
self.assertEqual(self.client.get(reverse('list-talks')).status_code, 200)
# Models str & get_asbolute_url