mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-12-23 23:23:06 +11:00
Merge branch 'master' of github.com:bartTC/dpaste.de
This commit is contained in:
commit
fab93971ea
4 changed files with 15 additions and 12 deletions
|
@ -5,18 +5,10 @@ from piston.handler import AnonymousBaseHandler
|
|||
from pastebin.apps.dpaste.models import Snippet
|
||||
|
||||
class SnippetHandler(AnonymousBaseHandler):
|
||||
allowed_methods = ('GET', 'POST')
|
||||
allowed_methods = ('POST',)
|
||||
fields = ('title', 'content',)
|
||||
exclude = ('id', re.compile(r'^private_'))
|
||||
model = Snippet
|
||||
|
||||
def content_size(self, blogpost):
|
||||
return len(blogpost.content)
|
||||
|
||||
def read(self, request, secret_id):
|
||||
post = Snippet.objects.get(secret_id=secret_id)
|
||||
return post
|
||||
|
||||
def create(self, request):
|
||||
if not request.POST.get('content'):
|
||||
return rc.BAD_REQUEST
|
||||
|
|
|
@ -79,6 +79,14 @@ LOGIN_REDIRECT_URL = '/'
|
|||
# Templates
|
||||
#==============================================================================
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'pastebin.disable.DisableCSRF',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
)
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
os.path.join(PROJECT_DIR, PROJECT_MODULE_NAME, 'templates'),
|
||||
)
|
||||
|
@ -91,9 +99,9 @@ INSTALLED_APPS = (
|
|||
'django.contrib.admin',
|
||||
'django.contrib.staticfiles',
|
||||
'mptt',
|
||||
'piston',
|
||||
'pastebin',
|
||||
'pastebin.apps.dpaste',
|
||||
'gunicorn',
|
||||
)
|
||||
|
||||
#==============================================================================
|
||||
|
|
|
@ -16,11 +16,11 @@ urlpatterns = patterns('',
|
|||
|
||||
# Bla
|
||||
(r'^i18n/', include('django.conf.urls.i18n')),
|
||||
(r'^admin/(.*)', include(admin.site.urls)),
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
|
||||
# API
|
||||
url(r'^api/(?P<secret_id>[^/]+)/$', snippet_resource),
|
||||
url(r'^api/$', snippet_resource),
|
||||
)
|
||||
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
|
|
3
pastebin/disable.py
Normal file
3
pastebin/disable.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
class DisableCSRF(object):
|
||||
def process_request(self, request):
|
||||
setattr(request, '_dont_enforce_csrf_checks', True)
|
Loading…
Reference in a new issue