Commit 074462d9 authored by Jérome Perrin's avatar Jérome Perrin

support funding and function to be passed as a document, not a category

Signed-off-by: Aurel's avatarAurélien Calonne <aurel@nexedi.com>
parent 243a4bed
...@@ -91,12 +91,20 @@ if function:\n ...@@ -91,12 +91,20 @@ if function:\n
if function == \'None\':\n if function == \'None\':\n
inventory_params[\'function_uid\'] = Query(function_uid=None)\n inventory_params[\'function_uid\'] = Query(function_uid=None)\n
else:\n else:\n
inventory_params[\'function_category\'] = function\n function_value = portal.restrictedTraverse(function, None)\n
if function_value is not None and function_value.getPortalType() != \'Category\':\n
inventory_params[\'function_uid\'] = function_value.getUid()\n
else:\n
inventory_params[\'function_category\'] = function\n
if funding:\n if funding:\n
if funding == \'None\':\n if funding == \'None\':\n
inventory_params[\'funding_uid\'] = Query(funding_uid=None)\n inventory_params[\'funding_uid\'] = Query(funding_uid=None)\n
else:\n else:\n
inventory_params[\'funding_category\'] = funding\n funding_value = portal.restrictedTraverse(funding, None)\n
if funding_value is not None and funding_value.getPortalType() != \'Category\':\n
inventory_params[\'funding_uid\'] = funding_value.getUid()\n
else:\n
inventory_params[\'funding_category\'] = funding\n
if project:\n if project:\n
if project == \'None\':\n if project == \'None\':\n
inventory_params[\'project_uid\'] = Query(project_uid=None)\n inventory_params[\'project_uid\'] = Query(project_uid=None)\n
......
...@@ -120,9 +120,17 @@ if project:\n ...@@ -120,9 +120,17 @@ if project:\n
else:\n else:\n
params[\'project_uid\'] = traverse(project).getUid()\n params[\'project_uid\'] = traverse(project).getUid()\n
if function:\n if function:\n
params[\'function_category\'] = function\n function_value = traverse(function, None)\n
if function_value is not None and function_value.getPortalType() != \'Category\':\n
params[\'function_uid\'] = function_value.getUid()\n
else:\n
params[\'function_category\'] = function\n
if funding:\n if funding:\n
params[\'funding_category\'] = funding\n funding_value = traverse(funding, None)\n
if funding_value is not None and funding_value.getPortalType() != \'Category\':\n
params[\'funding_uid\'] = funding_value.getUid()\n
else:\n
params[\'funding_category\'] = funding\n
if mirror_section:\n if mirror_section:\n
params[\'mirror_section_uid\'] = traverse(mirror_section).getUid()\n params[\'mirror_section_uid\'] = traverse(mirror_section).getUid()\n
if parent_portal_type:\n if parent_portal_type:\n
......
...@@ -104,6 +104,7 @@ if project:\n ...@@ -104,6 +104,7 @@ if project:\n
params[\'project_uid\'] = Query(project_uid=None)\n params[\'project_uid\'] = Query(project_uid=None)\n
else:\n else:\n
params[\'project_uid\'] = portal.portal_categories.restrictedTraverse(project).getUid()\n params[\'project_uid\'] = portal.portal_categories.restrictedTraverse(project).getUid()\n
\n
funding_category = request.get(\'funding\')\n funding_category = request.get(\'funding\')\n
if funding_category:\n if funding_category:\n
if funding_category == \'None\':\n if funding_category == \'None\':\n
......
...@@ -60,8 +60,12 @@ inventory_kw = dict(section_uid=section_uid,\n ...@@ -60,8 +60,12 @@ inventory_kw = dict(section_uid=section_uid,\n
)\n )\n
if function_category:\n if function_category:\n
inventory_kw[\'function_category\'] = function_category\n inventory_kw[\'function_category\'] = function_category\n
if function_uid:\n
inventory_kw[\'function_uid\'] = function_uid\n
if funding_category:\n if funding_category:\n
inventory_kw[\'funding_category\'] = funding_category\n inventory_kw[\'funding_category\'] = funding_category\n
if funding_uid:\n
inventory_kw[\'funding_uid\'] = funding_uid\n
if project_uid:\n if project_uid:\n
inventory_kw[\'project_uid\'] = project_uid\n inventory_kw[\'project_uid\'] = project_uid\n
if mirror_section_category:\n if mirror_section_category:\n
...@@ -114,7 +118,7 @@ return [Object(debit_price=debit, credit_price=credit)]\n ...@@ -114,7 +118,7 @@ return [Object(debit_price=debit, credit_price=credit)]\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>section_uid, simulation_state, at_date, period_start_date, precision, node_category=None, function_category=None, funding_category=None, project_uid=None, from_date=\'ignored\', mirror_section_category=None, mirror_section_uid=None, **kw</string> </value> <value> <string>section_uid, simulation_state, at_date, period_start_date, precision, node_category=None, function_category=None, function_uid=None, funding_category=None, funding_uid=None, project_uid=None, from_date=\'ignored\', mirror_section_category=None, mirror_section_uid=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
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