mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
Use Django's built-in @require_POST decorator
Theirs returns an actual 405 (imported from commit 31be790b0f53d7b63d7d3cd85972b16add3d8c74)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.http import require_POST
|
||||
from zephyr.models import UserProfile, UserActivity, get_client
|
||||
from zephyr.lib.response import json_success, json_error
|
||||
from django.utils.timezone import now
|
||||
@@ -30,13 +31,8 @@ def asynchronous(method):
|
||||
wrapper.csrf_exempt = True
|
||||
return wrapper
|
||||
|
||||
def require_post(view_func):
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(request, *args, **kwargs):
|
||||
if request.method != "POST":
|
||||
return json_error('This form can only be submitted by POST.')
|
||||
return view_func(request, *args, **kwargs)
|
||||
return _wrapped_view_func
|
||||
# I like the all-lowercase name better
|
||||
require_post = require_POST
|
||||
|
||||
def parse_client(request, default):
|
||||
client_name = default
|
||||
|
||||
@@ -119,7 +119,7 @@ class PublicURLTest(TestCase):
|
||||
# through Tornado.
|
||||
urls = {200: ["/accounts/home/", "/accounts/login/"],
|
||||
302: ["/", "/accounts/logout/"],
|
||||
400: ["/accounts/register/",
|
||||
405: ["/accounts/register/",
|
||||
"/api/v1/get_public_streams",
|
||||
"/api/v1/subscriptions/list",
|
||||
"/api/v1/subscriptions/add",
|
||||
|
||||
Reference in New Issue
Block a user