Changeset 3402 in products for quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/browser/plonetabs.py
- Timestamp:
- Apr 2, 2012 1:04:35 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/browser/plonetabs.py
r3401 r3402 38 38 39 39 cookie_name = 'ploneTabsMode' 40 40 41 41 42 class PloneTabsControlPanel(PloneKSSView): … … 148 149 IStatusMessage(self.request).addStatusMessage( 149 150 _(u"'${id}' action successfully added.", 150 mapping={'id': action.id}), type="info")151 mapping={'id': action.id}), type="info") 151 152 self.redirect(search="category=%s" % cat_name) 152 153 return False … … 179 180 else: 180 181 errs.update(self.processErrors(errors, 181 sufix='_%s' % id)) # add edit form sufix to error ids182 sufix='_%s' % id)) # add edit form sufix to error ids 182 183 IStatusMessage(self.request).addStatusMessage( 183 184 _(u"Please correct the indicated errors."), type="error") … … 214 215 self.moveAction(id, cat_name, steps=1) 215 216 IStatusMessage(self.request).addStatusMessage( 216 217 _(u"'${id}' action moved up.", mapping={'id': id}), type="info") 217 218 self.redirect(search="category=%s" % cat_name) 218 219 return False … … 247 248 """Redirect to @@plonetabs-controlpanel configlet""" 248 249 if not url: 249 portal_url = 250 portal_url = getMultiAdapter((self.context, self.request), 250 251 name=u"plone_portal_state").portal_url() 251 252 url = '%s/%s' % (portal_url, "@@plonetabs-controlpanel") … … 302 303 """See interface""" 303 304 tool = getToolByName(self.context, "portal_actions") 304 return len(tool.listActions(categories=[category, ])) > 0305 return len(tool.listActions(categories=[category, ])) > 0 305 306 306 307 def getPortalActions(self, category="portal_tabs"): … … 322 323 site_properties = getToolByName(self.context, 323 324 "portal_properties").site_properties 324 return not site_properties.getProperty("disable_folder_sections", False) 325 return not site_properties.getProperty("disable_folder_sections", 326 False) 325 327 326 328 def isNotFoldersGenerated(self): … … 364 366 query = {} 365 367 rootPath = getNavigationRoot(context) 366 query['path'] = {'query' : rootPath, 'depth': 1}368 query['path'] = {'query': rootPath, 'depth': 1} 367 369 query['portal_type'] = utils.typesToList(context) 368 370 … … 388 390 excludedIds = {} 389 391 for id in idsNotToList: 390 excludedIds[id] =1392 excludedIds[id] = 1 391 393 392 394 rawresult = portal_catalog.searchResults(**query) … … 396 398 if not excludedIds.has_key(item.getId): 397 399 id, item_url = get_view_url(item) 398 data = {'name' 399 'id' 400 'url' 400 data = {'name': utils.pretty_title_or_id(context, item), 401 'id': id, 402 'url': item_url, 401 403 'description': item.Description, 402 'exclude_from_nav' 404 'exclude_from_nav': item.exclude_from_nav} 403 405 result.append(data) 404 406 … … 428 430 actions = getMultiAdapter((self.context, self.request), 429 431 name=u'plone_context_state').actions() 430 try: 431 # Plone 4 and higher 432 import plone.app.upgrade 432 try: 433 # Plone 4 and higher 434 import plone.app.upgrade 433 435 if 'portal_tabs' in actions: 434 436 actions_tabs = actions['portal_tabs'] 435 437 else: 436 438 actions_tabs = [] 437 except ImportError: 439 except ImportError: 438 440 actions_tabs = actions 439 441 … … 519 521 ksscore = self.getCommandSet("core") 520 522 content = self.getGeneratedTabs() 521 ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('roottabs'), content) 523 ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('roottabs'), 524 content) 522 525 523 526 # update global-sections viewlet … … 554 557 value="invisible") 555 558 message = _(u"'${id}' object was included into navigation.", 556 mapping={'id': obj_id})559 mapping={'id': obj_id}) 557 560 else: 558 561 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 559 562 message = _(u"'${id}' object was excluded from navigation.", 560 mapping={'id': obj_id})563 mapping={'id': obj_id}) 561 564 562 565 # update global-sections viewlet … … 580 583 value="invisible") 581 584 message = _(u"'${id}' action is now visible.", 582 mapping={'id': act_id})585 mapping={'id': act_id}) 583 586 else: 584 587 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 585 588 message = _(u"'${id}' action is now invisible.", 586 mapping={'id': act_id})589 mapping={'id': act_id}) 587 590 self.updatePage(cat_name) 588 591 … … 608 611 # issue portal status message 609 612 self.kss_issueMessage(_(u"'${id}' action successfully removed.", 610 mapping={'id': act_id}))613 mapping={'id': act_id})) 611 614 612 615 @kssaction … … 627 630 # update client 628 631 # add one more action to actions list 629 content = self.getActionsList(category=cat_name, tabs=[action,]) 630 ksscore.insertHTMLAsLastChild(ksscore.getHtmlIdSelector('tabslist'), 631 content) 632 content = self.getActionsList(category=cat_name, tabs=[action, ]) 633 ksscore.insertHTMLAsLastChild( 634 ksscore.getHtmlIdSelector('tabslist'), 635 content) 632 636 633 637 # update reorder controls … … 652 656 653 657 message = _(u"'${id}' action successfully added.", 654 mapping={'id': action.id})658 mapping={'id': action.id}) 655 659 msgtype = "info" 656 660 … … 661 665 if errors.has_key('id') or errors.has_key('available_expr'): 662 666 self.kss_toggleCollapsible( 663 664 667 ksscore.getCssSelector('form[name=addaction_form] ' 668 '.headerAdvanced'), collapse='false') 665 669 666 670 message = _(u"Please correct the indicated errors.") … … 684 688 # collapse advanced section 685 689 self.kss_toggleCollapsible( 686 687 collapse='true')690 ksscore.getCssSelector('form[name=addaction_form] .headerAdvanced'), 691 collapse='true') 688 692 689 693 # reset form inputs … … 711 715 # update client 712 716 ksscore = self.getCommandSet("core") 713 content = self.getActionsList(category=cat_name, tabs=[action_info, ])717 content = self.getActionsList(category=cat_name, tabs=[action_info, ]) 714 718 ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 715 719 … … 728 732 # update client 729 733 ksscore = self.getCommandSet("core") 730 content = self.getActionsList(category=cat_name, tabs=[action, ])734 content = self.getActionsList(category=cat_name, tabs=[action, ]) 731 735 ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 732 736 … … 755 759 # update client 756 760 # replace action item with updated one 757 content = self.getActionsList(category=cat_name, tabs=[action, ])761 content = self.getActionsList(category=cat_name, tabs=[action, ]) 758 762 ksscore.replaceHTML(ksscore.getHtmlIdSelector(html_id), content) 759 763 760 764 message = _(u"'${id}' action successfully updated.", 761 mapping={'id': action.id})765 mapping={'id': action.id}) 762 766 msgtype = "info" 763 767 … … 826 830 def copyAction(self, action): 827 831 """Copy action to dictionary""" 828 action_info = {'description': action.description}832 action_info = {'description': action.description} 829 833 for attr in ACTION_ATTRS: 830 834 action_info[attr] = getattr(action, attr) … … 848 852 chooser.checkName(data['id'], self.context) 849 853 except Exception, e: 850 errors['id'] = self._formatError(e, **{'id': data['id']})854 errors['id'] = self._formatError(e, **{'id': data['id']}) 851 855 852 856 # validate action name … … 1007 1011 '.error-container' % (id, UI_ATTRS.get(name, name))) 1008 1012 else: 1009 field_selector = ksscore.getCssSelector('form[name=addaction_form] ' 1013 field_selector = ksscore.getCssSelector('form' +\ 1014 '[name=addaction_form] ' 1010 1015 '.field-%s' % UI_ATTRS.get(name, name)) 1011 1016 field_error_selector = ksscore.getCssSelector('form[name=' … … 1068 1073 """"Issues portal status message and removes it afte 10 seconds""" 1069 1074 ksscore = self.getCommandSet('core') 1070 self.getCommandSet('plone').issuePortalMessage(message, msgtype=msgtype) 1075 self.getCommandSet('plone').issuePortalMessage(message, 1076 msgtype=msgtype) 1071 1077 self.kss_timeout( 1072 1078 ksscore.getHtmlIdSelector('kssPortalMessage'), … … 1123 1129 """Delete action with given id from given category""" 1124 1130 category = self.getActionCategory(cat_name) 1125 category.manage_delObjects(ids=[id, ])1131 category.manage_delObjects(ids=[id, ]) 1126 1132 return True 1127 1133 … … 1131 1137 category = self.getActionCategory(cat_name) 1132 1138 if steps > 0: 1133 category.moveObjectsUp([id, ], steps)1139 category.moveObjectsUp([id, ], steps) 1134 1140 else: 1135 category.moveObjectsDown([id, ], abs(steps))1141 category.moveObjectsDown([id, ], abs(steps)) 1136 1142 return True 1137 1143 return False … … 1176 1182 #ksszope = self.getCommandSet("zope") 1177 1183 #ksszope.refreshViewlet( 1178 1179 1180 1184 #self.getCommandSet("core").getHtmlIdSelector("portal-siteactions"), 1185 #"plone.portalheader", 1186 #"plone.site_actions") 1181 1187 1182 1188 def updateUserPageSection(self): … … 1189 1195 "plone.personal_bar") 1190 1196 1197 1191 1198 class PloneTabsMode(BrowserView): 1192 1199
Note: See TracChangeset
for help on using the changeset viewer.