add videotaped and video_licence profile fields

This commit is contained in:
Élie Bouttier 2016-07-10 00:42:40 +02:00
parent 577db6bc4b
commit ea72f19e83
4 changed files with 34 additions and 5 deletions

View File

@ -13,12 +13,12 @@ UserForm = modelform_factory(User, fields=['first_name', 'last_name', 'email', '
ProfileForm = modelform_factory(Profile, fields=['biography'])
ParticipationForm = modelform_factory(Participation, fields=['transport', 'connector', 'sound', 'constraints'])
ParticipationForm = modelform_factory(Participation, fields=['transport', 'connector', 'sound', 'videotaped', 'video_licence', 'constraints'])
ProfileOrgaForm = modelform_factory(Profile, fields=['biography', 'notes'])
ParticipationOrgaForm = modelform_factory(Participation,
fields=['transport', 'connector', 'sound', 'constraints', 'orga'])
fields=['transport', 'connector', 'sound', 'videotaped', 'video_licence', 'constraints', 'orga'])
class ParticipationField(forms.ModelChoiceField):
def label_from_instance(self, obj):

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-07-09 22:40
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0002_auto_20160709_2059'),
]
operations = [
migrations.AddField(
model_name='participation',
name='video_licence',
field=models.IntegerField(choices=[(1, 'CC-Zero'), (2, 'CC-BY'), (3, 'CC-BY-SA'), (4, 'CC-BY-ND'), (5, 'CC-BY-NC'), (6, 'CC-BY-NC-SA'), (7, 'CC-BY-NC-ND')], default=1),
),
migrations.AddField(
model_name='participation',
name='videotaped',
field=models.BooleanField(default=True, verbose_name="I'm ok to be recorded on video"),
),
]

View File

@ -30,6 +30,7 @@ class Participation(PonyConfModel):
TRANSPORTS = IntEnum('Transport', 'train plane others')
CONNECTORS = IntEnum('Connector', 'VGA HDMI miniDP')
LICENCES = IntEnum('Video licence', 'CC-Zero CC-BY CC-BY-SA CC-BY-ND CC-BY-NC CC-BY-NC-SA CC-BY-NC-ND')
site = models.ForeignKey(Site, on_delete=models.CASCADE)
user = models.ForeignKey(User)
@ -41,6 +42,8 @@ class Participation(PonyConfModel):
connector = models.IntegerField(choices=enum_to_choices(CONNECTORS), blank=True, null=True)
constraints = models.TextField(blank=True)
sound = models.BooleanField("I need sound", default=False)
videotaped = models.BooleanField("I'm ok to be recorded on video", default=True)
video_licence = models.IntegerField(choices=enum_to_choices(LICENCES), default=1)
orga = models.BooleanField(default=False)
class Meta:

View File

@ -32,10 +32,10 @@ class AccountTests(TestCase):
self.client.login(username='b', password='b')
# He tries with an invalid address
self.client.post(reverse('profile'), {'email': 'bnewdomain.com', 'username': 'z', 'biography': 'tester'})
self.client.post(reverse('profile'), {'email': 'bnewdomain.com', 'username': 'z', 'biography': 'tester', 'video_licence': 1})
self.assertEqual(User.objects.filter(username='z').count(), 0)
self.client.post(reverse('profile'), {'email': 'b@newdomain.com', 'username': 'z', 'biography': 'tester'})
self.client.post(reverse('profile'), {'email': 'b@newdomain.com', 'username': 'z', 'biography': 'tester', 'video_licence': 1})
user = User.objects.get(username='z')
self.assertEqual(user.email, 'b@newdomain.com')
@ -62,6 +62,7 @@ class AccountTests(TestCase):
self.assertEqual(self.client.post(reverse('edit-participant', kwargs={'username': 'a'}),
{'biography': 'foo', 'notes': 'bar', 'first_name': 'Jules', 'username': 'a',
'last_name': 'César', 'email': 'a@example.org', 'transport': 1,
'connector': 1, 'constraints': 'nope', 'orga': 0,
'connector': 1, 'video_licence': 2, 'constraints': 'nope', 'orga': 0,
}).status_code, 200)
self.assertEqual(User.objects.get(username='a').profile.biography, 'foo')
self.assertEqual(Participation.objects.get(user=User.objects.get(username='a')).video_licence, 2)