+ class Meta:
+ abstract = True
+
+
+class PasswordMultiView(LoginMultiView):
+ "Adds on views for password-related functions."
+ password_reset_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_reset_related', blank=True, null=True)
+ password_reset_confirmation_email = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_reset_confirmation_email_related', blank=True, null=True)
+ password_set_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_set_related', blank=True, null=True)
+ password_change_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_change_related', blank=True, null=True)
+
+ password_change_form = PasswordChangeForm
+ password_set_form = SetPasswordForm
+ password_reset_form = PasswordResetForm
+
+ @property
+ def urlpatterns(self):
+ urlpatterns = super(PasswordMultiView, self).urlpatterns
+
+ if self.password_reset_page and self.password_reset_confirmation_email and self.password_set_page:
+ urlpatterns += patterns('',
+ url(r'^password/reset$', csrf_protect(self.password_reset), name='password_reset'),
+ url(r'^password/reset/(?P<uidb36>\w+)/(?P<token>[^/]+)$', self.password_reset_confirm, name='password_reset_confirm'),
+ )
+
+ if self.password_change_page:
+ urlpatterns += patterns('',
+ url(r'^password/change$', csrf_protect(self.login_required(self.password_change)), name='password_change'),
+ )
+ return urlpatterns
+
+ def make_confirmation_link(self, confirmation_view, token_generator, user, node, token_args=None, reverse_kwargs=None, secure=False):
+ token = token_generator.make_token(user, *(token_args or []))
+ kwargs = {
+ 'uidb36': int_to_base36(user.id),
+ 'token': token
+ }
+ kwargs.update(reverse_kwargs or {})
+ return node.construct_url(subpath=self.reverse(confirmation_view, kwargs=kwargs), with_domain=True, secure=secure)
+