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
3a876d92
Commit
3a876d92
authored
Aug 13, 2012
by
benjaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Block anonymous access to upload files
parent
d1f50d11
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
96 additions
and
14 deletions
+96
-14
TODO.md
+2
-2
testproject/testproject/settings.py
+2
-0
wiki/conf/settings.py
+4
-0
wiki/plugins/attachments/settings.py
+3
-0
wiki/plugins/attachments/templates/wiki/plugins/attachments/index.html
+4
-0
wiki/plugins/attachments/views.py
+16
-11
wiki/plugins/images/settings.py
+4
-1
wiki/plugins/images/views.py
+13
-0
wiki/plugins/images/wiki_plugin.py
+35
-0
wiki/templates/wiki/includes/anonymous_blocked.html
+13
-0
No files found.
TODO.md
View file @
3a876d92
...
@@ -13,11 +13,11 @@ Not implemented - will be ASAP
...
@@ -13,11 +13,11 @@ Not implemented - will be ASAP
*
Key-value meta data
*
Key-value meta data
*
Index views for urlpaths
*
Index views for urlpaths
*
Searching
*
Searching
*
South migrations
**
Soon
**
*
South migrations
**
Done
**
*
View source for read-only articles + locked status
*
View source for read-only articles + locked status
*
Global moderator permission
**Almost done**
(need to add grant form for users with
*grant*
permissions)
*
Global moderator permission
**Almost done**
(need to add grant form for users with
*grant*
permissions)
*
Are you sure you wanna leave this page?
*
Are you sure you wanna leave this page?
*
Special view for deleted articles w/ restore button
*
Special view for deleted articles w/ restore button
**Done**
Ideas
Ideas
=====
=====
...
...
testproject/testproject/settings.py
View file @
3a876d92
...
@@ -9,6 +9,8 @@ ADMINS = (
...
@@ -9,6 +9,8 @@ ADMINS = (
# ('Your Name', 'your_email@example.com'),
# ('Your Name', 'your_email@example.com'),
)
)
LOGIN_URL
=
'/_accounts/login/'
MANAGERS
=
ADMINS
MANAGERS
=
ADMINS
DATABASES
=
{
DATABASES
=
{
...
...
wiki/conf/settings.py
View file @
3a876d92
...
@@ -8,6 +8,8 @@ URL_CASE_SENSITIVE = getattr(django_settings, 'WIKI_URL_CASE_SENSITIVE', False)
...
@@ -8,6 +8,8 @@ URL_CASE_SENSITIVE = getattr(django_settings, 'WIKI_URL_CASE_SENSITIVE', False)
APP_LABEL
=
'wiki'
APP_LABEL
=
'wiki'
WIKI_LANGUAGE
=
'markdown'
WIKI_LANGUAGE
=
'markdown'
# The editor class to use -- maybe a 3rd party or your own...? You can always
# extend the built-in editor and customize it....
EDITOR
=
getattr
(
django_settings
,
'WIKI_EDITOR'
,
'wiki.editors.MarkItUp'
)
EDITOR
=
getattr
(
django_settings
,
'WIKI_EDITOR'
,
'wiki.editors.MarkItUp'
)
# This slug is used in URLPath if an article has been deleted. The children of the
# This slug is used in URLPath if an article has been deleted. The children of the
...
@@ -15,9 +17,11 @@ EDITOR = getattr(django_settings, 'WIKI_EDITOR', 'wiki.editors.MarkItUp')
...
@@ -15,9 +17,11 @@ EDITOR = getattr(django_settings, 'WIKI_EDITOR', 'wiki.editors.MarkItUp')
# and all their content.
# and all their content.
LOST_AND_FOUND_SLUG
=
getattr
(
django_settings
,
'WIKI_LOST_AND_FOUND_SLUG'
,
'lost-and-found'
)
LOST_AND_FOUND_SLUG
=
getattr
(
django_settings
,
'WIKI_LOST_AND_FOUND_SLUG'
,
'lost-and-found'
)
# Do we want to log IPs?
LOG_IPS_ANONYMOUS
=
getattr
(
django_settings
,
'WIKI_LOG_IPS_ANONYMOUS'
,
True
)
LOG_IPS_ANONYMOUS
=
getattr
(
django_settings
,
'WIKI_LOG_IPS_ANONYMOUS'
,
True
)
LOG_IPS_USERS
=
getattr
(
django_settings
,
'WIKI_LOG_IPS_USERS'
,
False
)
LOG_IPS_USERS
=
getattr
(
django_settings
,
'WIKI_LOG_IPS_USERS'
,
False
)
# Sign up, login and logout views should be accessible
ACCOUNT_HANDLING
=
getattr
(
django_settings
,
'WIKI_ACCOUNT_HANDLING'
,
True
)
ACCOUNT_HANDLING
=
getattr
(
django_settings
,
'WIKI_ACCOUNT_HANDLING'
,
True
)
# Maximum amount of children to display in a menu before going "+more"
# Maximum amount of children to display in a menu before going "+more"
...
...
wiki/plugins/attachments/settings.py
View file @
3a876d92
...
@@ -2,6 +2,9 @@ from django.conf import settings as django_settings
...
@@ -2,6 +2,9 @@ from django.conf import settings as django_settings
SLUG
=
"attachments"
SLUG
=
"attachments"
# Allow anonymous users to upload (not nice on an open network)
ANONYMOUS
=
getattr
(
django_settings
,
'WIKI_ATTACHMENTS_ANONYMOUS'
,
False
)
# Maximum file sizes: Please using something like LimitRequestBody on
# Maximum file sizes: Please using something like LimitRequestBody on
# your web server.
# your web server.
# http://httpd.apache.org/docs/2.2/mod/core.html#LimitRequestBody
# http://httpd.apache.org/docs/2.2/mod/core.html#LimitRequestBody
...
...
wiki/plugins/attachments/templates/wiki/plugins/attachments/index.html
View file @
3a876d92
...
@@ -82,12 +82,16 @@
...
@@ -82,12 +82,16 @@
<div
id=
"collapse_upload"
class=
"accordion-body collapse{% if form.errors %} in{% endif %}"
>
<div
id=
"collapse_upload"
class=
"accordion-body collapse{% if form.errors %} in{% endif %}"
>
<div
class=
"accordion-inner"
>
<div
class=
"accordion-inner"
>
{% if anonymous_disallowed %}
{% include "wiki/includes/anonymous_blocked.html" %}
{% else %}
<form
method=
"POST"
class=
"form-vertical"
id=
"attachment_form"
enctype=
"multipart/form-data"
>
<form
method=
"POST"
class=
"form-vertical"
id=
"attachment_form"
enctype=
"multipart/form-data"
>
{% wiki_form form %}
{% wiki_form form %}
<button
type=
"submit"
name=
"save"
value=
"1"
class=
"btn btn-large"
>
<button
type=
"submit"
name=
"save"
value=
"1"
class=
"btn btn-large"
>
{% trans "Upload file" %}
{% trans "Upload file" %}
</button>
</button>
</form>
</form>
{% endif %}
</div>
</div>
</div>
</div>
...
...
wiki/plugins/attachments/views.py
View file @
3a876d92
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
django.conf
import
settings
as
django_settings
from
django.contrib
import
messages
from
django.db
import
transaction
from
django.db.models
import
Q
from
django.http
import
Http404
from
django.shortcuts
import
redirect
,
get_object_or_404
from
django.shortcuts
import
redirect
,
get_object_or_404
from
django.utils.decorators
import
method_decorator
from
django.utils.decorators
import
method_decorator
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.views.generic.edit
import
FormView
from
django.db.models
import
Q
from
wiki.views.mixins
import
ArticleMixin
from
wiki.decorators
import
get_article
from
wiki.plugins.attachments
import
forms
from
wiki.plugins.attachments
import
models
from
django.contrib
import
messages
from
django.views.generic.base
import
TemplateView
,
View
from
django.views.generic.base
import
TemplateView
,
View
from
wiki.core.http
import
send_file
from
django.views.generic.edit
import
FormView
from
django.http
import
Http404
from
django.db
import
transaction
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
wiki.core.http
import
send_file
from
wiki.decorators
import
get_article
from
wiki.plugins.attachments
import
models
,
settings
,
forms
from
wiki.views.mixins
import
ArticleMixin
class
AttachmentView
(
ArticleMixin
,
FormView
):
class
AttachmentView
(
ArticleMixin
,
FormView
):
form_class
=
forms
.
AttachmentForm
form_class
=
forms
.
AttachmentForm
...
@@ -34,6 +35,9 @@ class AttachmentView(ArticleMixin, FormView):
...
@@ -34,6 +35,9 @@ class AttachmentView(ArticleMixin, FormView):
# WARNING! The below decorator silences other exceptions that may occur!
# WARNING! The below decorator silences other exceptions that may occur!
#@transaction.commit_manually
#@transaction.commit_manually
def
form_valid
(
self
,
form
):
def
form_valid
(
self
,
form
):
if
self
.
request
.
user
.
is_anonymous
and
not
settings
.
ANONYMOUS
:
return
redirect
(
django_settings
.
LOGIN_URL
)
try
:
try
:
attachment_revision
=
form
.
save
(
commit
=
False
)
attachment_revision
=
form
.
save
(
commit
=
False
)
attachment
=
models
.
Attachment
()
attachment
=
models
.
Attachment
()
...
@@ -59,6 +63,7 @@ class AttachmentView(ArticleMixin, FormView):
...
@@ -59,6 +63,7 @@ class AttachmentView(ArticleMixin, FormView):
kwargs
[
'attachments'
]
=
self
.
attachments
kwargs
[
'attachments'
]
=
self
.
attachments
kwargs
[
'search_form'
]
=
forms
.
SearchForm
()
kwargs
[
'search_form'
]
=
forms
.
SearchForm
()
kwargs
[
'selected_tab'
]
=
'attachments'
kwargs
[
'selected_tab'
]
=
'attachments'
kwargs
[
'anonymous_disallowed'
]
=
self
.
request
.
user
.
is_anonymous
and
not
settings
.
ANONYMOUS
return
super
(
AttachmentView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AttachmentView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
wiki/plugins/images/settings.py
View file @
3a876d92
from
django.conf
import
settings
as
django_settings
from
django.conf
import
settings
as
django_settings
# Where to store images
# Where to store images
IMAGE_PATH
=
getattr
(
django_settings
,
"WIKI_IMAGE_PATH"
,
'wiki/images/
%
aid/'
)
IMAGE_PATH
=
getattr
(
django_settings
,
'WIKI_IMAGE_PATH'
,
"wiki/images/
%
aid/"
)
SLUG
=
'images'
\ No newline at end of file
wiki/plugins/images/views.py
0 → 100644
View file @
3a876d92
from
wiki.views.mixins
import
ArticleMixin
from
django.views.generic.base
import
TemplateView
from
django.utils.decorators
import
method_decorator
from
wiki.decorators
import
get_article
class
ImageView
(
ArticleMixin
,
TemplateView
):
@method_decorator
(
get_article
(
can_read
=
True
))
def
dispatch
(
self
,
request
,
article
,
*
args
,
**
kwargs
):
return
super
(
ImageView
,
self
)
.
dispatch
(
request
,
article
,
*
args
,
**
kwargs
)
\ No newline at end of file
wiki/plugins/images/wiki_plugin.py
0 → 100644
View file @
3a876d92
# -*- coding: utf-8 -*-
from
django.conf.urls.defaults
import
patterns
,
url
from
django.utils.translation
import
ugettext
as
_
from
wiki.core
import
plugins_registry
from
wiki
import
plugins
from
wiki.plugins.images
import
views
,
models
,
settings
from
wiki.plugins.notifications
import
ARTICLE_EDIT
class
ImagePlugin
(
plugins
.
BasePlugin
):
#settings_form = 'wiki.plugins.notifications.forms.SubscriptionForm'
slug
=
settings
.
SLUG
urlpatterns
=
patterns
(
''
,
url
(
'^$'
,
views
.
ImageView
.
as_view
(),
name
=
'images_index'
),
)
# List of notifications to construct signal handlers for. This
# is handled inside the notifications plugin.
notifications
=
[{
'model'
:
models
.
Image
,
'message'
:
lambda
obj
:
_
(
u"An image was added:
%
s"
)
%
obj
.
get_filename
(),
'key'
:
ARTICLE_EDIT
,
'created'
:
True
,
'get_article'
:
lambda
obj
:
obj
.
attachment
.
article
}
]
#markdown_extensions = [AttachmentExtension()]
def
__init__
(
self
):
#print "I WAS LOADED!"
pass
plugins_registry
.
register
(
ImagePlugin
)
wiki/templates/wiki/includes/anonymous_blocked.html
0 → 100644
View file @
3a876d92
{% load i18n %}
{% load url from future %}
<em>
{% url 'wiki:signup' as signup_url %}
{% url 'wiki:login' as login_url %}
{% if login_url and signup_url %}
{% blocktrans %}
You need to
<a
href=
"{{ login_url }}"
>
log in
</a>
or
<a
href=
"{{ signup_url }}"
>
sign up
</a>
to use this function.
{% endblocktrans %}
{% else %}
{% trans "You need to log in og sign up to use this function." %}
{% endif %}
</em>
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