Fixed validation in API post_entry.
Added state to API get_entry_serializable
This commit is contained in:
parent
c92aa0d0b2
commit
09e528acbb
@ -95,6 +95,7 @@ def get_entry_serializable(entry, urlgen):
|
|||||||
'description': entry.description,
|
'description': entry.description,
|
||||||
'description_html': entry.description_html,
|
'description_html': entry.description_html,
|
||||||
'media_type': entry.media_type,
|
'media_type': entry.media_type,
|
||||||
|
'state': entry.state,
|
||||||
'permalink': entry.url_for_self(urlgen, qualified=True),
|
'permalink': entry.url_for_self(urlgen, qualified=True),
|
||||||
'media_files': get_media_file_paths(entry.media_files, urlgen)}
|
'media_files': get_media_file_paths(entry.media_files, urlgen)}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import uuid
|
|||||||
|
|
||||||
from os.path import splitext
|
from os.path import splitext
|
||||||
from webob import exc, Response
|
from webob import exc, Response
|
||||||
|
from cgi import FieldStorage
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from celery import registry
|
from celery import registry
|
||||||
|
|
||||||
@ -43,10 +44,18 @@ _log = logging.getLogger(__name__)
|
|||||||
@require_active_login
|
@require_active_login
|
||||||
def post_entry(request):
|
def post_entry(request):
|
||||||
_log.debug('Posting entry')
|
_log.debug('Posting entry')
|
||||||
|
|
||||||
|
if request.method == 'OPTIONS':
|
||||||
|
return json_response({'status': 200})
|
||||||
|
|
||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
|
_log.debug('Must POST against post_entry')
|
||||||
return exc.HTTPBadRequest()
|
return exc.HTTPBadRequest()
|
||||||
|
|
||||||
if not 'file' in request.POST or not hasattr(request.POST['file'], 'file'):
|
if not 'file' in request.POST \
|
||||||
|
or not isinstance(request.POST['file'], FieldStorage) \
|
||||||
|
or not request.POST['file'].file:
|
||||||
|
_log.debug('File field not found')
|
||||||
return exc.HTTPBadRequest()
|
return exc.HTTPBadRequest()
|
||||||
|
|
||||||
media_file = request.POST['file']
|
media_file = request.POST['file']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user