From 8d3c540edd0cef12e35d7c1d599755040ad92117 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 17 Sep 2017 13:04:41 +0000 Subject: [PATCH] Added submit API instructions and fixed a bug in error handling for the submission validity checkers. - Legacy-Id: 14126 --- ietf/submit/views.py | 7 ++- ietf/templates/submit/api_submit_info.html | 50 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 ietf/templates/submit/api_submit_info.html diff --git a/ietf/submit/views.py b/ietf/submit/views.py index 77d4e12ad..be933d9b0 100644 --- a/ietf/submit/views.py +++ b/ietf/submit/views.py @@ -80,7 +80,10 @@ def api_submit(request): submission = None def err(code, text): return HttpResponse(text, status=code, reason=text, content_type='text/plain') - if request.method == 'POST': + + if request.method == 'GET': + return render(request, 'submit/api_submit_info.html') + elif request.method == 'POST': e = None try: form = SubmissionAutoUploadForm(request, data=request.POST, files=request.FILES) @@ -107,7 +110,7 @@ def api_submit(request): if errors: raise ValidationError(errors) - errors = [ c.message for c in submission.checks.all() if not c.passed ] + errors = [ c.message for c in submission.checks.all() if c.passed==False ] if errors: raise ValidationError(errors) diff --git a/ietf/templates/submit/api_submit_info.html b/ietf/templates/submit/api_submit_info.html new file mode 100644 index 000000000..e43ae6b50 --- /dev/null +++ b/ietf/templates/submit/api_submit_info.html @@ -0,0 +1,50 @@ +{% extends "base.html" %} +{# Copyright The IETF Trust 2015, All Rights Reserved #} +{% load origin %} + +{% block title %}Draft submission API instructions{% endblock %} + +{% block content %} + {% origin %} +

Draft submission API instructions

+ +

+ A simplified draft submission interface, intended for automation, + is available at {% url 'ietf.submit.views.api_submit' %}. +

+

+ The interface accepts only xml uploads which can be processed on the server, and + requires the user to have a datatracker account. A successful submit still requires + the same email confirmation roundtrip as submissions done through the regular + submission tool. +

+

+ This interface does not provide all the options which the regular submission tool does. + Some limitations: +

+

+

+ It takes 2 parameters: +

+ +

+ It returns an appropriate http result code, and a brief explanatory text message. +

+

+ Here is an example: +

+
+    $ curl -S -F "user=user.name@example.com" -F "xml=@~/draft-user-example.xml" https://datatracker.ietf.org/api/submit
+    Upload of draft-user-example OK, confirmation requests sent to:
+      User Name <user.name@example.com>
+  
+ + +{% endblock %}