Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
chris
repanier
Commits
e8c7e180
Commit
e8c7e180
authored
Jun 25, 2017
by
Patrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use customer id instead of name to create unsubscribe link to use only ascii characters
parent
8af63fe3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
repanier/models/customer.py
repanier/models/customer.py
+4
-4
No files found.
repanier/models/customer.py
View file @
e8c7e180
...
...
@@ -323,21 +323,21 @@ class Customer(models.Model):
return
'<br/><br/><hr/><br/><a href="%s">%s</a>'
%
(
self
.
_get_unsubscribe_link
(),
_
(
"Unsubscribe to emails"
))
def
_get_unsubscribe_link
(
self
):
us
ername
,
token
=
self
.
make_token
().
split
(
":"
,
1
)
c
us
tomer_id
,
token
=
self
.
make_token
().
split
(
":"
,
1
)
return
"https://%s%s"
%
(
settings
.
ALLOWED_HOSTS
[
0
],
reverse
(
'unsubscribe_view'
,
kwargs
=
{
'
short_name'
:
self
.
short_basket_name
,
'token'
:
token
,
}
kwargs
=
{
'
customer_id'
:
customer_id
,
'token'
:
token
,
}
)
)
def
make_token
(
self
):
return
TimestampSigner
().
sign
(
self
.
short_basket_name
)
return
TimestampSigner
().
sign
(
self
.
id
)
def
check_token
(
self
,
token
):
try
:
key
=
'%s:%s'
%
(
self
.
short_basket_name
,
token
)
key
=
'%s:%s'
%
(
self
.
id
,
token
)
TimestampSigner
().
unsign
(
key
,
max_age
=
60
*
60
*
48
)
# Valid for 2 days
except
(
BadSignature
,
SignatureExpired
):
return
False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment