Make email mandatory and show that on the event proposal admin site.

This commit is contained in:
Víðir Valberg Guðmundsson 2018-08-18 20:02:59 +02:00
parent 428cee3cd7
commit c8f6f76689
3 changed files with 30 additions and 5 deletions

View file

@ -32,7 +32,7 @@ class SpeakerProposalAdmin(admin.ModelAdmin):
def get_speakers_string(event_proposal): def get_speakers_string(event_proposal):
return ', '.join(event_proposal.speakers.all().values_list('name', flat=True)) return ', '.join(event_proposal.speakers.all().values_list('email', flat=True))
get_speakers_string.short_description = 'Speakers' get_speakers_string.short_description = 'Speakers'

View file

@ -0,0 +1,29 @@
# Generated by Django 2.1 on 2018-08-18 17:57
from django.db import migrations
def add_email(apps, schema_editor):
Speaker = apps.get_model('program', 'Speaker')
SpeakerProposal = apps.get_model('program', 'SpeakerProposal')
for speaker in Speaker.objects.all():
if speaker.proposal and not speaker.email:
speaker.email = speaker.proposal.user.email
speaker.save()
for speaker_proposal in SpeakerProposal.objects.all():
if not speaker_proposal.email:
speaker_proposal.email = speaker_proposal.user.email
speaker_proposal.save()
class Migration(migrations.Migration):
dependencies = [
('program', '0067_auto_20180818_1634'),
]
operations = [
migrations.RunPython(add_email)
]

View file

@ -237,8 +237,6 @@ class SpeakerProposal(UserSubmittedModel):
email = models.EmailField( email = models.EmailField(
max_length=150, max_length=150,
help_text="The email of the speaker (defaults to the logged in user if empty.", 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(
@ -790,8 +788,6 @@ class Speaker(CampRelatedModel):
email = models.EmailField( email = models.EmailField(
max_length=150, max_length=150,
help_text="The email of the speaker.", help_text="The email of the speaker.",
null=True,
blank=True
) )
biography = models.TextField( biography = models.TextField(