Commit 6256b9dc authored by Tristan Cavelier's avatar Tristan Cavelier

erp5_officejs_support_request_ui: use SupportRequest_getCommentPostListAsJson

instead of PostModule_getAscendingRelatedPostListAsJson
parent 05f84873
...@@ -127,8 +127,7 @@ ...@@ -127,8 +127,7 @@
.push(function () { .push(function () {
return gadget.jio_getAttachment( return gadget.jio_getAttachment(
'post_module', 'post_module',
gadget.hateoas_url + 'post_module/PostModule_getAscendingRelatedPostListAsJson' gadget.hateoas_url + gadget.options.jio_key + "/SupportRequest_getCommentPostListAsJson"
+ "?follow_up=" + gadget.options.jio_key
); );
}) })
.push(function (post_list) { .push(function (post_list) {
......
from json import dumps from json import dumps
portal = context.getPortalObject() portal = context.getPortalObject()
comment_list = [] preferred_date_order = portal.portal_preferences.getPreferredDateOrder() or "ymd"
if not follow_up: preferred_date_order = "/".join(preferred_date_order)
return dumps(comment_list) def formatDate(date):
# get the follow up object
object_list = portal.portal_catalog(relative_url=follow_up) # with id keyword, this function will return a sequence data type which contains one element.
if object_list:
follow_up_object = object_list[0].getObject()
else:
raise NotImplementedError(follow_up)
# get the all HTML Posts which related to this follow up object
post_list = portal.portal_catalog(portal_type="HTML Post", strict_follow_up_uid=follow_up_object.getUid(), sort_on=(('modification_date', 'ascending'),), validation_state="published") # with id keyword, this function will return a sequence data type which contains one element.
preferred_date_order = portal.portal_preferences.getPreferredDateOrder()
def format_date(date):
# XXX modification date & creation date are still in server timezone. # XXX modification date & creation date are still in server timezone.
# See merge request !17 # See merge request !17
# #
# if default_time_zone: # if default_time_zone:
# date = date.toZone(default_time_zone) # date = date.toZone(default_time_zone)
if preferred_date_order == 'dmy': return date.strftime("%s %%H:%%M" %(
return "%s/%s/%s   %s" % (date.dd(), date.mm(), date.year(), date.TimeMinutes()) preferred_date_order.
if preferred_date_order == 'mdy': replace("y", "%Y").
return "%s/%s/%s   %s" % (date.mm(), date.dd(), date.year(), date.TimeMinutes()) replace("m", "%m").
# ymd replace("d", "%d"),
return "%s/%s/%s   %s" % (date.year(), date.mm(), date.dd(), date.TimeMinutes()) ))
post_list = portal.portal_catalog(
portal_type="HTML Post",
strict_follow_up_uid=context.getUid(),
sort_on=(('modification_date', 'ascending'),),
validation_state="published",
)
comment_list = []
for post in post_list: for post in post_list:
owner = post.Base_getOwnerTitle() owner = post.Base_getOwnerTitle()
time_stamp = format_date(post.getStartDate()) time_stamp = formatDate(post.getStartDate())
content = post.getTextContent() content = post.getTextContent()
successor_list = post.getSuccessorValueList() successor_list = post.getSuccessorValueList()
successor_name = successor_link = None successor_name = successor_link = None
if successor_list: if successor_list:
successor_link, successor_name = successor_list[0].getRelativeUrl(), successor_list[0].getFilename() successor_link, successor_name = successor_list[0].getRelativeUrl(), successor_list[0].getFilename()
comment_list.append((owner, time_stamp, content, successor_link, successor_name)) comment_list.append((owner, time_stamp, content, successor_link, successor_name))
return dumps(comment_list) return dumps(comment_list)
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>follow_up</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>PostModule_getAscendingRelatedPostListAsJson</string> </value> <value> <string>SupportRequest_getCommentPostListAsJson</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment