Add email to SpeakerProposal and Speaker models.
This commit is contained in:
parent
83fa993ed1
commit
1af78e6ff7
|
@ -36,7 +36,7 @@
|
|||
{% for proposal in speakerproposals %}
|
||||
<tr>
|
||||
<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.event|truefalseicon }}</td>
|
||||
<td>{{ proposal.user }}</td>
|
||||
|
|
|
@ -17,7 +17,7 @@ class SpeakerProposalForm(forms.ModelForm):
|
|||
"""
|
||||
class Meta:
|
||||
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):
|
||||
# initialise the form
|
||||
|
|
18
src/program/migrations/0065_speakerproposal_email.py
Normal file
18
src/program/migrations/0065_speakerproposal_email.py
Normal 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),
|
||||
),
|
||||
]
|
18
src/program/migrations/0066_speaker_email.py
Normal file
18
src/program/migrations/0066_speaker_email.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -234,6 +234,13 @@ class SpeakerProposal(UserSubmittedModel):
|
|||
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(
|
||||
help_text='Biography of the speaker/artist/host. Markdown is supported.'
|
||||
)
|
||||
|
@ -268,6 +275,11 @@ class SpeakerProposal(UserSubmittedModel):
|
|||
|
||||
# set Speaker data
|
||||
speaker.camp = self.camp
|
||||
if self.email:
|
||||
email = self.email
|
||||
else:
|
||||
email = request.user.email
|
||||
speaker.email = email
|
||||
speaker.name = self.name
|
||||
speaker.biography = self.biography
|
||||
speaker.needs_oneday_ticket = self.needs_oneday_ticket
|
||||
|
@ -770,6 +782,13 @@ class Speaker(CampRelatedModel):
|
|||
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(
|
||||
help_text='Markdown is supported.'
|
||||
)
|
||||
|
|
|
@ -158,6 +158,10 @@ class SpeakerProposalCreateView(LoginRequiredMixin, CampViewMixin, EnsureWritabl
|
|||
# set user before saving
|
||||
form.instance.user = self.request.user
|
||||
form.instance.camp = self.camp
|
||||
|
||||
if not form.instance.email:
|
||||
form.instance.email = self.request.user.email
|
||||
|
||||
speakerproposal = form.save()
|
||||
|
||||
# add speakerproposal to eventproposal
|
||||
|
@ -574,6 +578,8 @@ class CombinedProposalSubmitView(LoginRequiredMixin, CampViewMixin, CreateView):
|
|||
speakerproposal = form['speakerproposal'].save(commit=False)
|
||||
speakerproposal.camp = self.camp
|
||||
speakerproposal.user = self.request.user
|
||||
if not speakerproposal.email:
|
||||
speakerproposal.email = self.request.user.email
|
||||
speakerproposal.save()
|
||||
|
||||
# then save the eventproposal
|
||||
|
|
Loading…
Reference in a new issue