Changeset 12067 for main/waeup.ikoba/trunk/src/waeup/ikoba
- Timestamp:
- 27 Nov 2014, 07:11:36 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/products
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser.py
r12065 r12067 41 41 FriendlyDatetimeDisplayWidget) 42 42 from waeup.ikoba.browser.breadcrumbs import Breadcrumb 43 from waeup.ikoba.browser.pages import ( 44 delSubobjects, add_local_role, del_local_roles, msave, 45 LocalRoleAssignmentUtilityView) 43 46 44 47 from waeup.ikoba.products.interfaces import ( … … 71 74 grok.name('index') 72 75 grok.require('waeup.Public') 73 #grok.template('containerpage')76 grok.template('containerpage') 74 77 pnav = 1 75 78 label = _('Products') 76 79 77 80 78 class ProductsContainerManageFormPage(IkobaEditFormPage): 81 class ProductsContainerManageFormPage(IkobaEditFormPage, 82 LocalRoleAssignmentUtilityView): 79 83 """The manage page for customer containers. 80 84 """ … … 82 86 grok.name('manage') 83 87 grok.require('waeup.manageProducts') 84 #grok.template('containermanagepage')88 grok.template('containermanagepage') 85 89 pnav = 1 86 90 label = _('Manage product section') 91 92 taboneactions = [_('Save'),_('Cancel')] 93 tabtwoactions = [_('Add product'), _('Remove selected'),_('Cancel')] 94 tabthreeactions1 = [_('Remove selected local roles')] 95 tabthreeactions2 = [_('Add local role')] 96 97 @jsaction(_('Remove selected')) 98 def delDepartments(self, **data): 99 if not checkPermission('waeup.managePortal', self.context): 100 self.flash(_('You are not allowed to remove products.'), 101 type='danger') 102 return 103 delSubobjects(self, redirect='@@manage', tab='2') 104 return 105 106 @action(_('Save'), style='primary') 107 def save(self, **data): 108 return msave(self, **data) 109 110 @action(_('Cancel'), validator=NullValidator) 111 def cancel(self, **data): 112 self.redirect(self.url(self.context)) 113 return 114 115 @action(_('Add product'), validator=NullValidator) 116 def addSubunit(self, **data): 117 self.redirect(self.url(self.context, '@@addproduct')) 118 return 119 120 @action(_('Add local role'), validator=NullValidator) 121 def addLocalRole(self, **data): 122 return add_local_role(self,3,**data) 123 124 @action(_('Remove selected local roles')) 125 def delLocalRoles(self, **data): 126 return del_local_roles(self,3,**data) 87 127 88 128 … … 101 141 product = createObject(u'waeup.Product') 102 142 self.applyData(product, **data) 103 self.context.addProduct(product) 104 self.flash(_('Product created.')) 105 self.redirect(self.url(self.context[product.product_id], 'index')) 143 try: 144 self.context.addProduct(product) 145 except KeyError: 146 self.flash(_('The Id chosen already exists.'), 147 type='danger') 148 return 149 self.flash( 150 _("Product ${a} added.", mapping = {'a':data['product_id']})) 151 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 152 self.context.__parent__.logger.info( 153 '%s - added: %s' % (ob_class, data['product_id'])) 154 self.redirect(self.url(self.context, u'@@manage')+'#tab2') 106 155 return 107 156 … … 122 171 123 172 124 class ProductManageFormPage(IkobaEditFormPage): 173 class ProductManageFormPage(IkobaEditFormPage, 174 LocalRoleAssignmentUtilityView): 125 175 """ View to manage product data 126 176 """ … … 128 178 grok.name('manage') 129 179 grok.require('waeup.manageProducts') 130 form_fields = grok.AutoFields(IProduct) 131 #grok.template('basemanagepage') 132 label = _('Manage product') 133 pnav = 1 180 form_fields = grok.AutoFields(IProduct).omit('product_id') 181 grok.template('productmanagepage') 182 pnav = 1 183 184 taboneactions = [_('Save'),_('Cancel')] 185 tabtwoactions1 = [_('Remove selected local roles')] 186 tabtwoactions2 = [_('Add local role')] 187 188 def label(self): 189 return _('Manage product ') + self.context.product_id 190 191 @action(_('Save'), style='primary') 192 def save(self, **data): 193 return msave(self, **data) 194 195 @action(_('Cancel'), validator=NullValidator) 196 def cancel(self, **data): 197 self.redirect(self.url(self.context)) 198 return 199 200 @action(_('Add local role'), validator=NullValidator) 201 def addLocalRole(self, **data): 202 return add_local_role(self,2,**data) 203 204 @action(_('Remove selected local roles')) 205 def delLocalRoles(self, **data): 206 return del_local_roles(self,2,**data) -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/viewlets.py
r12065 r12067 62 62 63 63 64 class AddProductActionButton(AddActionButton):65 grok.order(1)66 grok.context(IProductsContainer)67 grok.view(ProductsContainerManageFormPage)68 grok.require('waeup.manageProducts')69 text = _('Add product')70 target = 'addproduct'71 72 73 64 class ProductViewActionButton(ManageActionButton): 74 65 grok.order(1)
Note: See TracChangeset for help on using the changeset viewer.