[CMF-checkins] CVS: CMF/CMFCollector/skins/collector - collector_issue_edit.py:1.3

Ken Manheimer klm@zope.com
Mon, 22 Oct 2001 13:12:06 -0400


Update of /cvs-repository/CMF/CMFCollector/skins/collector
In directory cvs.zope.org:/tmp/cvs-serv9032

Modified Files:
	collector_issue_edit.py 
Log Message:
Implemented issue editing.

In addition to invoking the issue .edit() method, we check for
toggling of security_related, and if seen, look for a workflow action
that restricts or unrestricts accordingly.  It makes sense for the
user interface to do this for the user, while it doesn't for the
application object business logic, so this is probably the right
place.  (It's also general enough so new restrict/unrestrict
transitions will be used, if/when added to the workflow.)

Return to the transcript, with a report of the changes.


=== CMF/CMFCollector/skins/collector/collector_issue_edit.py 1.2 => 1.3 ===
-##parameters=
 ##title=Submit a Request
 
-REQUEST = context.REQUEST
+from Products.PythonScripts.standard import url_quote_plus
 
-import pdb; pdb.set_trace()
+reqget = context.REQUEST.get
 
-id = context.edit(comment=REQUEST.get('comment'),
-                  status=REQUEST.get('status'),
-                  submitter_name=REQUEST.get('submitter_name'),
-                  title=REQUEST.get('title'),
-                  description=REQUEST.get('description'),
-                  security_related=REQUEST.get('security_related'),
-                  topic=REQUEST.get('topic'),
-                  importance=REQUEST.get('importance'),
-                  classification=REQUEST.get('classification'),
-                  severity=REQUEST.get('severity'),
-                  reported_version=REQUEST.get('reported_version'),
-                  other_version_info=REQUEST.get('other_version_info'))
+was_security_related = context.security_related
 
-context.REQUEST.RESPONSE.redirect("%s/collector_issue_contents"
-                                  % context.absolute_url())
+changed = context.edit(title=reqget('title'),
+                       security_related=reqget('security_related', 0),
+                       description=reqget('description'),
+                       topic=reqget('topic'),
+                       classification=reqget('classification'),
+                       importance=reqget('importance'),
+                       severity=reqget('severity'),
+                       reported_version=reqget('reported_version'),
+                       other_version_info=reqget('other_version_info'),
+                       text=reqget('text'))
+
+if context.security_related != was_security_related:
+    # Do first available restrict/unrestrict action:
+    for action, pretty in context.valid_actions_pairs():
+        if pretty in ['Restrict', 'Unrestrict']:
+            context.do_action(action, ' Triggered by security_related toggle.')
+            changed = changed + ", " + pretty.lower() + 'ed'
+            break
+
+whence = context.absolute_url()
+
+if changed:
+    msg = url_quote_plus("Changed: " + changed)
+    context.REQUEST.RESPONSE.redirect("%s?portal_status_message=%s"
+                                      % (whence, msg))
+
+else:
+    context.REQUEST.RESPONSE.redirect(whence)