Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
rpteam
rp
Commits
7ec225b7
Commit
7ec225b7
authored
Jul 16, 2019
by
Okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding the unpublish api call
parent
f49a1bfe
Pipeline
#2656
passed with stages
in 3 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
apps/rp/models.py
apps/rp/models.py
+8
-0
apps/rp/tests/test_article.py
apps/rp/tests/test_article.py
+19
-0
No files found.
apps/rp/models.py
View file @
7ec225b7
...
...
@@ -204,6 +204,14 @@ class Article(models.Model):
else
:
return
self
.
status
@
transition
(
field
=
status
,
source
=
'PUBLISHED'
,
target
=
'DRAFT'
,
permission
=
"rp.can_change_status"
)
def
unpublish
(
self
):
"""
Unpublish an article from the RP, and reset it back to a _DRAFT_.
"""
pass
@
transition
(
field
=
status
,
source
=
'NEW'
,
target
=
'NEW'
,
permission
=
"rp.can_vote"
)
@
transition
(
field
=
status
,
source
=
'DRAFT'
,
target
=
'DRAFT'
,
...
...
apps/rp/tests/test_article.py
View file @
7ec225b7
...
...
@@ -103,6 +103,11 @@ class TestArticle(TestCase):
self
.
article
.
refresh_from_db
()
assert
self
.
article
.
title
!=
old_title
def
test_unpublish
(
self
):
a
=
ArticleFactory
(
status
=
'PUBLISHED'
)
a
.
unpublish
()
assert
a
.
status
==
'DRAFT'
class
TestArticleViews
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -377,3 +382,17 @@ class TestArticleApi(TestCase):
r
=
self
.
client
.
post
(
'/api/articles/{}/unset-priority/'
.
format
(
a
.
id
))
assert
r
.
status_code
==
200
assert
r
.
data
[
'priority'
]
is
False
def
test_api_unpublish_unauth
(
self
):
a
=
ArticleFactory
(
status
=
'PUBLISHED'
)
r
=
self
.
client
.
post
(
'/api/articles/{}/unpublish/'
.
format
(
a
.
id
))
assert
r
.
status_code
==
401
def
test_api_unpublish
(
self
):
self
.
jedi
.
user_permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
'can_change_status'
))
self
.
client
.
force_login
(
self
.
jedi
)
a
=
ArticleFactory
(
status
=
'PUBLISHED'
)
r
=
self
.
client
.
post
(
'/api/articles/{}/unpublish/'
.
format
(
a
.
id
))
assert
r
.
status_code
==
200
assert
r
.
data
[
'status'
]
==
'DRAFT'
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