Add email to SpeakerProposal and Speaker models.

This commit is contained in:
Víðir Valberg Guðmundsson 2018-08-18 14:11:30 +02:00
parent 83fa993ed1
commit 1af78e6ff7
6 changed files with 63 additions and 2 deletions

View file

@ -36,7 +36,7 @@
{% for proposal in speakerproposals %} {% for proposal in speakerproposals %}
<tr> <tr>
<td>{{ proposal.name }}</td> <td>{{ proposal.name }}</td>
<td>{{ proposal.user.email }}</td> <td>{{ proposal.email }}</td>
<td class="text-center">{{ proposal.needs_oneday_ticket|truefalseicon }}</td> <td class="text-center">{{ proposal.needs_oneday_ticket|truefalseicon }}</td>
<td class="text-center">{{ proposal.event|truefalseicon }}</td> <td class="text-center">{{ proposal.event|truefalseicon }}</td>
<td>{{ proposal.user }}</td> <td>{{ proposal.user }}</td>

View file

@ -17,7 +17,7 @@ class SpeakerProposalForm(forms.ModelForm):
""" """
class Meta: class Meta:
model = SpeakerProposal model = SpeakerProposal
fields = ['name', 'biography', 'needs_oneday_ticket', 'submission_notes'] fields = ['name', 'email', 'biography', 'needs_oneday_ticket', 'submission_notes']
def __init__(self, camp, eventtype=None, *args, **kwargs): def __init__(self, camp, eventtype=None, *args, **kwargs):
# initialise the form # initialise the form

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1 on 2018-08-18 11:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('program', '0064_auto_20180810_1748'),
]
operations = [
migrations.AddField(
model_name='speakerproposal',
name='email',
field=models.EmailField(blank=True, help_text='The email of the speaker (defaults to the logged in user if empty.', max_length=150, null=True),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1 on 2018-08-18 12:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('program', '0065_speakerproposal_email'),
]
operations = [
migrations.AddField(
model_name='speaker',
name='email',
field=models.EmailField(blank=True, help_text='The email of the speaker.', max_length=150, null=True),
),
]

View file

@ -234,6 +234,13 @@ class SpeakerProposal(UserSubmittedModel):
help_text='Name or alias of the speaker/artist/host', help_text='Name or alias of the speaker/artist/host',
) )
email = models.EmailField(
max_length=150,
help_text="The email of the speaker (defaults to the logged in user if empty.",
null=True,
blank=True,
)
biography = models.TextField( biography = models.TextField(
help_text='Biography of the speaker/artist/host. Markdown is supported.' help_text='Biography of the speaker/artist/host. Markdown is supported.'
) )
@ -268,6 +275,11 @@ class SpeakerProposal(UserSubmittedModel):
# set Speaker data # set Speaker data
speaker.camp = self.camp speaker.camp = self.camp
if self.email:
email = self.email
else:
email = request.user.email
speaker.email = email
speaker.name = self.name speaker.name = self.name
speaker.biography = self.biography speaker.biography = self.biography
speaker.needs_oneday_ticket = self.needs_oneday_ticket speaker.needs_oneday_ticket = self.needs_oneday_ticket
@ -770,6 +782,13 @@ class Speaker(CampRelatedModel):
help_text='Name or alias of the speaker', help_text='Name or alias of the speaker',
) )
email = models.EmailField(
max_length=150,
help_text="The email of the speaker.",
null=True,
blank=True
)
biography = models.TextField( biography = models.TextField(
help_text='Markdown is supported.' help_text='Markdown is supported.'
) )

View file

@ -158,6 +158,10 @@ class SpeakerProposalCreateView(LoginRequiredMixin, CampViewMixin, EnsureWritabl
# set user before saving # set user before saving
form.instance.user = self.request.user form.instance.user = self.request.user
form.instance.camp = self.camp form.instance.camp = self.camp
if not form.instance.email:
form.instance.email = self.request.user.email
speakerproposal = form.save() speakerproposal = form.save()
# add speakerproposal to eventproposal # add speakerproposal to eventproposal
@ -574,6 +578,8 @@ class CombinedProposalSubmitView(LoginRequiredMixin, CampViewMixin, CreateView):
speakerproposal = form['speakerproposal'].save(commit=False) speakerproposal = form['speakerproposal'].save(commit=False)
speakerproposal.camp = self.camp speakerproposal.camp = self.camp
speakerproposal.user = self.request.user speakerproposal.user = self.request.user
if not speakerproposal.email:
speakerproposal.email = self.request.user.email
speakerproposal.save() speakerproposal.save()
# then save the eventproposal # then save the eventproposal