def send_user_key(user_id): profile = UserProfile.objects.get(user_id=user_id) if not profile.token: profile.generate_token() # Render HTML and text templates: context = {"confirm_url": make_absolute_url(profile.manage_url)} send_mail(profile.user, "Cornerwise: Please confirm your email", "confirm", context)
def send_user_key(user): profile = user.profile if not profile.token: profile.generate_token() # Render HTML and text templates: path = reverse("user-login", kwargs={"token": profile.token, "pk": user.pk}) context = {"confirm_url": make_absolute_url(path)} send_mail(user, "Cornerwise: Please confirm your email", "confirm", context)
def welcome_context(subscription): """Constructs the context for rendering the welcome email. """ user = subscription.user profile = user.profile if not profile.token: profile.generate_token() return { "confirm_url": make_absolute_url(profile.confirm_url), "minimap_src": subscription.minimap_src, "subscription-preview": subscription.minimap_src }
def confirmation_context(subscription): try: user = subscription.user existing = user.subscriptions.filter(active=True).exists() except IndexError: # The user doesn't have any active Subscriptions return return { "subscription": subscription.readable_description, "minimap_src": subscription.minimap_src, "subscription-preview": subscription.minimap_src, "old_minimap_src": existing.minimap_src, "confirmation_link": make_absolute_url(subscription.confirm_url) }
def _make_user_context(user, context): context = context.copy() if context else {} context["user"] = user.profile.addressal context["unsubscribe_url"] = make_absolute_url( user.profile.unsubscribe_url) return context
def absolutize(url): return make_absolute_url(url)