From d30ce1e3a58ddc621bcec51eecf48f2ca278504c Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Sun, 12 Jun 2016 22:45:22 +0200 Subject: [PATCH] talk types --- doc/requirements.md | 4 +-- proposals/forms.py | 2 +- proposals/migrations/0002_talk_event.py | 20 ++++++++++++ proposals/models.py | 7 +++++ proposals/templates/proposals/_talk_list.html | 18 +++++++++++ .../templates/proposals/talk_detail.html | 2 ++ proposals/templates/proposals/talk_list.html | 15 +-------- proposals/templates/proposals/talks.html | 31 ++----------------- proposals/tests.py | 6 ++-- 9 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 proposals/migrations/0002_talk_event.py create mode 100644 proposals/templates/proposals/_talk_list.html diff --git a/doc/requirements.md b/doc/requirements.md index 4102c94..195eddb 100644 --- a/doc/requirements.md +++ b/doc/requirements.md @@ -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 diff --git a/proposals/forms.py b/proposals/forms.py index 07eeacd..c83a877 100644 --- a/proposals/forms.py +++ b/proposals/forms.py @@ -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']) diff --git a/proposals/migrations/0002_talk_event.py b/proposals/migrations/0002_talk_event.py new file mode 100644 index 0000000..9bf800f --- /dev/null +++ b/proposals/migrations/0002_talk_event.py @@ -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), + ), + ] diff --git a/proposals/models.py b/proposals/models.py index 634e078..ddab9d3 100644 --- a/proposals/models.py +++ b/proposals/models.py @@ -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() diff --git a/proposals/templates/proposals/_talk_list.html b/proposals/templates/proposals/_talk_list.html new file mode 100644 index 0000000..9fcf6ca --- /dev/null +++ b/proposals/templates/proposals/_talk_list.html @@ -0,0 +1,18 @@ + diff --git a/proposals/templates/proposals/talk_detail.html b/proposals/templates/proposals/talk_detail.html index df75e15..14c0f4b 100644 --- a/proposals/templates/proposals/talk_detail.html +++ b/proposals/templates/proposals/talk_detail.html @@ -8,6 +8,8 @@ edit
+

{{ talk.get_event_display }}

+ Description:

{{ talk.description }}

diff --git a/proposals/templates/proposals/talk_list.html b/proposals/templates/proposals/talk_list.html index 7ed87c4..e00cd0c 100644 --- a/proposals/templates/proposals/talk_list.html +++ b/proposals/templates/proposals/talk_list.html @@ -6,19 +6,6 @@

{{ title }}

- +{% include "proposals/_talk_list.html" %} {% endblock %} diff --git a/proposals/templates/proposals/talks.html b/proposals/templates/proposals/talks.html index 32c3c92..8875c5a 100644 --- a/proposals/templates/proposals/talks.html +++ b/proposals/templates/proposals/talks.html @@ -8,37 +8,10 @@
My participing talks:
- +{% include "proposals/_talk_list.html" with talk_list=my_talks%}
Others talks:
- +{% include "proposals/_talk_list.html" with talk_list=other_talks%} {% endblock %} diff --git a/proposals/tests.py b/proposals/tests.py index 7454305..954e416 100644 --- a/proposals/tests.py +++ b/proposals/tests.py @@ -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