Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-wiki
Commits
2c1e7c10
Commit
2c1e7c10
authored
Jul 16, 2013
by
benjaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Django 1.4 incompatibility
parent
9c31dc3d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletions
+8
-1
wiki/plugins/notifications/forms.py
+8
-1
No files found.
wiki/plugins/notifications/forms.py
View file @
2c1e7c10
...
...
@@ -41,6 +41,7 @@ class SettingsModelForm(forms.ModelForm):
label
=
_
(
u"Remove subscriptions"
),
required
=
False
,
help_text
=
_
(
u"Select article subscriptions to remove from notifications"
),
initial
=
models
.
ArticleSubscription
.
objects
.
none
(),
)
self
.
fields
[
'email'
]
=
forms
.
TypedChoiceField
(
label
=
_
(
u"Email digests"
),
...
...
@@ -58,7 +59,10 @@ class SettingsModelForm(forms.ModelForm):
def
save
(
self
,
*
args
,
**
kwargs
):
instance
=
super
(
SettingsModelForm
,
self
)
.
save
(
*
args
,
**
kwargs
)
if
self
.
__editing_instance
:
self
.
cleaned_data
[
'delete_subscriptions'
]
.
delete
()
# Django < 1.5 returns list objects when ModelMultipleChoiceField
# is empty.. so check before calling delete()
if
self
.
cleaned_data
[
'delete_subscriptions'
]:
self
.
cleaned_data
[
'delete_subscriptions'
]
.
delete
()
if
self
.
cleaned_data
[
'email'
]
==
1
:
instance
.
subscription_set
.
all
()
.
update
(
send_emails
=
False
,
...
...
@@ -69,6 +73,7 @@ class SettingsModelForm(forms.ModelForm):
)
return
instance
class
BaseSettingsFormSet
(
BaseModelFormSet
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -81,6 +86,7 @@ class BaseSettingsFormSet(BaseModelFormSet):
subscription__articlesubscription__article__current_revision__deleted
=
False
,
)
.
prefetch_related
(
'subscription_set__articlesubscription'
,)
SettingsFormSet
=
modelformset_factory
(
Settings
,
form
=
SettingsModelForm
,
...
...
@@ -89,6 +95,7 @@ SettingsFormSet = modelformset_factory(
fields
=
(
'interval'
,
),
)
class
SubscriptionForm
(
PluginSettingsFormMixin
,
forms
.
Form
):
settings_form_headline
=
_
(
u'Notifications'
)
...
...
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