| 174 | | def manage_moveUpAction(self, form, errors): |
|---|
| 175 | | """ Move up given action by one position """ |
|---|
| 176 | | portal_actions = getToolByName(self.context, "portal_actions") |
|---|
| 177 | | |
|---|
| 178 | | id = form.get("orig_id", "") |
|---|
| 179 | | category = form.get("category", "") |
|---|
| 180 | | |
|---|
| 181 | | if category not in portal_actions.objectIds(): |
|---|
| 182 | | IStatusMessage(self.request).addStatusMessage(_(u"Unexistent root portal actions category '%s'" % category), type="error") |
|---|
| 183 | | else: |
|---|
| 184 | | cat_container = portal_actions[category] |
|---|
| 185 | | if id not in map(lambda x: x.id, filter(lambda x: IAction.providedBy(x), cat_container.objectValues())): |
|---|
| 186 | | IStatusMessage(self.request).addStatusMessage(_(u"'%s' action does not exist in '%s' category" % (id, category)), type="error") |
|---|
| 187 | | else: |
|---|
| 188 | | cat_container.moveObjectsUp([id,], 1) |
|---|
| 189 | | IStatusMessage(self.request).addStatusMessage(_(u"'%s' action in '%s' category moved up" % (id, category)), type="info") |
|---|
| 190 | | |
|---|
| 191 | | # redirect to form after successfull deletion |
|---|
| 192 | | self.redirect(search="category=%s" % category) |
|---|
| 193 | | return False |
|---|
| 194 | | |
|---|
| 195 | | # return form with errors |
|---|
| 196 | | return True |
|---|
| 197 | | |
|---|
| 198 | | def manage_moveDownAction(self, form, errors): |
|---|
| 199 | | """ Move up given action by one position """ |
|---|
| 200 | | portal_actions = getToolByName(self.context, "portal_actions") |
|---|
| 201 | | |
|---|
| 202 | | id = form.get("orig_id", "") |
|---|
| 203 | | category = form.get("category", "") |
|---|
| 204 | | |
|---|
| 205 | | if category not in portal_actions.objectIds(): |
|---|
| 206 | | IStatusMessage(self.request).addStatusMessage(_(u"Unexistent root portal actions category '%s'" % category), type="error") |
|---|
| 207 | | else: |
|---|
| 208 | | cat_container = portal_actions[category] |
|---|
| 209 | | if id not in map(lambda x: x.id, filter(lambda x: IAction.providedBy(x), cat_container.objectValues())): |
|---|
| 210 | | IStatusMessage(self.request).addStatusMessage(_(u"'%s' action does not exist in '%s' category" % (id, category)), type="error") |
|---|
| 211 | | else: |
|---|
| 212 | | cat_container.moveObjectsDown([id,], 1) |
|---|
| 213 | | IStatusMessage(self.request).addStatusMessage(_(u"'%s' action in '%s' category moved down" % (id, category)), type="info") |
|---|
| 214 | | |
|---|
| 215 | | # redirect to form after successfull deletion |
|---|
| 216 | | self.redirect(search="category=%s" % category) |
|---|
| 217 | | return False |
|---|
| 218 | | |
|---|
| 219 | | # return form with errors |
|---|
| 220 | | return True |
|---|
| | 174 | def manage_moveUpAction(self, form, errs): |
|---|
| | 175 | """ Manage Method for moving up given action by one position """ |
|---|
| | 176 | # extract posted data |
|---|
| | 177 | id, cat_name, data = self.parseEditForm(form) |
|---|
| | 178 | |
|---|
| | 179 | # get category and action to move |
|---|
| | 180 | category = self.getActionCategory(cat_name) |
|---|
| | 181 | if id in category.objectIds(): |
|---|
| | 182 | self.moveAction(id, cat_name, steps=1) |
|---|
| | 183 | IStatusMessage(self.request).addStatusMessage(_(u"'%s' action moved up." % id), type="info") |
|---|
| | 184 | self.redirect(search="category=%s" % cat_name) |
|---|
| | 185 | return False |
|---|
| | 186 | else: |
|---|
| | 187 | IStatusMessage(self.request).addStatusMessage(_(u"No '%s' action in '%s' category." % (id, cat_name)), type="error") |
|---|
| | 188 | return True |
|---|
| | 189 | |
|---|
| | 190 | def manage_moveDownAction(self, form, errs): |
|---|
| | 191 | """ Manage Method for moving down given action by one position """ |
|---|
| | 192 | # extract posted data |
|---|
| | 193 | id, cat_name, data = self.parseEditForm(form) |
|---|
| | 194 | |
|---|
| | 195 | # get category and action to move |
|---|
| | 196 | category = self.getActionCategory(cat_name) |
|---|
| | 197 | if id in category.objectIds(): |
|---|
| | 198 | self.moveAction(id, cat_name, steps=-1) |
|---|
| | 199 | IStatusMessage(self.request).addStatusMessage(_(u"'%s' action moved down." % id), type="info") |
|---|
| | 200 | self.redirect(search="category=%s" % cat_name) |
|---|
| | 201 | return False |
|---|
| | 202 | else: |
|---|
| | 203 | IStatusMessage(self.request).addStatusMessage(_(u"No '%s' action in '%s' category." % (id, cat_name)), type="error") |
|---|
| | 204 | return True |
|---|