Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b20ebb00
authored
Jun 09, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: allow unsubscription with token
parent
a30de002
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
2 deletions
+65
-2
circle/dashboard/forms.py
+13
-0
circle/dashboard/tasks/local_periodic_tasks.py
+4
-0
circle/dashboard/templates/dashboard/notifications/email.txt
+3
-0
circle/dashboard/templates/dashboard/unsubscribe.html
+21
-0
circle/dashboard/urls.py
+3
-1
circle/dashboard/views.py
+21
-1
No files found.
circle/dashboard/forms.py
View file @
b20ebb00
...
@@ -1107,6 +1107,19 @@ class MyProfileForm(forms.ModelForm):
...
@@ -1107,6 +1107,19 @@ class MyProfileForm(forms.ModelForm):
return
value
return
value
class
UnsubscribeForm
(
forms
.
ModelForm
):
class
Meta
:
fields
=
(
'email_notifications'
,
)
model
=
Profile
@property
def
helper
(
self
):
helper
=
FormHelper
()
helper
.
add_input
(
Submit
(
"submit"
,
_
(
"Change language"
)))
return
helper
class
CirclePasswordChangeForm
(
PasswordChangeForm
):
class
CirclePasswordChangeForm
(
PasswordChangeForm
):
@property
@property
...
...
circle/dashboard/tasks/local_periodic_tasks.py
View file @
b20ebb00
...
@@ -26,6 +26,7 @@ from django.utils.translation import ungettext, override
...
@@ -26,6 +26,7 @@ from django.utils.translation import ungettext, override
from
manager.mancelery
import
celery
from
manager.mancelery
import
celery
from
..models
import
Notification
from
..models
import
Notification
from
..views
import
UnsubscribeFormView
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -50,6 +51,9 @@ def send_email_notifications():
...
@@ -50,6 +51,9 @@ def send_email_notifications():
context
=
{
'user'
:
user
.
profile
,
'messages'
:
msgs
,
context
=
{
'user'
:
user
.
profile
,
'messages'
:
msgs
,
'url'
:
(
settings
.
DJANGO_URL
.
rstrip
(
"/"
)
+
'url'
:
(
settings
.
DJANGO_URL
.
rstrip
(
"/"
)
+
reverse
(
"dashboard.views.notifications"
)),
reverse
(
"dashboard.views.notifications"
)),
'unsub'
:
(
settings
.
DJANGO_URL
.
rstrip
(
"/"
)
+
reverse
(
"dashboard.views.unsubscribe"
,
args
=
[
UnsubscribeFormView
.
get_token
(
user
)])),
'site'
:
settings
.
COMPANY_NAME
}
'site'
:
settings
.
COMPANY_NAME
}
subject
=
settings
.
EMAIL_SUBJECT_PREFIX
+
ungettext
(
subject
=
settings
.
EMAIL_SUBJECT_PREFIX
+
ungettext
(
"
%
d new notification"
,
"
%
d new notification"
,
...
...
circle/dashboard/templates/dashboard/notifications/email.txt
View file @
b20ebb00
...
@@ -11,3 +11,6 @@
...
@@ -11,3 +11,6 @@
--
--
{{site}} CIRCLE Cloud
{{site}} CIRCLE Cloud
{% trans "You can change your subscription without logging in:" %}
{{unsub}}
circle/dashboard/templates/dashboard/unsubscribe.html
0 → 100644
View file @
b20ebb00
{% extends "dashboard/base.html" %}
{% load crispy_forms_tags %}
{% load i18n %}
{% block content %}
<div
class=
"body-content"
>
<div
class=
"panel panel-default"
style=
"margin-top: 60px;"
>
<div
class=
"panel-heading"
>
<h3
class=
"no-margin"
>
{% trans "Subscription settings" %}
</h3>
</div>
<div
class=
"panel-body"
>
<form
method=
"POST"
action=
""
>
{% csrf_token %}
{% crispy form %}
</form>
</div>
</div>
</div>
{% endblock %}
circle/dashboard/urls.py
View file @
b20ebb00
...
@@ -35,7 +35,7 @@ from .views import (
...
@@ -35,7 +35,7 @@ from .views import (
TemplateChoose
,
TemplateChoose
,
UserCreationView
,
UserCreationView
,
get_vm_screenshot
,
get_vm_screenshot
,
ProfileView
,
toggle_use_gravatar
,
ProfileView
,
toggle_use_gravatar
,
UnsubscribeFormView
,
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -140,6 +140,8 @@ urlpatterns = patterns(
...
@@ -140,6 +140,8 @@ urlpatterns = patterns(
url
(
r'^profile/$'
,
MyPreferencesView
.
as_view
(),
url
(
r'^profile/$'
,
MyPreferencesView
.
as_view
(),
name
=
"dashboard.views.profile-preferences"
),
name
=
"dashboard.views.profile-preferences"
),
url
(
r'^subscribe/(?P<token>.*)/$'
,
UnsubscribeFormView
.
as_view
(),
name
=
"dashboard.views.unsubscribe"
),
url
(
r'^profile/(?P<username>[^/]+)/$'
,
ProfileView
.
as_view
(),
url
(
r'^profile/(?P<username>[^/]+)/$'
,
ProfileView
.
as_view
(),
name
=
"dashboard.views.profile"
),
name
=
"dashboard.views.profile"
),
url
(
r'^profile/(?P<username>[^/]+)/use_gravatar/$'
,
toggle_use_gravatar
),
url
(
r'^profile/(?P<username>[^/]+)/use_gravatar/$'
,
toggle_use_gravatar
),
...
...
circle/dashboard/views.py
View file @
b20ebb00
...
@@ -59,7 +59,7 @@ from braces.views._access import AccessMixin
...
@@ -59,7 +59,7 @@ from braces.views._access import AccessMixin
from
.forms
import
(
from
.forms
import
(
CircleAuthenticationForm
,
DiskAddForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
CircleAuthenticationForm
,
DiskAddForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
GroupCreateForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
GroupCreateForm
,
UserCreationForm
,
GroupProfileUpdateForm
,
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
CirclePasswordChangeForm
CirclePasswordChangeForm
)
)
...
@@ -2605,6 +2605,26 @@ class MyPreferencesView(UpdateView):
...
@@ -2605,6 +2605,26 @@ class MyPreferencesView(UpdateView):
return
self
.
render_to_response
(
context
)
return
self
.
render_to_response
(
context
)
class
UnsubscribeFormView
(
SuccessMessageMixin
,
UpdateView
):
model
=
Profile
form_class
=
UnsubscribeForm
template_name
=
"dashboard/unsubscribe.html"
success_message
=
_
(
"Successfully modified subscription."
)
@classmethod
def
get_salt
(
cls
):
return
unicode
(
cls
)
@classmethod
def
get_token
(
cls
,
user
):
return
signing
.
dumps
(
user
.
pk
,
salt
=
cls
.
get_salt
())
def
get_object
(
self
,
queryset
=
None
):
pk
=
signing
.
loads
(
self
.
kwargs
[
'token'
],
salt
=
self
.
get_salt
(),
max_age
=
48
*
3600
)
return
(
queryset
or
self
.
get_queryset
())
.
get
(
user_id
=
pk
)
def
set_language_cookie
(
request
,
response
,
lang
=
None
):
def
set_language_cookie
(
request
,
response
,
lang
=
None
):
if
lang
is
None
:
if
lang
is
None
:
try
:
try
:
...
...
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