Get email activation url through a function.

This allows us to override the activation url function
in the derived class; this can be used to change the
view which handles the confirmation.
This commit is contained in:
Umair Khan 2017-01-17 15:11:51 +05:00 committed by Tim Abbott
parent 9fecbcecf5
commit 61b2a1c158
1 changed files with 6 additions and 2 deletions

View File

@ -84,7 +84,11 @@ class ConfirmationManager(models.Manager):
# type: (Union[ContentType, int], Optional[str]) -> Text
key = generate_key()
self.create(content_object=obj, date_sent=now(), confirmation_key=key)
return generate_activation_url(key, host=host)
return self.get_activation_url(key, host=host)
def get_activation_url(self, confirmation_key, host=None):
# type: (Text, Optional[str]) -> Text
return generate_activation_url(confirmation_key, host=host)
def send_confirmation(self, obj, email_address, additional_context=None,
subject_template_path=None, body_template_path=None,
@ -92,7 +96,7 @@ class ConfirmationManager(models.Manager):
# type: (ContentType, Text, Optional[Dict[str, Any]], Optional[str], Optional[str], Optional[str]) -> Confirmation
confirmation_key = generate_key()
current_site = Site.objects.get_current()
activate_url = generate_activation_url(confirmation_key, host=host)
activate_url = self.get_activation_url(confirmation_key, host=host)
context = Context({
'activate_url': activate_url,
'current_site': current_site,