def get_speaker(self): name = self.cleaned_data.get("speaker_name", "") email = self.cleaned_data.get("speaker_email") try: speaker = Speaker.objects.get(user__email=email) except Speaker.DoesNotExist: user = User.objects.create_user(username=random_string(), email=email, first_name=name[:30], password=random_string()) speaker = Speaker.objects.create( user=user, name=name[:100], biography="", biography_markup_type='markdown', biography_es="", biography_es_markup_type='markdown', biography_en="", biography_en_markup_type='markdown') return speaker
def create_user(self): """Creates user in case the is no user associated with this attendee. """ if self.user is None: users = User.objects.filter(username=self.tracker) if users.exists(): self.user = users.first() else: self.user = User.objects.create_user( username=self.tracker, email=self.email, password=random_string(), first_name=self.name.split(" ")[0], last_name=" ".join(self.name.split(" ")[1:]) ) self.save() return self.user
def notify(self): """Sends an email to the creator of the proposal with a confirmation email. The emails has a link to edit the proposal. """ if not self.code: self.code = random_string(64) context = self.notification_email_context() send_email( context=context, template="emails/proposals/confirmation.html", subject=_("[PyConES 2016] Confirmación de propuesta de charla"), to=self.speaker.email, from_email="*****@*****.**") self.notified = True self.save()
def notify(self): """Sends an email to the creator of the proposal with a confirmation email. The emails has a link to edit the proposal. """ if not self.code: self.code = random_string(64) context = self.notification_email_context() send_email( context=context, template="emails/proposals/confirmation.html", subject=_("[PyConES 2016] Confirmación de propuesta de charla"), to=self.speaker.email, from_email="*****@*****.**" ) self.notified = True self.save()
def get_speaker(self): name = self.cleaned_data.get("speaker_name", "") email = self.cleaned_data.get("speaker_email") try: speaker = Speaker.objects.get(user__email=email) except Speaker.DoesNotExist: user = User.objects.create_user( username=random_string(), email=email, first_name=name[:30], password=random_string() ) speaker = Speaker.objects.create( user=user, name=name[:100], biography="", biography_markup_type='markdown', biography_es="", biography_es_markup_type='markdown', biography_en="", biography_en_markup_type='markdown' ) return speaker
def create_user(self): """Creates user in case the is no user associated with this attendee. """ if self.user is None: users = User.objects.filter(username=self.tracker) if users.exists(): self.user = users.first() else: self.user = User.objects.create_user( username=self.tracker, email=self.email, password=random_string(), first_name=self.name.split(" ")[0], last_name=" ".join(self.name.split(" ")[1:])) self.save() return self.user
def generate_restore_code(self): self.restore_code = random_string(16) self.save()