diff options
| author | Joar Wandborg <git@wandborg.com> | 2012-09-17 23:54:27 +0200 | 
|---|---|---|
| committer | Joar Wandborg <git@wandborg.com> | 2012-09-17 23:54:27 +0200 | 
| commit | 09e528acbb4d1321fce5cec8b22fd7fd153bf68a (patch) | |
| tree | 0697f41fb689d66b5065eb08d1980b527680800f | |
| parent | c92aa0d0b21e01223db7eeaa2fcea4d961b512d9 (diff) | |
| download | mediagoblin-09e528acbb4d1321fce5cec8b22fd7fd153bf68a.tar.lz mediagoblin-09e528acbb4d1321fce5cec8b22fd7fd153bf68a.tar.xz mediagoblin-09e528acbb4d1321fce5cec8b22fd7fd153bf68a.zip | |
Fixed validation in API post_entry.
Added state to API get_entry_serializable
| -rw-r--r-- | mediagoblin/plugins/api/tools.py | 1 | ||||
| -rw-r--r-- | mediagoblin/plugins/api/views.py | 11 | 
2 files changed, 11 insertions, 1 deletions
| diff --git a/mediagoblin/plugins/api/tools.py b/mediagoblin/plugins/api/tools.py index e5aca29b..c4630ba7 100644 --- a/mediagoblin/plugins/api/tools.py +++ b/mediagoblin/plugins/api/tools.py @@ -95,6 +95,7 @@ def get_entry_serializable(entry, urlgen):              'description': entry.description,              'description_html': entry.description_html,              'media_type': entry.media_type, +            'state': entry.state,              'permalink': entry.url_for_self(urlgen, qualified=True),              'media_files': get_media_file_paths(entry.media_files, urlgen)} diff --git a/mediagoblin/plugins/api/views.py b/mediagoblin/plugins/api/views.py index 2eb9e414..d537ec6e 100644 --- a/mediagoblin/plugins/api/views.py +++ b/mediagoblin/plugins/api/views.py @@ -20,6 +20,7 @@ import uuid  from os.path import splitext  from webob import exc, Response +from cgi import FieldStorage  from werkzeug.utils import secure_filename  from celery import registry @@ -43,10 +44,18 @@ _log = logging.getLogger(__name__)  @require_active_login  def post_entry(request):      _log.debug('Posting entry') + +    if request.method == 'OPTIONS': +        return json_response({'status': 200}) +      if request.method != 'POST': +        _log.debug('Must POST against post_entry')          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()      media_file = request.POST['file'] | 
