Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom email field attribute #58

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions simple_email_confirmation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@ class SimpleEmailConfirmationUserMixin(object):
Provides python-level functionality only.
"""

# if your User object stores the User's primary email address
# in a place other than User.email, you can override the
# primary_email_field_name and/or primary_email get/set methods.
# All access to a User's primary_email in this app passes through
# these two get/set methods.

primary_email_field_name = 'email'
ferndot marked this conversation as resolved.
Show resolved Hide resolved

def get_primary_email(self):
return getattr(self, self.primary_email_field_name)
return getattr(self, self.get_email_field_name())

def set_primary_email(self, email, require_confirmed=True):
"Set an email address as primary"
Expand All @@ -44,8 +36,8 @@ def set_primary_email(self, email, require_confirmed=True):
if email not in self.confirmed_emails and require_confirmed:
raise EmailNotConfirmed()

setattr(self, self.primary_email_field_name, email)
self.save(update_fields=[self.primary_email_field_name])
setattr(self, self.get_email_field_name(), email)
self.save(update_fields=[self.get_email_field_name()])
primary_email_changed.send(
sender=self, old_email=old_email, new_email=email,
)
Expand Down