Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
056924ad
Commit
056924ad
authored
13 years ago
by
Bridger Maxwell
Browse files
Options
Downloads
Patches
Plain Diff
Got most of deleting working.
--HG-- branch : bridgerwiki
parent
b3797a41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
simplewiki/views.py
+15
-7
15 additions, 7 deletions
simplewiki/views.py
with
15 additions
and
7 deletions
simplewiki/views.py
+
15
−
7
View file @
056924ad
...
...
@@ -32,7 +32,7 @@ def view(request, wiki_url):
if
err
:
return
err
perm_err
=
check_permissions
(
request
,
article
,
check_read
=
True
)
perm_err
=
check_permissions
(
request
,
article
,
check_read
=
True
,
check_deleted
=
True
)
if
perm_err
:
return
perm_err
d
=
{
'
wiki_article
'
:
article
,
...
...
@@ -81,7 +81,7 @@ def create(request, wiki_url):
d
.
update
(
csrf
(
request
))
return
render_to_response
(
'
simplewiki_error.html
'
,
d
)
perm_err
=
check_permissions
(
request
,
path
[
-
1
],
check_locked
=
False
,
check_write
=
True
)
perm_err
=
check_permissions
(
request
,
path
[
-
1
],
check_locked
=
False
,
check_write
=
True
,
check_deleted
=
True
)
if
perm_err
:
return
perm_err
# Ensure doesn't already exist
...
...
@@ -136,7 +136,7 @@ def edit(request, wiki_url):
return
err
# Check write permissions
perm_err
=
check_permissions
(
request
,
article
,
check_write
=
True
,
check_locked
=
True
)
perm_err
=
check_permissions
(
request
,
article
,
check_write
=
True
,
check_locked
=
True
,
check_deleted
=
False
)
if
perm_err
:
return
perm_err
...
...
@@ -187,7 +187,7 @@ def history(request, wiki_url, page=1):
if
err
:
return
err
perm_err
=
check_permissions
(
request
,
article
,
check_read
=
True
)
perm_err
=
check_permissions
(
request
,
article
,
check_read
=
True
,
check_deleted
=
False
)
if
perm_err
:
return
perm_err
...
...
@@ -285,12 +285,18 @@ def search_articles(request):
else
:
# Need to throttle results by splitting them into pages...
results
=
Article
.
objects
.
all
()
if
request
.
user
.
is_superuser
:
results
=
results
.
order_by
(
'
current_revision__deleted
'
)
else
:
print
"
tried to filter
"
results
=
results
.
filter
(
current_revision__deleted
=
0
)
if
results
.
count
()
==
1
and
querystring
:
return
HttpResponseRedirect
(
reverse
(
'
wiki_view
'
,
args
=
(
results
[
0
].
get_url
(),)))
else
:
d
=
{
'
wiki_search_results
'
:
results
,
'
wiki_search_query
'
:
querystring
}
'
wiki_search_query
'
:
querystring
,
}
d
.
update
(
csrf
(
request
))
return
render_to_response
(
'
simplewiki_searchresults.html
'
,
d
)
...
...
@@ -426,13 +432,15 @@ def fetch_from_url(request, url):
return
(
article
,
path
,
err
)
def
check_permissions
(
request
,
article
,
check_read
=
False
,
check_write
=
False
,
check_locked
=
False
,
check_deleted
=
True
):
def
check_permissions
(
request
,
article
,
check_read
=
False
,
check_write
=
False
,
check_locked
=
False
,
check_deleted
=
False
):
read_err
=
check_read
and
not
article
.
can_read
(
request
.
user
)
write_err
=
check_write
and
not
article
.
can_write
(
request
.
user
)
locked_err
=
check_locked
and
article
.
locked
deleted_err
=
check_deleted
and
not
(
article
.
current_revision
.
deleted
==
0
)
if
request
.
user
.
is_superuser
:
if
(
request
.
user
.
is_superuser
)
:
deleted_err
=
False
if
read_err
or
write_err
or
locked_err
or
deleted_err
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment