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
OpenEdx
django-wiki
Commits
6e472422
Commit
6e472422
authored
Nov 18, 2013
by
benjaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #191 - introduce DRY in plugins.notifications default_url
parent
363f50ac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
11 deletions
+16
-11
wiki/models/article.py
+1
-1
wiki/models/urlpath.py
+11
-3
wiki/plugins/notifications/models.py
+4
-7
No files found.
wiki/models/article.py
View file @
6e472422
...
...
@@ -193,7 +193,7 @@ class ArticleForObject(models.Model):
verbose_name
=
_
(
'content type'
),
related_name
=
"content_type_set_for_
%(class)
s"
)
object_id
=
models
.
PositiveIntegerField
(
_
(
'object ID'
))
content_object
=
generic
.
GenericForeignKey
(
ct_field
=
"content_type"
,
fk_field
=
"object_id"
)
content_object
=
generic
.
GenericForeignKey
(
"content_type"
,
"object_id"
)
is_mptt
=
models
.
BooleanField
(
default
=
False
,
editable
=
False
)
...
...
wiki/models/urlpath.py
View file @
6e472422
...
...
@@ -33,11 +33,19 @@ class URLPath(MPTTModel):
objects
=
managers
.
URLPathManager
()
_default_manager
=
objects
articles
=
generic
.
GenericRelation
(
ArticleForObject
)
articles
=
generic
.
GenericRelation
(
ArticleForObject
,
content_type_field
=
'content_type'
,
object_id_field
=
'object_id'
,
)
# Do NOT modify this field - it is updated with signals whenever ArticleForObject is changed.
article
=
models
.
ForeignKey
(
Article
,
on_delete
=
models
.
CASCADE
,
editable
=
False
,
verbose_name
=
_
(
u'Cache lookup value for articles'
))
article
=
models
.
ForeignKey
(
Article
,
on_delete
=
models
.
CASCADE
,
editable
=
False
,
verbose_name
=
_
(
u'Cache lookup value for articles'
),
)
SLUG_MAX_LENGTH
=
50
...
...
wiki/plugins/notifications/models.py
View file @
6e472422
...
...
@@ -26,13 +26,10 @@ class ArticleSubscription(ArticlePlugin, Subscription):
def
default_url
(
article
,
urlpath
=
None
):
try
:
if
not
urlpath
:
urlpath
=
wiki_models
.
URLPath
.
objects
.
get
(
articles
=
article
)
url
=
reverse
(
'wiki:get'
,
kwargs
=
{
'path'
:
urlpath
.
path
})
except
wiki_models
.
URLPath
.
DoesNotExist
:
url
=
reverse
(
'wiki:get'
,
kwargs
=
{
'article_id'
:
article
.
id
})
return
url
if
urlpath
:
return
reverse
(
'wiki:get'
,
kwargs
=
{
'path'
:
urlpath
.
path
})
return
article
.
get_absolute_url
()
def
post_article_revision_save
(
**
kwargs
):
instance
=
kwargs
[
'instance'
]
...
...
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