From c7ce7fe02068352a9cd4c1c0a6d386dff953890c Mon Sep 17 00:00:00 2001 From: Jeff Triplett Date: Mon, 14 Mar 2016 22:24:14 -0500 Subject: [PATCH] Adds twitter_username to Speaker This change is based on the PyOhio fork located at: https://github.com/PyCon/pycon/search?utf8=%E2%9C%93&q=twitter_username --- symposion/speakers/admin.py | 2 +- symposion/speakers/forms.py | 7 +++++++ .../0002_speaker_twitter_username.py | 20 +++++++++++++++++++ symposion/speakers/models.py | 5 +++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 symposion/speakers/migrations/0002_speaker_twitter_username.py diff --git a/symposion/speakers/admin.py b/symposion/speakers/admin.py index e79370a3..95d4b28a 100644 --- a/symposion/speakers/admin.py +++ b/symposion/speakers/admin.py @@ -5,5 +5,5 @@ from symposion.speakers.models import Speaker admin.site.register(Speaker, - list_display=["name", "email", "created"], + list_display=["name", "email", "created", "twitter_username"], search_fields=["name"]) diff --git a/symposion/speakers/forms.py b/symposion/speakers/forms.py index 3b81efa3..c0acfe38 100644 --- a/symposion/speakers/forms.py +++ b/symposion/speakers/forms.py @@ -12,4 +12,11 @@ class SpeakerForm(forms.ModelForm): "name", "biography", "photo", + "twitter_username", ] + + def clean_twitter_username(self): + value = self.cleaned_data["twitter_username"] + if value.startswith("@"): + value = value[1:] + return value diff --git a/symposion/speakers/migrations/0002_speaker_twitter_username.py b/symposion/speakers/migrations/0002_speaker_twitter_username.py new file mode 100644 index 00000000..9208697b --- /dev/null +++ b/symposion/speakers/migrations/0002_speaker_twitter_username.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-03-15 03:16 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('symposion_speakers', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='speaker', + name='twitter_username', + field=models.CharField(blank=True, help_text='Your Twitter account', max_length=15), + ), + ] diff --git a/symposion/speakers/models.py b/symposion/speakers/models.py index 57d113d7..6e6de9d4 100644 --- a/symposion/speakers/models.py +++ b/symposion/speakers/models.py @@ -30,6 +30,11 @@ class Speaker(models.Model): "Markdown."), verbose_name=_("Biography")) biography_html = models.TextField(blank=True) photo = models.ImageField(upload_to="speaker_photos", blank=True, verbose_name=_("Photo")) + twitter_username = models.CharField( + max_length=15, + blank=True, + help_text=_(u"Your Twitter account") + ) annotation = models.TextField(verbose_name=_("Annotation")) # staff only invite_email = models.CharField(max_length=200, unique=True, null=True, db_index=True, verbose_name=_("Invite_email")) invite_token = models.CharField(max_length=40, db_index=True, verbose_name=_("Invite token"))