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 @@
.push(function () {
return gadget.jio_getAttachment(
gadget.hateoas_url + 'post_module/PostModule_getAscendingRelatedPostListAsJson'
+ "?follow_up=" + gadget.options.jio_key
gadget.hateoas_url + gadget.options.jio_key + "/SupportRequest_getCommentPostListAsJson"
.push(function (post_list) {
from json import dumps
portal = context.getPortalObject()
comment_list = []
if not follow_up:
return dumps(comment_list)
# 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()
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):
preferred_date_order = portal.portal_preferences.getPreferredDateOrder() or "ymd"
preferred_date_order = "/".join(preferred_date_order)
def formatDate(date):
# XXX modification date & creation date are still in server timezone.
# See merge request !17
# if default_time_zone:
# date = date.toZone(default_time_zone)
if preferred_date_order == 'dmy':
return "%s/%s/%s   %s" % (date.dd(),, date.year(), date.TimeMinutes())
if preferred_date_order == 'mdy':
return "%s/%s/%s   %s" % (, date.dd(), date.year(), date.TimeMinutes())
# ymd
return "%s/%s/%s   %s" % (date.year(),, date.dd(), date.TimeMinutes())
return date.strftime("%s %%H:%%M" %(
replace("y", "%Y").
replace("m", "%m").
replace("d", "%d"),
post_list = portal.portal_catalog(
portal_type="HTML Post",
sort_on=(('modification_date', 'ascending'),),
comment_list = []
for post in post_list:
owner = post.Base_getOwnerTitle()
time_stamp = format_date(post.getStartDate())
time_stamp = formatDate(post.getStartDate())
content = post.getTextContent()
successor_list = post.getSuccessorValueList()
successor_name = successor_link = None
if successor_list:
successor_link, successor_name = successor_list[0].getRelativeUrl(), successor_list[0].getFilename()
comment_list.append((owner, time_stamp, content, successor_link, successor_name))
return dumps(comment_list)
......@@ -50,11 +50,11 @@
<key> <string>_params</string> </key>
<value> <string>follow_up</string> </value>
<value> <string></string> </value>
<key> <string>id</string> </key>
<value> <string>PostModule_getAscendingRelatedPostListAsJson</string> </value>
<value> <string>SupportRequest_getCommentPostListAsJson</string> </value>
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