Commit ac51d80a authored by Patrick's avatar Patrick

Use customer id instead of name to avoid non ascii characters in the unsubscribe link

parent e8c7e180
......@@ -153,5 +153,5 @@ urlpatterns = [
url(r'^rest/version/$', version_rest, name='version_rest'),
url(r'^dowload-customer-invoice/(?P<customer_invoice_id>\d+)/$', download_customer_invoice, name='download_customer_invoice'),
url(r'^unsubscribe/(?P<short_name>.*)/(?P<token>[\w.:\-_=]+)/$', unsubscribe_view, name='unsubscribe_view'),
url(r'^unsubscribe/(?P<customer_id>.*)/(?P<token>[\w.:\-_=]+)/$', unsubscribe_view, name='unsubscribe_view'),
......@@ -11,17 +11,17 @@ from repanier.models.customer import Customer
def unsubscribe_view(request, short_name, token):
def unsubscribe_view(request, customer_id, token):
User is immediately unsubscribed
if they came from an unexpired unsubscribe link.
customer = Customer.objects.filter(
if customer is not None and (not customer.subscribe_to_email or customer.check_token(token)):
if customer is not None and customer.check_token(token):
# unsubscribe them
# use vvvv because ^^^^^ will call "pre_save" function which reset valid_email to None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment