diff --git a/pybay/forms.py b/pybay/forms.py index 08277577..61a0117a 100644 --- a/pybay/forms.py +++ b/pybay/forms.py @@ -1,6 +1,8 @@ import random import string +from pathlib import Path + from django import forms from django.conf import settings from django.core.mail import EmailMessage @@ -16,6 +18,7 @@ from crispy_forms.layout import Layout from crispy_forms.bootstrap import PrependedText + class CallForProposalForm(forms.Form): first_name = forms.CharField(label='First Name', max_length=100) last_name = forms.CharField(label='Last Name', max_length=100) @@ -104,6 +107,7 @@ def save_to_models(self): ) # Create a new talk + themes_csv = ','.join(data['themes']) proposal = TalkProposal.objects.create( kind=ProposalKind.objects.get(name='talk'), title=data['talk_title'], @@ -111,7 +115,7 @@ def save_to_models(self): abstract=data['abstract'], audience_level=data['audience_level'], speaker=speaker, - category=data['category'], + themes=themes_csv, talk_length=data['talk_length'], what_attendees_will_learn=data['what_attendees_will_learn'], meetup_talk=data['meetup_talk'], @@ -121,8 +125,8 @@ def save_to_models(self): ) # Email submit - with open('%s/proposals/email_confirmation.tmpl' % - settings.PACKAGE_ROOT) as f: + current_directory = Path(__file__).resolve().parent + with open(str(current_directory / "proposals/email_confirmation.tmpl")) as f: message = f.read().format(**data, **settings.PROJECT_DATA) email = EmailMessage( 'Your PyBay talk proposal was successfully submitted!', diff --git a/pybay/proposals/email_confirmation.tmpl b/pybay/proposals/email_confirmation.tmpl index 13597dbb..81b22247 100644 --- a/pybay/proposals/email_confirmation.tmpl +++ b/pybay/proposals/email_confirmation.tmpl @@ -18,7 +18,7 @@ Name: {first_name} {last_name} Email: {email} Speaker Profile: {speaker_bio} Talk Title: {talk_title} -Category: {category} +Themes: {themes} Level: {audience_level} Description: {description} Abstract: {abstract} diff --git a/pybay/proposals/forms.py b/pybay/proposals/forms.py index 5a7a51e6..ddde2ff0 100644 --- a/pybay/proposals/forms.py +++ b/pybay/proposals/forms.py @@ -22,7 +22,7 @@ class Meta: model = TalkProposal fields = [ "title", - "category", + "themes", "audience_level", "description", "abstract", @@ -41,7 +41,7 @@ class Meta: model = TutorialProposal fields = [ "title", - "category", + "themes", "audience_level", "description", "abstract", diff --git a/pybay/proposals/migrations/0016_auto_20180326_0812.py b/pybay/proposals/migrations/0016_auto_20180326_0812.py index 56ea0148..9d10a03f 100644 --- a/pybay/proposals/migrations/0016_auto_20180326_0812.py +++ b/pybay/proposals/migrations/0016_auto_20180326_0812.py @@ -13,7 +13,7 @@ class Migration(migrations.Migration): operations = [ migrations.RunSQL( - sql = "ALTER TABLE `proposals_talkproposal` CHANGE `what_will_attendees_learn` `what_attendees_will_learn` longtext NOT NULL;", - reverse_sql = "ALTER TABLE `proposals_talkproposal` CHANGE `what_attendees_will_learn` `what_will_attendees_learn` longtext NOT NULL;" + sql = "ALTER TABLE `proposals_talkproposal` ADD `what_will_attendees_learn` longtext;", + reverse_sql = "ALTER TABLE `proposals_talkproposal` ADD `what_attendees_will_learn` longtext;" ), ] diff --git a/pybay/tests/test_forms.py b/pybay/tests/test_forms.py index 4e12169c..d505aaf0 100644 --- a/pybay/tests/test_forms.py +++ b/pybay/tests/test_forms.py @@ -15,7 +15,8 @@ def _get_data(self): 'email': "pirosb3@gmail.com", 'website': "woo.com", 'phone': "+14155289519", - 'themes': ['python fundamentals & language internals'], + 'themes': ['python fundamentals & popular libraries', + 'engineering a community'], 'audience_level': 1, 'talk_length': 25, 'speaker_bio': 'wooo', @@ -58,6 +59,8 @@ def test_form_save_models(self): self.assertEqual(proposal.speaker_and_talk_history, 'wooo2') self.assertEqual(proposal.talk_links, 'http://google.com') self.assertEqual(speaker.user.username, "pirosb3@gmail.com") + self.assertEqual('python fundamentals & popular libraries,engineering a community', + proposal.themes) def test_form_duplicate_profile(self): form1 = CallForProposalForm(self._get_data()) diff --git a/requirements.txt b/requirements.txt index 1e78eef9..bc66c16f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,3 +29,4 @@ pytz==2015.7 rollbar==0.13.2 six==1.10.0 model-mommy==1.3.2 +sqlparse==0.2.4