urls: Rename arguments to accounts/unsubscribe.

type -> email_type to match future work on ScheduledJob.

token -> confirmation_key to match what the other confirmation views urls
call this argument.
This commit is contained in:
Rishi Gupta
2017-07-07 11:37:09 -07:00
committed by Tim Abbott
parent 11a4cffba0
commit 0f46fd86dd
3 changed files with 7 additions and 7 deletions

View File

@@ -39,14 +39,14 @@ def unsubscribe_token(user_profile):
# unsubscription tokens. # unsubscription tokens.
return Confirmation.objects.get_link_for_object(user_profile, 'unused').split("/")[-1] return Confirmation.objects.get_link_for_object(user_profile, 'unused').split("/")[-1]
def one_click_unsubscribe_link(user_profile, endpoint): def one_click_unsubscribe_link(user_profile, email_type):
# type: (UserProfile, Text) -> Text # type: (UserProfile, Text) -> Text
""" """
Generate a unique link that a logged-out user can visit to unsubscribe from Generate a unique link that a logged-out user can visit to unsubscribe from
Zulip e-mails without having to first log in. Zulip e-mails without having to first log in.
""" """
token = unsubscribe_token(user_profile) token = unsubscribe_token(user_profile)
resource_path = "accounts/unsubscribe/%s/%s" % (endpoint, token) resource_path = "accounts/unsubscribe/%s/%s" % (email_type, token)
return "%s/%s" % (user_profile.realm.uri.rstrip("/"), resource_path) return "%s/%s" % (user_profile.realm.uri.rstrip("/"), resource_path)
def hash_util_encode(string): def hash_util_encode(string):

View File

@@ -49,10 +49,10 @@ email_unsubscribers = {
} }
# Login NOT required. These are for one-click unsubscribes. # Login NOT required. These are for one-click unsubscribes.
def email_unsubscribe(request, type, token): def email_unsubscribe(request, email_type, confirmation_key):
# type: (HttpRequest, str, str) -> HttpResponse # type: (HttpRequest, str, str) -> HttpResponse
if type in email_unsubscribers: if email_type in email_unsubscribers:
display_name, unsubscribe_function = email_unsubscribers[type] display_name, unsubscribe_function = email_unsubscribers[email_type]
return process_unsubscribe(request, token, display_name, unsubscribe_function) return process_unsubscribe(request, confirmation_key, display_name, unsubscribe_function)
return render(request, 'zerver/unsubscribe_link_error.html') return render(request, 'zerver/unsubscribe_link_error.html')

View File

@@ -118,7 +118,7 @@ i18n_urls = [
# Email unsubscription endpoint. Allows for unsubscribing from various types of emails, # Email unsubscription endpoint. Allows for unsubscribing from various types of emails,
# including the welcome emails (day 1 & 2), missed PMs, etc. # including the welcome emails (day 1 & 2), missed PMs, etc.
url(r'^accounts/unsubscribe/(?P<type>[\w]+)/(?P<token>[\w]+)', url(r'^accounts/unsubscribe/(?P<email_type>[\w]+)/(?P<confirmation_key>[\w]+)',
zerver.views.unsubscribe.email_unsubscribe, name='zerver.views.unsubscribe.email_unsubscribe'), zerver.views.unsubscribe.email_unsubscribe, name='zerver.views.unsubscribe.email_unsubscribe'),
# Portico-styled page used to provide email confirmation of terms acceptance. # Portico-styled page used to provide email confirmation of terms acceptance.