Commit 3c356997 authored by Ivan Tyagov's avatar Ivan Tyagov

Use permanent URL for navigation in a forum intead of just redirecting to discussion_thread_module.

This provides consistent UI.
parent 078a2430
......@@ -52,7 +52,9 @@
<item>
<key> <string>group_list</string> </key>
<value>
<tuple/>
<tuple>
<string>document</string>
</tuple>
</value>
</item>
<item>
......@@ -93,6 +95,12 @@
<key> <string>type_class</string> </key>
<value> <string>TextDocument</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
......
......@@ -83,6 +83,10 @@
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>translated_validation_state_title</string>
<string>State</string>
......
......@@ -57,27 +57,39 @@ from DateTime import DateTime\n
\n
portal = context.getPortalObject()\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
version = \'001\'\n
language = portal.Localizer.get_selected_language()\n
discussion_post = context.newContent(\n
\n
discussion_thread = context\n
is_temp_object = discussion_thread.isTempObject()\n
\n
if is_temp_object:\n
# this is a temporary object accessed by its reference\n
# we need to get real ZODB one\n
discussion_thread = getattr(discussion_thread.original_container, discussion_thread.original_id)\n
\n
discussion_post = discussion_thread.newContent(\n
portal_type = "Discussion Post",\n
title = title,\n
text_content = text_content,\n
source_value = person,\n
predecessor_value = predecessor,\n
version = version,\n
language = language,\n
version = \'001\',\n
language = portal.Localizer.get_selected_language(),\n
text_format = \'text/html\')\n
\n
# depending on security model Post can be submited for review\n
portal_status_message = "New post created in background."\n
portal_status_message = context.Base_translateString("New post created in background.")\n
\n
# a parent thread is actually just a logical container so it\'s modified\n
# whenever a new post is done\n
context.edit(modification_date = DateTime())\n
discussion_thread.edit(modification_date = DateTime())\n
\n
return context.Base_redirect(form_id,\n
keep_items = dict(portal_status_message=context.Base_translateString(portal_status_message)))\n
if not is_temp_object:\n
return discussion_thread.Base_redirect(form_id,\n
keep_items = dict(portal_status_message=portal_status_message))\n
else:\n
# redirect using again reference\n
redirect_url = \'%s?portal_status_message=%s\' %(context.REQUEST[\'URL1\'],portal_status_message)\n
context.REQUEST.RESPONSE.redirect(redirect_url)\n
</string> </value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>ob=kw[\'brain\'].getObject()\n
return ob.getReference()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Listbox_getDiscussionThreadPermanentUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -69,7 +69,10 @@ if site_list in MARKER:\n
# set predicate settings for current Web Section\n
membership_criterion_category_list = context.getMembershipCriterionCategoryList()\n
multimembership_criterion_base_category_list = context.getMultimembershipCriterionBaseCategoryList()\n
\n
# XXX: what if reference duplicates : add some random part ?\n
reference = title.replace(\' \', \'-\')\n
\n
create_kw = dict(title = title,\n
source_value = person,\n
reference = reference,\n
......@@ -95,8 +98,8 @@ discussion_post = discussion_thread.newContent(\n
language = language)\n
\n
# depending on security model Thread and Post can be directly published or shared\n
portal_status_message = "New discussion created. Your post will be reviewed for approval."\n
discussion_thread.submit()\n
portal_status_message = "New discussion created in backgroud."\n
discussion_thread.publish()\n
\n
if send_notification_text not in (\'\', None):\n
# we can send notifications\n
......@@ -135,7 +138,7 @@ if send_notification_text not in (\'\', None):\n
message_text_format=notification_message.getContentType(),\n
store_as_event=False)\n
\n
return discussion_thread.Base_redirect(form_id,\n
return context.Base_redirect(form_id,\n
keep_items = dict(portal_status_message=context.Base_translateString(portal_status_message)))\n
</string> </value>
</item>
......@@ -143,6 +146,14 @@ return discussion_thread.Base_redirect(form_id,\n
<key> <string>_params</string> </key>
<value> <string>title, text_content, form_id=\'view\', predecessor=None, description=None, subject_list=None, classification=None, group_list=None, site_list=None, send_notification_text=None, reference=None,**kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignor</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_createNewDiscussionThread</string> </value>
......
......@@ -244,6 +244,10 @@
<key> <string>url_columns</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>Listbox_getDiscussionThreadPermanentUrl</string>
</tuple>
<tuple>
<string>modification_date</string>
<string></string>
......
107
\ No newline at end of file
108
\ No newline at end of file
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