[CMF-checkins] CVS: CMF - topic_addCriterion.py:1.1 topic_addSubtopic.py:1.1 topic_criteria_form.dtml:1.1 topic_deleteCriteria.py:1.1 topic_editCriteria.py:1.1 topic_editTopic.py:1.1 topic_edit_form.dtml:1.1 topic_subtopics_form.dtml:1.1 topic_add.dtml:NONE topic_criteria.dtml:NONE topic_edit.dtml:NONE topic_subtopics.dtml:NONE

Jeffrey Shell jeffrey@digicool.com
Wed, 11 Apr 2001 14:39:35 -0400 (EDT)


Update of /cvs-repository/CMF/CMFTopic/skins/topic
In directory korak:/home/jeffrey/InstanceHomes/cmf-dev/CMF/CMFTopic/skins/topic

Added Files:
	topic_addCriterion.py topic_addSubtopic.py 
	topic_criteria_form.dtml topic_deleteCriteria.py 
	topic_editCriteria.py topic_editTopic.py topic_edit_form.dtml 
	topic_subtopics_form.dtml 
Removed Files:
	topic_add.dtml topic_criteria.dtml topic_edit.dtml 
	topic_subtopics.dtml 
Log Message:
Dealing with CMF Topic issue (248), a lot of work done to move usage of REQUEST out of Topic.py and into Python Scripts in the default Topic skins.


--- Added File topic_addCriterion.py in package CMF ---
## Script (Python) "topic_addCriterion"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST, RESPONSE, field, criteria_type
##title=
##

context.addCriteria(field=field, criteria_type=criteria_type)

RESPONSE.redirect('%s/topic_criteria_form' % context.absolute_url())

--- Added File topic_addSubtopic.py in package CMF ---
## Script (Python) "topic_addSubtopic"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST, RESPONSE, new_id
##title=
##

topictype = context.getTypeInfo()
context.addSubtopic(new_id)

action = topictype.getActionById('subtopics')
url = '%s/%s?portal_status_message=%s' % (
    context.absolute_url(),
    action,
    "Subtopic+'%s'+added" % new_id
    )
RESPONSE.redirect(url)

--- Added File topic_criteria_form.dtml in package CMF ---
<dtml-var standard_html_header>

<div class="Desktop">

<div class="Topic">

<h2> Topic Criteria: &dtml-getId; </h2>

<form action="&dtml-absolute_url;" method="post">

<dtml-in listCriteria>
 <dtml-var expr="_[getEditForm()]">
</dtml-in>
<input type="submit" name="topic_deleteCriteria:action" value=" Delete selected ">
&nbsp;&nbsp;
<input type="submit" name="topic_editCriteria:action" value=" Save changes ">
<input type="hidden" name=":default_action" value="editCriteria">
</form>


<form action="&dtml-absolute_url;/topic_addCriterion" method="post">
<h2> Add New Topic Criteria: </h2>
<table class="FormLayout">
 <tr valign="top">
  <th align="right"> Field id: </th>
  <td><select name="field">
    <dtml-in name="listAvailableFields">
    <option value="&dtml-sequence-item;">&dtml-sequence-item;</option>
    </dtml-in>
  </select></td>
 </tr>
 <tr valign="top">
  <th align="left"> Criteria type: </th>
  <td><select name="criteria_type">
    <dtml-in name="listCriteriaTypes" mapping>
    <option value="&dtml-name;">&dtml-name;</option>
    </dtml-in>
  </select></td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td><input type="submit" value=" Add "></td>
 </tr>
</table>
</form>

</div>

</div>

<dtml-var standard_html_footer>

--- Added File topic_deleteCriteria.py in package CMF ---
## Script (Python) "topic_deleteCriteria"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST, RESPONSE, criterion_ids
##title=
##

for cid in criterion_ids:
    context.deleteCriterion(cid)

message = 'Criteria+deleted.'
RESPONSE.redirect('%s/topic_criteria_form?portal_status_message=%s' % (
    context.absolute_url(), message)
                  )

--- Added File topic_editCriteria.py in package CMF ---
## Script (Python) "topic_editCriteria"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST, RESPONSE, criteria
##title=
##
"""\
Save changes to the list of criteria.  This is done by going over
the submitted criteria records and comparing them against the
criteria object's editable attributes.  A 'command' object is
built to send to the Criterion objects 'apply' method, which in turn
applies the command to the Criterion objects 'edit' method.
"""

for rec in criteria:
    crit = context.getCriterion(rec.id)
    command = {}
    for attr in crit.editableAttributes():
        tmp = getattr(rec, attr, None)
        # Due to having multiple radio buttons on the same page
        # with the same name but belonging to different records,
        # they needed to be associated with different records with ids
        if tmp is None:
            tmp = getattr(rec, '%s__%s' % (attr, rec.id), None)
        command[attr] = tmp
    crit.apply(command)

message='Changes+saved.'
RESPONSE.redirect('%s/topic_criteria_form?portal_status_message=%s' % (
    context.absolute_url(), message)
                  )


--- Added File topic_editTopic.py in package CMF ---
## Script (Python) "topic_editTopic"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST, RESPONSE, acquireCriteria, title=None, description=None
##title=
##

context.edit(acquireCriteria=acquireCriteria,
             title=title,
             description=description)

RESPONSE.redirect('%s/topic_view' % context.absolute_url())

--- Added File topic_edit_form.dtml in package CMF ---
<dtml-var standard_html_header>

<div class="Desktop">

<div class="Topic">

<h2> Edit Topic: <dtml-var id> </h2>

<form action="&dtml-absolute_url;" method="post">
<table class="FormLayout">

 <tr valign="top">
  <th align="right"> Title: </th>
  <td><input type="text" name="title" value="&dtml-title;" size="30" /></td>
 </tr>
 <tr valign="top"
  <th align="right"> Description: </th>
  <td><textarea name="description:test" rows="5" cols="65"
       >&dtml-Description;</textarea></td>
 </tr>
 <tr valign="top">
  <th align="right"> Acquire Criteria<br>from Parent: </th>
  <td>
   <dtml-let acqChecked="acquireCriteria and 'checked' or ''">
   <input type="checkbox"
          name="acquireCriteria"
          value="1" &dtml-acqChecked;>
   </dtml-let>
   <input type="hidden"
          name="acquireCriteria:default"
          value="">
  </td>
 </tr>

 <tr valign="top">
  <td> <br> </td>
  <td>
   <input type="submit" name="topic_editTopic:action" value="Change">
  </td>
 </tr>

</table>
</form>

</div>

</div>

<dtml-var standard_html_footer>

--- Added File topic_subtopics_form.dtml in package CMF ---
<dtml-var standard_html_header>

<div class="Desktop">

<div class="Topic">

<h2> Topic Subtopics: <dtml-var getId> </h2>

<form action="&dtml-absolute_url;" method="post">
<table class="FormLayout">

<dtml-in listSubtopics>

 <tr valign="top">
  <td> <input type="checkbox" name="ids:list" value="&dtml-getId;"> </td>
  <td> 
   <a href="&dtml-getId;">&dtml-getId;</a>
   <dtml-with buildQuery>
    <dtml-in items>
     <dtml-if sequence-start>(</dtml-if>
     <dtml-var sequence-key> : <dtml-var sequence-item>
     <dtml-unless sequence-end>,</dtml-unless>
     <dtml-if sequence-end>)</dtml-if>
    </dtml-in>
   </dtml-with>
  </td>
 </tr>

</dtml-in>

 <tr valign="top">
  <td> <br> </td>
  <td>
   <input type="submit" name="folder_rename_form:action" value="Rename">
   <input type="submit" name="folder_cut:action" value="Cut">
   <input type="submit" name="folder_copy:action" value="Copy">
   <input type="submit" name="folder_paste:action" value="Paste">
   <input type="submit" name="folder_delete:action" value="Delete">
  </td>
 </tr>

</table>
</form>

<form action="topic_addSubtopic" method="get">
<h2> Add subtopic: </h2>
<p><strong>Id: </strong>
<input type="text" name="new_id" size="30" /><br />
<input type="submit" value=" Add " /></p>
</form>

</div>

</div>

<dtml-var standard_html_footer>

--- Removed file topic_add.dtml from package CMF --

--- Removed file topic_criteria.dtml from package CMF --

--- Removed file topic_edit.dtml from package CMF --

--- Removed file topic_subtopics.dtml from package CMF --