Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Lu Xu
erp5
Commits
c9cc425e
Commit
c9cc425e
authored
Nov 08, 2013
by
Tristan Cavelier
Committed by
Sebastien Robin
Nov 08, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_jio: more hardcoded code to handle task reports + code to handle query
parent
770c5009
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
417 additions
and
131 deletions
+417
-131
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_allDocs.xml
...io/SkinTemplateItem/portal_skins/erp5_jio/JIO_allDocs.xml
+13
-9
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_class.xml
..._jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_class.xml
+371
-81
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_get.xml
...p5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_get.xml
+1
-1
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_getAttachment.xml
...nTemplateItem/portal_skins/erp5_jio/JIO_getAttachment.xml
+1
-1
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_post.xml
...5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_post.xml
+7
-6
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_put.xml
...p5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_put.xml
+5
-5
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_putAttachment.xml
...nTemplateItem/portal_skins/erp5_jio/JIO_putAttachment.xml
+4
-4
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_remove.xml
...jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_remove.xml
+3
-3
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_removeAttachment.xml
...mplateItem/portal_skins/erp5_jio/JIO_removeAttachment.xml
+11
-20
bt5/erp5_jio/bt/revision
bt5/erp5_jio/bt/revision
+1
-1
No files found.
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_allDocs.xml
View file @
c9cc425e
...
@@ -51,24 +51,28 @@
...
@@ -51,24 +51,28 @@
<item>
<item>
<key>
<string>
_body
</string>
</key>
<key>
<string>
_body
</string>
</key>
<value>
<string>
import json\n
<value>
<string>
import json\n
from Products.ERP5Type.Log import log\n
#
from Products.ERP5Type.Log import log\n
# use JSON.parse as json.loads and JSON.stringify as json.dumps\n
# use JSON.parse as json.loads and JSON.stringify as json.dumps\n
\n
\n
context.REQUEST.response.setHeader("Access-Control-Allow-Origin", "*")\n
context.REQUEST.response.setHeader("Access-Control-Allow-Origin", "*")\n
\n
\n
try: option = json.loads(context.REQUEST.form["option"])\n
jio = context.JIO_class()\n
\n
try: option = jio.jsonUtf8Loads(context.REQUEST.form["option"])\n
except KeyError:\n
except KeyError:\n
option = {}\n
option = {}\n
try:\n
mode = str(context.REQUEST.form["mode"])\n
except KeyError:\n
mode = "normal"\n
\n
\n
jio = context.JIO_class(mode=mode)\n
try: mode = str(context.REQUEST.form["mode"])\n
except KeyError: mode = "generic"\n
jio.setMode(mode)\n
\n
metadata_json = jio.getAllDocuments(option)\n
\n
return jio.sendSuccess(metadata_json)\n
\n
\n
document_list = context.portal_catalog(portal_type="Web Page")\n
#
document_list = context.portal_catalog(portal_type="Web Page")\n
\n
\n
return jio.sendSuccess(jio.getAllDocsFromDocumentList(document_list, include_docs=option.get("include_docs")))\n
#
return jio.sendSuccess(jio.getAllDocsFromDocumentList(document_list, include_docs=option.get("include_docs")))\n
</string>
</value>
</string>
</value>
</item>
</item>
<item>
<item>
...
...
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_class.xml
View file @
c9cc425e
This diff is collapsed.
Click to expand it.
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_get.xml
View file @
c9cc425e
...
@@ -75,7 +75,7 @@ jio.setMode(mode)\n
...
@@ -75,7 +75,7 @@ jio.setMode(mode)\n
try:\n
try:\n
metadata_json =
jio.getDocumentMetadata(doc)\n
metadata_json =
jio.getDocumentMetadata(doc)\n
except
ValueError
as
e:\n
except
ValueError
as
e:\n
return
jio.sendError(jio.create
BadReques
tDict("Cannot
get
document",
str(e)))\n
return
jio.sendError(jio.create
Conflic
tDict("Cannot
get
document",
str(e)))\n
except
LookupError
as
e:\n
except
LookupError
as
e:\n
return
jio.sendError(jio.createNotFoundDict("Cannot
get
document",
str(e)))\n
return
jio.sendError(jio.createNotFoundDict("Cannot
get
document",
str(e)))\n
\n
\n
...
...
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_getAttachment.xml
View file @
c9cc425e
...
@@ -75,7 +75,7 @@ jio.setMode(mode)\n
...
@@ -75,7 +75,7 @@ jio.setMode(mode)\n
try:\n
try:\n
attachment_data =
jio.getDocumentAttachment(doc)\n
attachment_data =
jio.getDocumentAttachment(doc)\n
except
ValueError
as
e:\n
except
ValueError
as
e:\n
return
jio.sendError(jio.create
BadReques
tDict("Cannot
get
attachment",
str(e)))\n
return
jio.sendError(jio.create
Conflic
tDict("Cannot
get
attachment",
str(e)))\n
except
LookupError
as
e:\n
except
LookupError
as
e:\n
return
jio.sendError(jio.createNotFoundDict("Cannot
get
attachment",
str(e)))\n
return
jio.sendError(jio.createNotFoundDict("Cannot
get
attachment",
str(e)))\n
\n
\n
...
...
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_post.xml
View file @
c9cc425e
...
@@ -60,7 +60,8 @@ jio = context.JIO_class()\n
...
@@ -60,7 +60,8 @@ jio = context.JIO_class()\n
\n
\n
try: doc = jio.jsonUtf8Loads(context.REQUEST.form["doc"])\n
try: doc = jio.jsonUtf8Loads(context.REQUEST.form["doc"])\n
except KeyError:\n
except KeyError:\n
return jio.sendError(jio.createBadRequestDict("Cannot get document", "No document information received"))\n
return jio.sendError(jio.createBadRequestDict(\n
"Cannot get document", "No document information received"))\n
\n
\n
try: mode = str(context.REQUEST.form["mode"])\n
try: mode = str(context.REQUEST.form["mode"])\n
except KeyError: mode = "generic"\n
except KeyError: mode = "generic"\n
...
@@ -68,12 +69,12 @@ jio.setMode(mode)\n
...
@@ -68,12 +69,12 @@ jio.setMode(mode)\n
\n
\n
try:\n
try:\n
response_json = jio.putDocumentMetadata(doc, overwrite=False)\n
response_json = jio.putDocumentMetadata(doc, overwrite=False)\n
except ValueError as e:\n
except (ValueError, TypeError, LookupError) as e:\n
return jio.sendError(jio.createBadRequestDict("Cannot post document", str(e)))\n
except TypeError as e:\n
return jio.sendError(jio.createBadRequestDict("Cannot post document", str(e)))\n
except LookupError as e:\n
return jio.sendError(jio.createConflictDict("Cannot post document", str(e)))\n
return jio.sendError(jio.createConflictDict("Cannot post document", str(e)))\n
# except KeyError as e:\n
# return jio.sendError(jio.createForbiddenDict("Cannot post document", str(e)))\n
# except LookupError as e:\n
# return jio.sendError(jio.createConflictDict("Cannot post document", str(e)))\n
\n
\n
return jio.sendSuccess(response_json)\n
return jio.sendSuccess(response_json)\n
</string>
</value>
</string>
</value>
...
...
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_put.xml
View file @
c9cc425e
...
@@ -67,11 +67,11 @@ except KeyError: mode = "generic"\n
...
@@ -67,11 +67,11 @@ except KeyError: mode = "generic"\n
jio.setMode(mode)\n
jio.setMode(mode)\n
\n
\n
try:\n
try:\n
response_json = jio.putDocumentMetadata(doc)\n
response_json = jio.putDocumentMetadata(doc
, need_id=True
)\n
except
ValueError
as e:\n
except
(ValueError, TypeError, KeyError)
as e:\n
return jio.sendError(jio.create
BadReques
tDict("Cannot put document", str(e)))\n
return jio.sendError(jio.create
Conflic
tDict("Cannot put document", str(e)))\n
except Type
Error as e:\n
# except Key
Error as e:\n
return jio.sendError(jio.createBadRequest
Dict("Cannot put document", str(e)))\n
# return jio.sendError(jio.createForbidden
Dict("Cannot put document", str(e)))\n
\n
\n
return jio.sendSuccess(response_json)\n
return jio.sendSuccess(response_json)\n
</string>
</value>
</string>
</value>
...
...
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_putAttachment.xml
View file @
c9cc425e
...
@@ -68,10 +68,10 @@ jio.setMode(mode)\n
...
@@ -68,10 +68,10 @@ jio.setMode(mode)\n
\n
\n
try:\n
try:\n
response_json = jio.putDocumentAttachment(doc)\n
response_json = jio.putDocumentAttachment(doc)\n
except
ValueError
as e:\n
except
(ValueError, TypeError, KeyError)
as e:\n
return jio.sendError(jio.create
BadReques
tDict("Cannot put attachment", str(e)))\n
return jio.sendError(jio.create
Conflic
tDict("Cannot put attachment", str(e)))\n
except TypeError as e:\n
#
except TypeError as e:\n
return jio.sendError(jio.createBadRequestDict("Cannot put attachment", str(e)))\n
#
return jio.sendError(jio.createBadRequestDict("Cannot put attachment", str(e)))\n
\n
\n
return jio.sendSuccess(response_json)\n
return jio.sendSuccess(response_json)\n
</string>
</value>
</string>
</value>
...
...
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_remove.xml
View file @
c9cc425e
...
@@ -68,10 +68,10 @@ jio.setMode(mode)\n
...
@@ -68,10 +68,10 @@ jio.setMode(mode)\n
\n
\n
try:\n
try:\n
response_json = jio.removeDocument(doc)\n
response_json = jio.removeDocument(doc)\n
except ValueError as e:\n
except (ValueError, TypeError) as e:\n
return jio.sendError(jio.createBadRequestDict("Cannot remove document", str(e)))\n
except TypeError as e:\n
return jio.sendError(jio.createBadRequestDict("Cannot remove document", str(e)))\n
return jio.sendError(jio.createBadRequestDict("Cannot remove document", str(e)))\n
except LookupError as e:\n
return jio.sendError(jio.createNotFoundDict("Cannot remove document", str(e)))\n
\n
\n
return jio.sendSuccess(response_json)\n
return jio.sendSuccess(response_json)\n
</string>
</value>
</string>
</value>
...
...
bt5/erp5_jio/SkinTemplateItem/portal_skins/erp5_jio/JIO_removeAttachment.xml
View file @
c9cc425e
...
@@ -58,31 +58,22 @@ context.REQUEST.response.setHeader("Access-Control-Allow-Origin", "*")\n
...
@@ -58,31 +58,22 @@ context.REQUEST.response.setHeader("Access-Control-Allow-Origin", "*")\n
\n
\n
jio = context.JIO_class()\n
jio = context.JIO_class()\n
\n
\n
try:\n
try: doc = jio.jsonUtf8Loads(context.REQUEST.form["doc"])\n
doc = json.loads(context.REQUEST.form["doc"])\n
except IndexError:\n
return jio.sendError(jio.createBadRequestErrorObject("Unable to operate put request", "No document received"))\n
try:\n
mode = str(context.REQUEST.form["mode"])\n
except KeyError:\n
except KeyError:\n
mode = "normal"
\n
return jio.sendError(jio.createBadRequestDict("Cannot get document", "No document information received"))
\n
\n
\n
try: mode = str(context.REQUEST.form["mode"])\n
except KeyError: mode = "generic"\n
jio.setMode(mode)\n
jio.setMode(mode)\n
\n
\n
doc = jio.recursiveEncodeToUtf8(doc)\n
try:\n
\n
response_json = jio.removeAttachment(doc)\n
if not isinstance(doc.get("_id"), str) or doc.get("_id") == "":\n
except (ValueError, TypeError) as e:\n
return jio.sendError(jio.createBadRequestErrorObject("Unable to operate put request", "Document id is missing"))\n
return jio.sendError(jio.createConflictDict("Cannot remove attachment", str(e)))\n
\n
except LookupError as e:\n
document_list = jio.getDocumentListFromId(doc.get("_id"))\n
return jio.sendError(jio.createNotFoundDict("Cannot remove attachment", str(e)))\n
\n
if len(document_list) == 0:\n
return jio.sendError(jio.createNotFoundErrorObject("Unable to find \\"" + doc.get("_id") + "\\"", "Document not found"))\n
else:\n
# TODO manage several documents\n
jio.removeAttachment(document_list[0], doc)\n
\n
\n
return jio.sendSuccess({"ok": True, "id": doc["_id"], "attachment": doc["_attachment"]}
)\n
return jio.sendSuccess(response_json
)\n
</string>
</value>
</string>
</value>
</item>
</item>
<item>
<item>
...
...
bt5/erp5_jio/bt/revision
View file @
c9cc425e
2
3
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment