Changeset 12097 for main/waeup.ikoba/trunk/src/waeup
- Timestamp:
- 30 Nov 2014, 20:49:22 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 20 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/app.py
r12091 r12097 76 76 77 77 @property 78 def unique_ application_id(self):79 """A unique application id for all applicationobjects in customers.78 def unique_contract_id(self): 79 """A unique contract id for all contract objects in customers. 80 80 81 The applicationid returned is guaranteed to be unique.81 The contract id returned is guaranteed to be unique. 82 82 83 Once a applicationid was issued, it won't be issued again.83 Once a contract id was issued, it won't be issued again. 84 84 85 Obtaining an applicationid is currently not thread-safe but can be85 Obtaining an contract id is currently not thread-safe but can be 86 86 made easily by enabling commented lines. 87 87 """ -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py
r12094 r12097 43 43 from waeup.ikoba.customers.interfaces import ( 44 44 ICustomer, ICustomerUpdateByRegNo, 45 ICustomerDocument, I Application)45 ICustomerDocument, IContract) 46 46 from waeup.ikoba.customers.workflow import ( 47 47 IMPORTABLE_REGISTRATION_STATES, IMPORTABLE_REGISTRATION_TRANSITIONS, 48 IMPORTABLE_ APPLICATION_STATES, IMPORTABLE_APPLICATION_TRANSITIONS)48 IMPORTABLE_CONTRACT_STATES, IMPORTABLE_CONTRACT_TRANSITIONS) 49 49 from waeup.ikoba.utils.batching import BatchProcessor 50 50 … … 463 463 464 464 465 class ApplicationProcessor(CustomerProcessorBase):466 """A batch processor for I Applicationobjects.465 class ContractProcessor(CustomerProcessorBase): 466 """A batch processor for IContract objects. 467 467 """ 468 468 grok.implements(IBatchProcessor) 469 469 grok.provides(IBatchProcessor) 470 470 grok.context(Interface) 471 util_name = ' applicationprocessor'471 util_name = 'contractprocessor' 472 472 grok.name(util_name) 473 473 474 name = _(' ApplicationProcessor')475 iface = I Application476 factory_name = 'waeup.Sample Application'474 name = _('Contract Processor') 475 iface = IContract 476 factory_name = 'waeup.SampleContract' 477 477 478 478 location_fields = [] 479 additional_fields = [' application_id', 'class_name']479 additional_fields = ['contract_id', 'class_name'] 480 480 additional_headers = ['class_name'] 481 481 482 482 def checkHeaders(self, headerfields, mode='ignore'): 483 super( ApplicationProcessor, self).checkHeaders(headerfields)484 if mode in ('update', 'remove') and not ' application_id' in headerfields:485 raise FatalCSVError( 486 "Need application_id for import in update and remove modes!")483 super(ContractProcessor, self).checkHeaders(headerfields) 484 if mode in ('update', 'remove') and not 'contract_id' in headerfields: 485 raise FatalCSVError( 486 "Need contract_id for import in update and remove modes!") 487 487 return True 488 488 … … 491 491 if customer is None: 492 492 return None 493 return customer[' applications']493 return customer['contracts'] 494 494 495 495 def getEntry(self, row, site): 496 applications = self.getParent(row, site)497 if applications is None:498 return None 499 application_id = row.get('application_id', None)500 if application_id is None:501 return None 502 entry = applications.get(application_id)496 contracts = self.getParent(row, site) 497 if contracts is None: 498 return None 499 contract_id = row.get('contract_id', None) 500 if contract_id is None: 501 return None 502 entry = contracts.get(contract_id) 503 503 return entry 504 504 … … 506 506 """Update obj to the values given in row. 507 507 """ 508 items_changed = super( ApplicationProcessor, self).updateEntry(508 items_changed = super(ContractProcessor, self).updateEntry( 509 509 obj, row, site, filename) 510 510 customer = self.getParent(row, site).__parent__ … … 516 516 def addEntry(self, obj, row, site): 517 517 parent = self.getParent(row, site) 518 application_id = row['application_id'].strip('#')519 parent[ application_id] = obj518 contract_id = row['contract_id'].strip('#') 519 parent[contract_id] = obj 520 520 return 521 521 522 522 def delEntry(self, row, site): 523 application= self.getEntry(row, site)523 contract = self.getEntry(row, site) 524 524 parent = self.getParent(row, site) 525 if applicationis not None:525 if contract is not None: 526 526 customer = self._getCustomer(row, site) 527 customer.__parent__.logger.info('%s - Applicationremoved: %s'528 % (customer.customer_id, application.application_id))529 del parent[ application.application_id]527 customer.__parent__.logger.info('%s - Contract removed: %s' 528 % (customer.customer_id, contract.contract_id)) 529 del parent[contract.contract_id] 530 530 return 531 531 … … 534 534 """ 535 535 errs, inv_errs, conv_dict = super( 536 ApplicationProcessor, self).checkConversion(row, mode=mode)536 ContractProcessor, self).checkConversion(row, mode=mode) 537 537 # We need to check if the class_name corresponds with the 538 538 # processor chosen. This is to avoid accidentally wrong imports. … … 541 541 if class_name != self.factory_name.strip('waeup.'): 542 542 errs.append(('class_name','wrong processor')) 543 # We have to check application_id.544 application_id = row.get('application_id', None)543 # We have to check contract_id. 544 contract_id = row.get('contract_id', None) 545 545 if mode == 'create': 546 if not application_id:547 application_id = generate_application_id()548 conv_dict[' application_id'] = application_id546 if not contract_id: 547 contract_id = generate_contract_id() 548 conv_dict['contract_id'] = contract_id 549 549 return errs, inv_errs, conv_dict 550 cat = queryUtility(ICatalog, name=' applications_catalog')550 cat = queryUtility(ICatalog, name='contracts_catalog') 551 551 results = list( 552 cat.searchResults( application_id=(application_id, application_id)))552 cat.searchResults(contract_id=(contract_id, contract_id))) 553 553 if results: 554 # application_id must not exist.555 errs.append((' application_id','id exists'))554 # contract_id must not exist. 555 errs.append(('contract_id','id exists')) 556 556 else: 557 if not application_id.startswith('a'):558 errs.append((' application_id','invalid format'))557 if not contract_id.startswith('a'): 558 errs.append(('contract_id','invalid format')) 559 559 return errs, inv_errs, conv_dict -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12096 r12097 51 51 ICustomer, ICustomersContainer, ICustomerRequestPW, ICustomersUtils, 52 52 ICustomerDocument, ICustomerDocumentsContainer, ICustomerCreate, 53 ICustomerPDFDocument, I ApplicationsContainer, IApplication, IApplicationEdit53 ICustomerPDFDocument, IContractsContainer, IContract, IContractEdit 54 54 ) 55 55 from waeup.ikoba.customers.catalog import search … … 1029 1029 omit_fields=self.omit_fields) 1030 1030 1031 # Pages for customer applications1032 1033 class ApplicationsBreadcrumb(Breadcrumb):1034 """A breadcrumb for the applications container.1035 """ 1036 grok.context(I ApplicationsContainer)1037 title = _(' Applications')1038 1039 1040 class ApplicationBreadcrumb(Breadcrumb):1031 # Pages for customer contracts 1032 1033 class ContractsBreadcrumb(Breadcrumb): 1034 """A breadcrumb for the contracts container. 1035 """ 1036 grok.context(IContractsContainer) 1037 title = _('Contracts') 1038 1039 1040 class ContractBreadcrumb(Breadcrumb): 1041 1041 """A breadcrumb for the customer container. 1042 1042 """ 1043 grok.context(I Application)1043 grok.context(IContract) 1044 1044 1045 1045 @property 1046 1046 def title(self): 1047 return self.context. application_id1048 1049 1050 class ApplicationsManageFormPage(IkobaEditFormPage):1051 """ Page to manage the customer applications1047 return self.context.contract_id 1048 1049 1050 class ContractsManageFormPage(IkobaEditFormPage): 1051 """ Page to manage the customer contracts 1052 1052 1053 1053 This manage form page is for both customers and officers. 1054 1054 """ 1055 grok.context(I ApplicationsContainer)1055 grok.context(IContractsContainer) 1056 1056 grok.name('index') 1057 1057 grok.require('waeup.viewCustomer') 1058 form_fields = grok.AutoFields(I ApplicationsContainer)1059 grok.template(' applicationsmanagepage')1060 pnav = 4 1061 1062 @property 1063 def manage_ applications_allowed(self):1064 return checkPermission('waeup.edit Applications', self.context)1065 1066 def unremovable(self, application):1058 form_fields = grok.AutoFields(IContractsContainer) 1059 grok.template('contractsmanagepage') 1060 pnav = 4 1061 1062 @property 1063 def manage_contracts_allowed(self): 1064 return checkPermission('waeup.editContracts', self.context) 1065 1066 def unremovable(self, contract): 1067 1067 usertype = getattr(self.request.principal, 'user_type', None) 1068 1068 if not usertype: 1069 1069 return False 1070 if not self.manage_ applications_allowed:1070 if not self.manage_contracts_allowed: 1071 1071 return True 1072 1072 return (self.request.principal.user_type == 'customer' and \ 1073 application.state in (APPROVED, REJECTED, EXPIRED))1074 1075 @property 1076 def label(self): 1077 return _('${a}: Applications',1073 contract.state in (APPROVED, REJECTED, EXPIRED)) 1074 1075 @property 1076 def label(self): 1077 return _('${a}: Contracts', 1078 1078 mapping = {'a':self.context.__parent__.display_fullname}) 1079 1079 1080 @jsaction(_('Remove selected applications'))1081 def del Application(self, **data):1080 @jsaction(_('Remove selected contracts')) 1081 def delContract(self, **data): 1082 1082 form = self.request.form 1083 1083 if 'val_id' in form: 1084 1084 child_id = form['val_id'] 1085 1085 else: 1086 self.flash(_('No applicationselected.'), type="warning")1086 self.flash(_('No contract selected.'), type="warning") 1087 1087 self.redirect(self.url(self.context)) 1088 1088 return … … 1091 1091 deleted = [] 1092 1092 for id in child_id: 1093 # Customers are not allowed to remove used applications1094 application= self.context.get(id, None)1095 if application is not None and not self.unremovable(application):1093 # Customers are not allowed to remove used contracts 1094 contract = self.context.get(id, None) 1095 if contract is not None and not self.unremovable(contract): 1096 1096 del self.context[id] 1097 1097 deleted.append(id) … … 1105 1105 1106 1106 1107 class ApplicationAddFormPage(IkobaAddFormPage):1108 """ Page to add an application1109 """ 1110 grok.context(I ApplicationsContainer)1107 class ContractAddFormPage(IkobaAddFormPage): 1108 """ Page to add an contract 1109 """ 1110 grok.context(IContractsContainer) 1111 1111 grok.name('addapp') 1112 grok.template(' applicationaddform')1113 grok.require('waeup.edit Applications')1114 form_fields = grok.AutoFields(I Application)1115 label = _('Add application')1112 grok.template('contractaddform') 1113 grok.require('waeup.editContracts') 1114 form_fields = grok.AutoFields(IContract) 1115 label = _('Add contract') 1116 1116 pnav = 4 1117 1117 … … 1121 1121 return sorted(apptypes.items()) 1122 1122 1123 @action(_('Create application'), style='primary')1124 def create Application(self, **data):1123 @action(_('Create contract'), style='primary') 1124 def createContract(self, **data): 1125 1125 form = self.request.form 1126 1126 customer = self.context.__parent__ 1127 1127 apptype = form.get('apptype', None) 1128 # Here we can create various instances of Applicationderived1128 # Here we can create various instances of Contract derived 1129 1129 # classes depending on the apptype parameter given in form. 1130 application= createObject('waeup.%s' % apptype)1131 self.context.add Application(application)1130 contract = createObject('waeup.%s' % apptype) 1131 self.context.addContract(contract) 1132 1132 apptype = getUtility(ICustomersUtils).SELECTABLE_APPTYPES_DICT[apptype] 1133 1133 self.flash(_('${a} created.', 1134 1134 mapping = {'a': apptype})) 1135 1135 self.context.writeLogMessage( 1136 self,'added: %s %s' % (apptype, application.application_id))1136 self,'added: %s %s' % (apptype, contract.contract_id)) 1137 1137 self.redirect(self.url(self.context)) 1138 1138 return … … 1143 1143 1144 1144 1145 class ApplicationDisplayFormPage(IkobaDisplayFormPage):1146 """ Page to view a application1147 """ 1148 grok.context(I Application)1145 class ContractDisplayFormPage(IkobaDisplayFormPage): 1146 """ Page to view a contract 1147 """ 1148 grok.context(IContract) 1149 1149 grok.name('index') 1150 1150 grok.require('waeup.viewCustomer') 1151 grok.template(' applicationpage')1152 form_fields = grok.AutoFields(I Application).omit('last_transition_date')1151 grok.template('contractpage') 1152 form_fields = grok.AutoFields(IContract).omit('last_transition_date') 1153 1153 pnav = 4 1154 1154 … … 1158 1158 1159 1159 1160 class ApplicationManageFormPage(IkobaEditFormPage):1161 """ Page to edit a application1162 """ 1163 grok.context(I Application)1160 class ContractManageFormPage(IkobaEditFormPage): 1161 """ Page to edit a contract 1162 """ 1163 grok.context(IContract) 1164 1164 grok.name('manage') 1165 1165 grok.require('waeup.manageCustomer') 1166 grok.template(' applicationeditpage')1167 form_fields = grok.AutoFields(I Application).omit('last_transition_date')1166 grok.template('contracteditpage') 1167 form_fields = grok.AutoFields(IContract).omit('last_transition_date') 1168 1168 pnav = 4 1169 1169 deletion_warning = _('Are you sure?') … … 1179 1179 1180 1180 1181 class ApplicationEditFormPage(ApplicationManageFormPage):1182 """ Page to edit a application1181 class ContractEditFormPage(ContractManageFormPage): 1182 """ Page to edit a contract 1183 1183 """ 1184 1184 grok.name('edit') 1185 1185 grok.require('waeup.handleCustomer') 1186 form_fields = grok.AutoFields(I ApplicationEdit).omit('last_transition_date')1186 form_fields = grok.AutoFields(IContractEdit).omit('last_transition_date') 1187 1187 1188 1188 def update(self): … … 1190 1190 emit_lock_message(self) 1191 1191 return 1192 return super( ApplicationEditFormPage, self).update()1192 return super(ContractEditFormPage, self).update() 1193 1193 1194 1194 @action(_('Save'), style='primary') … … 1206 1206 1207 1207 1208 class ApplicationTriggerTransitionFormPage(IkobaEditFormPage):1209 """ View to trigger customer applicationtransitions1210 """ 1211 grok.context(I Application)1208 class ContractTriggerTransitionFormPage(IkobaEditFormPage): 1209 """ View to trigger customer contract transitions 1210 """ 1211 grok.context(IContract) 1212 1212 grok.name('trigtrans') 1213 1213 grok.require('waeup.triggerTransition') 1214 1214 grok.template('trigtrans') 1215 label = _('Trigger applicationtransition')1215 label = _('Trigger contract transition') 1216 1216 pnav = 4 1217 1217 … … 1240 1240 return 1241 1241 1242 class PDF ApplicationsOverviewPage(UtilityView, grok.View):1242 class PDFContractsOverviewPage(UtilityView, grok.View): 1243 1243 """Deliver an overview slip. 1244 1244 """ 1245 grok.context(I ApplicationsContainer)1246 grok.name(' applications_overview_slip.pdf')1245 grok.context(IContractsContainer) 1246 grok.name('contracts_overview_slip.pdf') 1247 1247 grok.require('waeup.viewCustomer') 1248 1248 prefix = 'form' … … 1256 1256 def label(self): 1257 1257 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 1258 return translate(_(' Applications of'),1258 return translate(_('Contracts of'), 1259 1259 'waeup.ikoba', target_language=portal_language) \ 1260 1260 + ' %s' % self.context.customer.display_fullname … … 1264 1264 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 1265 1265 tabletitle = [] 1266 tabletitle.append(translate(_('Customer Applications'), 'waeup.ikoba',1266 tabletitle.append(translate(_('Customer Contracts'), 'waeup.ikoba', 1267 1267 target_language=portal_language)) 1268 1268 return tabletitle … … 1281 1281 tabledata.append(sorted( 1282 1282 [value for value in self.context.values()])) 1283 tableheader.append([(Id, ' application_id', 2),1283 tableheader.append([(Id, 'contract_id', 2), 1284 1284 (Title, 'title', 6), 1285 1285 (Type, 'translated_class_name', 6), … … 1298 1298 1299 1299 1300 class PDF ApplicationSlipPage(UtilityView, grok.View):1300 class PDFContractSlipPage(UtilityView, grok.View): 1301 1301 """Deliver pdf file including metadata. 1302 1302 """ 1303 grok.context(I Application)1304 grok.name(' application_slip.pdf')1303 grok.context(IContract) 1304 grok.name('contract_slip.pdf') 1305 1305 grok.require('waeup.viewCustomer') 1306 1306 prefix = 'form' … … 1309 1309 'suspended_comment',) 1310 1310 1311 #form_fields = grok.AutoFields(ICustomerPDF Application).omit(1311 #form_fields = grok.AutoFields(ICustomerPDFContract).omit( 1312 1312 # 'last_transition_date') 1313 1313 form_fields =() … … 1327 1327 customers_utils = getUtility(ICustomersUtils) 1328 1328 return customers_utils.renderPDF( 1329 self, ' application_slip.pdf',1329 self, 'contract_slip.pdf', 1330 1330 self.context.customer, customerview, 1331 1331 omit_fields=self.omit_fields) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractaddform.pt
r12096 r12097 5 5 <tr> 6 6 <td class="fieldname"> 7 <span i18n:translate=""> ApplicationType</span>:7 <span i18n:translate="">Contract Type</span>: 8 8 </td> 9 9 <td> -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractpage.pt
r12096 r12097 1 1 <div class="wfstatus-sub" i18n:domain="waeup.ikoba"> 2 ApplicationState: <span tal:replace="context/translated_state">3 APPLICATIONSTATE</span>2 Contract State: <span tal:replace="context/translated_state"> 3 CONTRACTSTATE</span> 4 4 </div> 5 5 … … 14 14 <tr> 15 15 <td i18n:translate="" class="fieldname"> 16 ApplicationType:16 Contract Type: 17 17 </td> 18 18 <td> -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractsmanagepage.pt
r12096 r12097 23 23 <td> 24 24 <a tal:attributes="href python: view.url(cl)"> 25 <span tal:content="cl/ application_id">APPID</span></a>25 <span tal:content="cl/contract_id">CONID</span></a> 26 26 </td> 27 27 <td> … … 43 43 </table> 44 44 45 <div tal:condition="python: view.availableActions and view.manage_ applications_allowed">45 <div tal:condition="python: view.availableActions and view.manage_contracts_allowed"> 46 46 <span tal:repeat="action view/actions" 47 47 tal:omit-tag=""> -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/catalog.py
r12094 r12097 27 27 from waeup.ikoba.interfaces import ( 28 28 ICompany, IQueryResultItem) 29 from waeup.ikoba.customers.interfaces import ICustomer, I Application29 from waeup.ikoba.customers.interfaces import ICustomer, IContract 30 30 31 31 … … 119 119 120 120 121 # Catalog for customer applications121 # Catalog for customer contracts 122 122 123 class ApplicationIndexes(grok.Indexes):124 """A catalog for all applications.123 class ContractIndexes(grok.Indexes): 124 """A catalog for all contracts. 125 125 """ 126 126 grok.site(ICompany) 127 grok.name(' applications_catalog')128 grok.context(I Application)127 grok.name('contracts_catalog') 128 grok.context(IContract) 129 129 130 application_id = grok.index.Field(attribute='application_id')130 contract_id = grok.index.Field(attribute='contract_id') 131 131 last_product_id = grok.index.Field(attribute='last_product_id') 132 application_category = grok.index.Field(attribute='application_category')132 contract_category = grok.index.Field(attribute='contract_category') -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/contracts.py
r12096 r12097 17 17 ## 18 18 """ 19 Customer applicationcomponents.19 Customer contract components. 20 20 """ 21 21 import os … … 28 28 from waeup.ikoba.interfaces import IIkobaUtils, IObjectHistory 29 29 from waeup.ikoba.customers.interfaces import ( 30 I ApplicationsContainer, ICustomerNavigation,31 I Application, IApplicationEdit, ICustomersUtils,30 IContractsContainer, ICustomerNavigation, 31 IContract, IContractEdit, ICustomersUtils, 32 32 ) 33 from waeup.ikoba.customers.utils import generate_ application_id33 from waeup.ikoba.customers.utils import generate_contract_id 34 34 from waeup.ikoba.utils.helpers import attrs_to_fields 35 35 36 class ApplicationsContainer(grok.Container):37 """This is a container for customer applications.36 class ContractsContainer(grok.Container): 37 """This is a container for customer contracts. 38 38 """ 39 grok.implements(I ApplicationsContainer, ICustomerNavigation)40 grok.provides(I ApplicationsContainer)39 grok.implements(IContractsContainer, ICustomerNavigation) 40 grok.provides(IContractsContainer) 41 41 42 def add Application(self, application):43 if not I Application.providedBy(application):42 def addContract(self, contract): 43 if not IContract.providedBy(contract): 44 44 raise TypeError( 45 ' ApplicationsContainers contain only IApplicationinstances')46 self[ application.application_id] = application45 'ContractsContainers contain only IContract instances') 46 self[contract.contract_id] = contract 47 47 return 48 48 … … 54 54 return self.__parent__.writeLogMessage(view, message) 55 55 56 ApplicationsContainer = attrs_to_fields(ApplicationsContainer)56 ContractsContainer = attrs_to_fields(ContractsContainer) 57 57 58 class ApplicationBase(grok.Container):59 """This is a customer applicationbaseclass.58 class ContractBase(grok.Container): 59 """This is a customer contract baseclass. 60 60 """ 61 grok.implements(I Application, IApplicationEdit, ICustomerNavigation)62 grok.provides(I Application)61 grok.implements(IContract, IContractEdit, ICustomerNavigation) 62 grok.provides(IContract) 63 63 grok.baseclass() 64 64 65 application_category = None65 contract_category = None 66 66 67 67 def __init__(self): 68 super( ApplicationBase, self).__init__()68 super(ContractBase, self).__init__() 69 69 # The site doesn't exist in unit tests 70 70 try: 71 self. application_id = generate_application_id()71 self.contract_id = generate_contract_id() 72 72 except AttributeError: 73 self. application_id = u'a123'73 self.contract_id = u'a123' 74 74 self.last_product_id = None 75 75 return … … 88 88 try: 89 89 TRANSLATED_STATES = getUtility( 90 ICustomersUtils).TRANSLATED_ APPLICATION_STATES90 ICustomersUtils).TRANSLATED_CONTRACT_STATES 91 91 return TRANSLATED_STATES[self.state] 92 92 except KeyError: … … 120 120 cond1 = self.customer.state in getUtility( 121 121 ICustomersUtils).APPMANAGE_CUSTOMER_STATES 122 # Applicationmust be in state created122 # Contract must be in state created 123 123 cond2 = self.state in getUtility( 124 ICustomersUtils).APPMANAGE_ APPLICATION_STATES124 ICustomersUtils).APPMANAGE_CONTRACT_STATES 125 125 if not (cond1 and cond2): 126 126 return False … … 138 138 139 139 140 class Sample Application(ApplicationBase):141 """This is a sample application.140 class SampleContract(ContractBase): 141 """This is a sample contract. 142 142 """ 143 143 144 application_category = 'sample'144 contract_category = 'sample' 145 145 146 Sample Application = attrs_to_fields(SampleApplication)146 SampleContract = attrs_to_fields(SampleContract) 147 147 148 148 149 # Applications must be importable. So we might need a factory.150 class Sample ApplicationFactory(grok.GlobalUtility):151 """A factory for applications.149 # Contracts must be importable. So we might need a factory. 150 class SampleContractFactory(grok.GlobalUtility): 151 """A factory for contracts. 152 152 """ 153 153 grok.implements(IFactory) 154 grok.name(u'waeup.Sample Application')155 title = u"Create a new application.",156 description = u"This factory instantiates new sample applicationinstances."154 grok.name(u'waeup.SampleContract') 155 title = u"Create a new contract.", 156 description = u"This factory instantiates new sample contract instances." 157 157 158 158 def __call__(self, *args, **kw): 159 return Sample Application(*args, **kw)159 return SampleContract(*args, **kw) 160 160 161 161 def getInterfaces(self): 162 return implementedBy(Sample Application)162 return implementedBy(SampleContract) 163 163 164 @grok.subscribe(I Application, grok.IObjectAddedEvent)165 def handle_ application_added(application, event):166 """If an applicationis added the transition create is fired.164 @grok.subscribe(IContract, grok.IObjectAddedEvent) 165 def handle_contract_added(contract, event): 166 """If an contract is added the transition create is fired. 167 167 The latter produces a logging message. 168 168 """ 169 if IWorkflowState( application).getState() is None:170 IWorkflowInfo( application).fireTransition('create')169 if IWorkflowState(contract).getState() is None: 170 IWorkflowInfo(contract).fireTransition('create') 171 171 return -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/customer.py
r12090 r12097 43 43 from waeup.ikoba.customers.utils import generate_customer_id, path_from_custid 44 44 from waeup.ikoba.customers.documents import CustomerDocumentsContainer 45 from waeup.ikoba.customers. applications import ApplicationsContainer45 from waeup.ikoba.customers.contracts import ContractsContainer 46 46 from waeup.ikoba.utils.helpers import attrs_to_fields, now, copy_filesystem_tree 47 47 … … 184 184 documents = CustomerDocumentsContainer() 185 185 customer['documents'] = documents 186 applications = ApplicationsContainer()187 customer[' applications'] = applications186 contracts = ContractsContainer() 187 customer['contracts'] = contracts 188 188 return 189 189 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12095 r12097 23 23 from waeup.ikoba.interfaces import MessageFactory as _ 24 24 from waeup.ikoba.interfaces import ( 25 IIkobaObject, application_sessions_vocab,validate_email, ICSVExporter)25 IIkobaObject, validate_email, ICSVExporter) 26 26 from waeup.ikoba.schema import TextLineChoice, FormattedDate, PhoneNumber 27 27 from waeup.ikoba.browser.interfaces import ICustomerNavigationBase … … 248 248 """ 249 249 250 # Customer applicationinterfaces251 252 class I ApplicationsContainer(IIkobaObject):250 # Customer contract interfaces 251 252 class IContractsContainer(IIkobaObject): 253 253 """A container for customer aplication objects. 254 254 255 255 """ 256 256 257 def add Application(application):258 """Add an applicationobject.259 """ 260 261 262 class I Application(IIkobaObject):263 """A customer application.264 265 """ 266 application_id = Attribute('ApplicationIdentifier')257 def addContract(contract): 258 """Add an contract object. 259 """ 260 261 262 class IContract(IIkobaObject): 263 """A customer contract. 264 265 """ 266 contract_id = Attribute('Contract Identifier') 267 267 history = Attribute('Object history, a list of messages') 268 state = Attribute('Returns the applicationstate')268 state = Attribute('Returns the contract state') 269 269 translated_state = Attribute( 270 270 'Returns a translated, more verbose appliction state') 271 class_name = Attribute('Name of the applicationclass')271 class_name = Attribute('Name of the contract class') 272 272 formatted_transition_date = Attribute( 273 273 'Last transition formatted date string') 274 application_category = Attribute('Category for the grouping of products')274 contract_category = Attribute('Category for the grouping of products') 275 275 last_product_id = Attribute( 276 'Id of product recently stored with the application')276 'Id of product recently stored with the contract') 277 277 278 278 title = schema.TextLine( 279 title = _(u' ApplicationTitle'),279 title = _(u'Contract Title'), 280 280 required = True, 281 281 ) … … 293 293 ) 294 294 295 class I ApplicationEdit(IApplication):296 """Interface for editing applicationdata by customers.295 class IContractEdit(IContract): 296 """Interface for editing contract data by customers. 297 297 298 298 """ -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/permissions.py
r12091 r12097 48 48 49 49 50 class Edit Applications(grok.Permission):51 grok.name('waeup.edit Applications')50 class EditContracts(grok.Permission): 51 grok.name('waeup.editContracts') 52 52 53 53 … … 74 74 grok.permissions('waeup.handleCustomer', 'waeup.uploadCustomerFile', 75 75 'waeup.viewCustomer', 'waeup.editCustomerDocuments', 76 'waeup.edit Applications')76 'waeup.editContracts') 77 77 78 78 … … 99 99 'waeup.editCustomerDocuments', 'waeup.uploadCustomerFile', 100 100 'waeup.viewCustomersTab', 'waeup.triggerTransition', 101 'waeup.edit Applications')101 'waeup.editContracts') 102 102 103 103 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12096 r12097 96 96 self.product.product_id = u'SAM' 97 97 self.product.title = u'Our Samle Product' 98 self.product. application_category = u'sample'98 self.product.contract_category = u'sample' 99 99 self.app['products'].addProduct(self.product) 100 100 … … 114 114 document.title = u'My first document' 115 115 self.customer['documents'].addDocument(document) 116 application = createObject('waeup.SampleApplication')117 application.title = u'My first application'118 self.customer[' applications'].addApplication(application)116 contract = createObject('waeup.SampleContract') 117 contract.title = u'My first contract' 118 self.customer['contracts'].addContract(contract) 119 119 120 120 # Set password … … 131 131 self.history_path = self.customer_path + '/history' 132 132 self.documents_path = self.customer_path + '/documents' 133 self. applications_path = self.customer_path + '/applications'133 self.contracts_path = self.customer_path + '/contracts' 134 134 135 135 self.app['configuration'].carry_over = True … … 1052 1052 1053 1053 1054 class ApplicationUITests(CustomersFullSetup):1055 # Tests for CustomerSample Applicationrelates views and pages1056 1057 def test_manage_ application(self):1058 # Managers can access the pages of customer applicationsconter1054 class ContractUITests(CustomersFullSetup): 1055 # Tests for CustomerSampleContract relates views and pages 1056 1057 def test_manage_contract(self): 1058 # Managers can access the pages of customer contractsconter 1059 1059 # and can perform actions 1060 1060 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') … … 1063 1063 self.assertEqual(self.browser.url, self.customer_path) 1064 1064 self.browser.open(self.customer_path) 1065 self.browser.getLink(" Applications").click()1066 self.browser.getLink("Add application").click()1067 self.browser.getControl(name="apptype").value = ['Sample Application']1068 self.browser.getControl("Create application").click()1069 self.assertTrue('Sample Applicationcreated.' in self.browser.contents)1070 application = self.customer['applications']['a102']1071 1072 # Applicationcan be edited1065 self.browser.getLink("Contracts").click() 1066 self.browser.getLink("Add contract").click() 1067 self.browser.getControl(name="apptype").value = ['SampleContract'] 1068 self.browser.getControl("Create contract").click() 1069 self.assertTrue('Sample Contract created.' in self.browser.contents) 1070 contract = self.customer['contracts']['a102'] 1071 1072 # Contract can be edited 1073 1073 self.browser.getLink("a102").click() 1074 1074 self.browser.getLink("Manage").click() … … 1078 1078 self.assertTrue('Form has been saved.' in self.browser.contents) 1079 1079 self.browser.getLink("View").click() 1080 self.assertEqual(self.browser.url, self. applications_path + '/a102/index')1080 self.assertEqual(self.browser.url, self.contracts_path + '/a102/index') 1081 1081 1082 1082 # Transitions can be performed … … 1086 1086 self.browser.getControl(name="transition").value = ['approve'] 1087 1087 self.browser.getControl("Save").click() 1088 self.assertEqual( application.state, 'approved')1089 1090 # Applications can be removed1091 self.browser.getLink(" Applications").click()1088 self.assertEqual(contract.state, 'approved') 1089 1090 # Contracts can be removed 1091 self.browser.getLink("Contracts").click() 1092 1092 ctrl = self.browser.getControl(name='val_id') 1093 ctrl.getControl(value= application.application_id).selected = True1093 ctrl.getControl(value=contract.contract_id).selected = True 1094 1094 self.browser.getControl("Remove selected", index=0).click() 1095 1095 self.assertTrue('Successfully removed' in self.browser.contents) … … 1100 1100 logcontent = open(logfile).read() 1101 1101 self.assertTrue( 1102 'INFO - zope.mgr - customers.browser. ApplicationManageFormPage '1102 'INFO - zope.mgr - customers.browser.ContractManageFormPage ' 1103 1103 '- K1000000 - a102 - saved: title' 1104 1104 in logcontent) 1105 1105 self.assertTrue( 1106 'INFO - zope.mgr - customers.browser. ApplicationAddFormPage '1107 '- K1000000 - added: Sample Application%s'1108 % application.application_id in logcontent)1109 self.assertTrue( 1110 'INFO - zope.mgr - customers.browser. ApplicationsManageFormPage '1106 'INFO - zope.mgr - customers.browser.ContractAddFormPage ' 1107 '- K1000000 - added: Sample Contract %s' 1108 % contract.contract_id in logcontent) 1109 self.assertTrue( 1110 'INFO - zope.mgr - customers.browser.ContractsManageFormPage ' 1111 1111 '- K1000000 - removed: %s' 1112 % application.application_id in logcontent)1113 1114 def test_edit_sample_ application(self):1112 % contract.contract_id in logcontent) 1113 1114 def test_edit_sample_contract(self): 1115 1115 # We add a second product. 1116 1116 product = createObject('waeup.Product') 1117 1117 product.product_id = u'LIC' 1118 1118 product.title = u'Our License Product' 1119 product. application_category = u'license'1119 product.contract_category = u'license' 1120 1120 self.app['products'].addProduct(product) 1121 # Customers can manage applications under certain conditions1121 # Customers can manage contracts under certain conditions 1122 1122 self.browser.open(self.login_path) 1123 1123 self.browser.getControl(name="form.login").value = self.customer_id … … 1126 1126 self.assertMatches( 1127 1127 '...You logged in...', self.browser.contents) 1128 self.browser.getLink(" Applications").click()1129 self.browser.getLink("Add application").click()1130 self.browser.getControl(name="apptype").value = ['Sample Application']1131 self.browser.getControl("Create application").click()1132 self.assertTrue('Sample Applicationcreated.' in self.browser.contents)1133 application = self.customer['applications']['a102']1134 # Applicationcan be edited ...1128 self.browser.getLink("Contracts").click() 1129 self.browser.getLink("Add contract").click() 1130 self.browser.getControl(name="apptype").value = ['SampleContract'] 1131 self.browser.getControl("Create contract").click() 1132 self.assertTrue('Sample Contract created.' in self.browser.contents) 1133 contract = self.customer['contracts']['a102'] 1134 # Contract can be edited ... 1135 1135 self.browser.getLink("a102").click() 1136 self.browser.open(self. applications_path + '/a102/edit')1136 self.browser.open(self.contracts_path + '/a102/edit') 1137 1137 #self.browser.getLink("Edit").click() 1138 1138 self.assertTrue('The requested form is locked' in self.browser.contents) 1139 1139 # Customer is in wrong state 1140 1140 IWorkflowState(self.customer).setState(APPROVED) 1141 self.browser.open(self. applications_path + '/a102/edit')1141 self.browser.open(self.contracts_path + '/a102/edit') 1142 1142 self.browser.getControl(name="form.title").value = 'My second app' 1143 # SAM is in the correct application_category ...1143 # SAM is in the correct contract_category ... 1144 1144 self.assertTrue('<option value="SAM">' in self.browser.contents) 1145 1145 # ... but NOTSAM not. 1146 1146 self.assertFalse('<option value="LIC">' in self.browser.contents) 1147 1147 # So far last_product_id is None. 1148 self.assertTrue(self.customer[' applications']['a102'].last_product_id is None)1148 self.assertTrue(self.customer['contracts']['a102'].last_product_id is None) 1149 1149 self.browser.getControl(name="form.product").value = ['SAM'] 1150 1150 self.browser.getControl("Save").click() 1151 1151 # After saving the form, last_product_id is set. 1152 self.assertEqual(self.customer[' applications']['a102'].last_product_id, 'SAM')1152 self.assertEqual(self.customer['contracts']['a102'].last_product_id, 'SAM') 1153 1153 self.assertTrue('Form has been saved.' in self.browser.contents) 1154 1154 # Saving the form again does not unset last_product_id 1155 self.assertEqual( application.title, 'My second app')1156 self.browser.getControl("Save").click() 1157 self.assertEqual(self.customer[' applications']['a102'].last_product_id, 'SAM')1155 self.assertEqual(contract.title, 'My second app') 1156 self.browser.getControl("Save").click() 1157 self.assertEqual(self.customer['contracts']['a102'].last_product_id, 'SAM') 1158 1158 self.assertTrue('Form has been saved.' in self.browser.contents) 1159 1159 self.browser.getLink("View").click() 1160 self.assertEqual(self.browser.url, self. applications_path + '/a102/index')1160 self.assertEqual(self.browser.url, self.contracts_path + '/a102/index') 1161 1161 # Customer can submit the form. The form is also saved. 1162 1162 self.browser.getLink("Edit").click() 1163 1163 self.browser.getControl(name="form.title").value = 'My third app' 1164 1164 self.browser.getControl("Apply now").click() 1165 self.assertEqual( application.title, 'My third app')1166 self.assertEqual( application.state, 'submitted')1167 self.assertTrue(' ApplicationState: submitted for approval' in self.browser.contents)1168 # Customer can't edit the applicationonce it has been submitted1169 self.browser.open(self. applications_path + '/a102/edit')1165 self.assertEqual(contract.title, 'My third app') 1166 self.assertEqual(contract.state, 'submitted') 1167 self.assertTrue('Contract State: submitted for approval' in self.browser.contents) 1168 # Customer can't edit the contract once it has been submitted 1169 self.browser.open(self.contracts_path + '/a102/edit') 1170 1170 self.assertTrue('The requested form is locked' in self.browser.contents) 1171 1171 1172 1172 def test_view_slips(self): 1173 1173 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1174 # Officers can open the applicationoverview1175 self.browser.open(self.customer_path + '/ applications')1176 self.browser.getLink("Download applications overview").click()1174 # Officers can open the contract overview 1175 self.browser.open(self.customer_path + '/contracts') 1176 self.browser.getLink("Download contracts overview").click() 1177 1177 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1178 1178 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1179 path = os.path.join(samples_dir(), ' applications_overview_slip.pdf')1179 path = os.path.join(samples_dir(), 'contracts_overview_slip.pdf') 1180 1180 open(path, 'wb').write(self.browser.contents) 1181 1181 print "Sample PDF overview_slip.pdf written to %s" % path 1182 # Officers can open applicationslips1183 self.browser.open(self.customer_path + '/ applications/a101')1184 self.browser.getLink("Download applicationslip").click()1182 # Officers can open contract slips 1183 self.browser.open(self.customer_path + '/contracts/a101') 1184 self.browser.getLink("Download contract slip").click() 1185 1185 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1186 1186 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1187 path = os.path.join(samples_dir(), ' application_slip.pdf')1187 path = os.path.join(samples_dir(), 'contract_slip.pdf') 1188 1188 open(path, 'wb').write(self.browser.contents) 1189 print "Sample application_slip.pdf written to %s" % path1190 1189 print "Sample contract_slip.pdf written to %s" % path 1190 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py
r12095 r12097 27 27 from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase 28 28 from waeup.ikoba.customers.customer import Customer 29 from waeup.ikoba.customers. applications import SampleApplication29 from waeup.ikoba.customers.contracts import SampleContract 30 30 31 31 … … 61 61 product.product_id = u'SAM' 62 62 product.title = u'Our Samle Product' 63 product. application_category = u'sample'63 product.contract_category = u'sample' 64 64 self.app['products'].addProduct(product) 65 65 self.product_id = product.product_id 66 66 self.product = self.app['products'][self.product_id] 67 67 68 application = createObject('waeup.SampleApplication')69 application.title = u'My Samle Application'70 application.product = product71 application.last_product_id = product.product_id72 self.customer[' applications'].addApplication(application)73 self. application_id = application.application_id74 self. application = self.customer['applications'][self.application_id]68 contract = createObject('waeup.SampleContract') 69 contract.title = u'My Samle Contract' 70 contract.product = product 71 contract.last_product_id = product.product_id 72 self.customer['contracts'].addContract(contract) 73 self.contract_id = contract.contract_id 74 self.contract = self.customer['contracts'][self.contract_id] 75 75 76 76 document = createObject('waeup.CustomerSampleDocument') … … 125 125 126 126 def test_search_by_id(self): 127 # We can find a certain applicationid127 # We can find a certain contract id 128 128 cat = queryUtility(ICatalog, name='documents_catalog') 129 129 results = cat.searchResults(document_id=(self.document_id, … … 134 134 135 135 136 class ApplicationsCatalogTests(CatalogTestSetup):136 class ContractsCatalogTests(CatalogTestSetup): 137 137 138 138 layer = FunctionalLayer … … 140 140 def test_get_catalog(self): 141 141 # We can get an customers catalog if we wish 142 cat = queryUtility(ICatalog, name=' applications_catalog')142 cat = queryUtility(ICatalog, name='contracts_catalog') 143 143 assert cat is not None 144 144 145 145 def test_search_by_id(self): 146 # We can find a certain applicationid147 cat = queryUtility(ICatalog, name=' applications_catalog')148 results = cat.searchResults( application_id=(self.application_id,149 self. application_id))146 # We can find a certain contract id 147 cat = queryUtility(ICatalog, name='contracts_catalog') 148 results = cat.searchResults(contract_id=(self.contract_id, 149 self.contract_id)) 150 150 results = [x for x in results] # Turn results generator into list 151 151 assert len(results) == 1 152 assert results[0] is self.customer[' applications'][self.application_id]152 assert results[0] is self.customer['contracts'][self.contract_id] 153 153 154 154 def test_search_by_category(self): 155 155 # We can find a certain name 156 cat = queryUtility(ICatalog, name=' applications_catalog')157 results = cat.searchResults( application_category=('sample', 'sample'))156 cat = queryUtility(ICatalog, name='contracts_catalog') 157 results = cat.searchResults(contract_category=('sample', 'sample')) 158 158 results = [x for x in results] # Turn results generator into list 159 159 assert len(results) == 1 160 assert results[0] is self.customer[' applications'][self.application_id]160 assert results[0] is self.customer['contracts'][self.contract_id] 161 161 162 162 def test_search_by_last_product_id(self): 163 163 # We can find a certain name 164 cat = queryUtility(ICatalog, name=' applications_catalog')164 cat = queryUtility(ICatalog, name='contracts_catalog') 165 165 results = cat.searchResults(last_product_id=('SAM', 'SAM')) 166 166 results = [x for x in results] # Turn results generator into list 167 167 assert len(results) == 1 168 assert results[0] is self.customer[' applications'][self.application_id]168 assert results[0] is self.customer['contracts'][self.contract_id] 169 169 assert results[0].product is self.product 170 170 171 171 def test_product_removal(self): 172 172 # This test does not only test catalog components, it also ensures 173 # that the product attribute of an applicationis cleared173 # that the product attribute of an contract is cleared 174 174 # but the last_product_id is not. 175 175 del self.app['products'][self.product_id] 176 self.assertTrue(self. application.product is None)177 self.assertEqual(self. application.last_product_id, 'SAM')178 cat = queryUtility(ICatalog, name=' applications_catalog')176 self.assertTrue(self.contract.product is None) 177 self.assertEqual(self.contract.last_product_id, 'SAM') 178 cat = queryUtility(ICatalog, name='contracts_catalog') 179 179 results = cat.searchResults(last_product_id=('SAM', 'SAM')) 180 180 results = [x for x in results] 181 181 assert len(results) == 1 182 assert results[0] is self.customer[' applications'][self.application_id]182 assert results[0] is self.customer['contracts'][self.contract_id] 183 183 assert results[0].product is None 184 184 # Product removal is being logged in customers.log -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_contract.py
r12096 r12097 17 17 ## 18 18 """ 19 Tests for applications.19 Tests for contracts. 20 20 """ 21 21 from zope.interface.verify import verifyClass, verifyObject … … 24 24 IWorkflowInfo, IWorkflowState, InvalidTransitionError) 25 25 from waeup.ikoba.customers.interfaces import ( 26 I ApplicationsContainer, IApplication)26 IContractsContainer, IContract) 27 27 from waeup.ikoba.interfaces import IObjectHistory 28 from waeup.ikoba.customers. applications import (29 ApplicationsContainer, SampleApplication)28 from waeup.ikoba.customers.contracts import ( 29 ContractsContainer, SampleContract) 30 30 from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase) 31 31 32 class ApplicationsContainerTestCase(FunctionalTestCase):32 class ContractsContainerTestCase(FunctionalTestCase): 33 33 34 34 layer = FunctionalLayer … … 38 38 self.assertTrue( 39 39 verifyClass( 40 I ApplicationsContainer, ApplicationsContainer)40 IContractsContainer, ContractsContainer) 41 41 ) 42 42 self.assertTrue( 43 43 verifyObject( 44 I ApplicationsContainer, ApplicationsContainer())44 IContractsContainer, ContractsContainer()) 45 45 ) 46 46 self.assertTrue( 47 47 verifyClass( 48 I Application, SampleApplication)48 IContract, SampleContract) 49 49 ) 50 50 self.assertTrue( 51 51 verifyObject( 52 I Application, SampleApplication())52 IContract, SampleContract()) 53 53 ) 54 54 return 55 55 56 def test_add Application(self):57 container = ApplicationsContainer()58 application = createObject(u'waeup.SampleApplication')59 id = application.application_id60 container.add Application(application)61 self.assertEqual(container[id], application)62 self.assertRaises(TypeError, container.add Application, object())63 self.assertEqual( application.class_name, 'SampleApplication')56 def test_addContract(self): 57 container = ContractsContainer() 58 contract = createObject(u'waeup.SampleContract') 59 id = contract.contract_id 60 container.addContract(contract) 61 self.assertEqual(container[id], contract) 62 self.assertRaises(TypeError, container.addContract, object()) 63 self.assertEqual(contract.class_name, 'SampleContract') 64 64 self.assertEqual(id, 'a123') 65 65 return 66 66 67 def test_ application_workflow(self):68 application = createObject(u'waeup.SampleApplication')69 IWorkflowInfo( application).fireTransition('create')70 self.assertEqual(IWorkflowState( application).getState(), 'created')71 IWorkflowInfo( application).fireTransition('submit')72 self.assertEqual(IWorkflowState( application).getState(), 'submitted')73 IWorkflowInfo( application).fireTransition('approve')74 self.assertEqual(IWorkflowState( application).getState(), 'approved')75 IWorkflowInfo( application).fireTransition('expire')76 self.assertEqual(IWorkflowState( application).getState(), 'expired')77 IWorkflowInfo( application).fireTransition('reset4')78 self.assertEqual(IWorkflowState( application).getState(), 'created')67 def test_contract_workflow(self): 68 contract = createObject(u'waeup.SampleContract') 69 IWorkflowInfo(contract).fireTransition('create') 70 self.assertEqual(IWorkflowState(contract).getState(), 'created') 71 IWorkflowInfo(contract).fireTransition('submit') 72 self.assertEqual(IWorkflowState(contract).getState(), 'submitted') 73 IWorkflowInfo(contract).fireTransition('approve') 74 self.assertEqual(IWorkflowState(contract).getState(), 'approved') 75 IWorkflowInfo(contract).fireTransition('expire') 76 self.assertEqual(IWorkflowState(contract).getState(), 'expired') 77 IWorkflowInfo(contract).fireTransition('reset4') 78 self.assertEqual(IWorkflowState(contract).getState(), 'created') 79 79 self.assertRaises(InvalidTransitionError, 80 IWorkflowInfo( application).fireTransition, 'approve')81 IWorkflowInfo( application).fireTransition('submit')82 IWorkflowInfo( application).fireTransition('reset3')83 self.assertEqual(IWorkflowState( application).getState(), 'created')80 IWorkflowInfo(contract).fireTransition, 'approve') 81 IWorkflowInfo(contract).fireTransition('submit') 82 IWorkflowInfo(contract).fireTransition('reset3') 83 self.assertEqual(IWorkflowState(contract).getState(), 'created') 84 84 return 85 85 86 def test_ application_history(self):87 doc = createObject(u'waeup.Sample Application')86 def test_contract_history(self): 87 doc = createObject(u'waeup.SampleContract') 88 88 IWorkflowInfo(doc).fireTransition('create') 89 89 messages = ' '.join(doc.history.messages) 90 self.assertTrue(' Applicationrecord created by system' in messages)90 self.assertTrue('Contract record created by system' in messages) 91 91 return -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py
r12091 r12097 268 268 ) 269 269 270 def generate_ application_id():271 new_id = grok.getSite().unique_ application_id270 def generate_contract_id(): 271 new_id = grok.getSite().unique_contract_id 272 272 return new_id 273 273 … … 289 289 APPMANAGE_CUSTOMER_STATES = DOCMANAGE_CUSTOMER_STATES 290 290 291 APPMANAGE_ APPLICATION_STATES = (CREATED,)291 APPMANAGE_CONTRACT_STATES = (CREATED,) 292 292 293 293 SKIP_UPLOAD_VIEWLETS = () … … 301 301 302 302 303 TRANSLATED_ APPLICATION_STATES = {303 TRANSLATED_CONTRACT_STATES = { 304 304 CREATED: _('created'), 305 305 SUBMITTED: _('submitted for approval'), … … 315 315 316 316 APPTYPES_DICT = { 317 'Sample Application': 'Sample Application',317 'SampleContract': 'Sample Contract', 318 318 } 319 319 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py
r12091 r12097 28 28 ICustomer, ICustomersContainer, 29 29 ICustomerDocumentsContainer, ICustomerDocument, 30 I ApplicationsContainer, IApplication)30 IContractsContainer, IContract) 31 31 from waeup.ikoba.customers.browser import ( 32 32 CustomersContainerPage, CustomersContainerManagePage, 33 33 CustomerBaseDisplayFormPage, 34 34 DocumentsManageFormPage, DocumentDisplayFormPage, DocumentManageFormPage, 35 ApplicationsManageFormPage, ApplicationDisplayFormPage,36 ApplicationManageFormPage)35 ContractsManageFormPage, ContractDisplayFormPage, 36 ContractManageFormPage) 37 37 38 38 grok.context(IIkobaObject) # Make IIkobaObject the default context … … 110 110 targets += [ 111 111 {'url':customer_url, 'title':'Base Data'}, 112 {'url':customer_url + '/ applications', 'title':_('My Applications')},112 {'url':customer_url + '/contracts', 'title':_('My Contracts')}, 113 113 {'url':customer_url + '/documents', 'title':_('My Documents')}, 114 114 {'url':customer_url + '/history', 'title':_('History')}, … … 153 153 154 154 155 class CustomerManage ApplicationsLink(CustomerManageLink):156 grok.order(3) 157 link = ' applications'158 text = _(u' Applications')155 class CustomerManageContractsLink(CustomerManageLink): 156 grok.order(3) 157 link = 'contracts' 158 text = _(u'Contracts') 159 159 160 160 … … 372 372 target = 'document_slip.pdf' 373 373 374 # Viewlets for customer applications375 376 class Add ApplicationActionButton(AddActionButton):377 grok.order(1) 378 grok.context(I ApplicationsContainer)379 grok.view( ApplicationsManageFormPage)380 grok.require('waeup.edit Applications')381 text = _('Add application')374 # Viewlets for customer contracts 375 376 class AddContractActionButton(AddActionButton): 377 grok.order(1) 378 grok.context(IContractsContainer) 379 grok.view(ContractsManageFormPage) 380 grok.require('waeup.editContracts') 381 text = _('Add contract') 382 382 target = 'addapp' 383 383 384 384 385 class PDF ApplicationOverviewActionButton(ManageActionButton):386 grok.order(2) 387 grok.context(I ApplicationsContainer)388 grok.view( ApplicationsManageFormPage)385 class PDFContractOverviewActionButton(ManageActionButton): 386 grok.order(2) 387 grok.context(IContractsContainer) 388 grok.view(ContractsManageFormPage) 389 389 grok.require('waeup.viewCustomer') 390 390 icon = 'actionicon_pdf.png' 391 text = _('Download applications overview')392 target = ' applications_overview_slip.pdf'393 394 395 class ApplicationManageActionButton(ManageActionButton):396 grok.order(1) 397 grok.context(I Application)398 grok.view( ApplicationDisplayFormPage)391 text = _('Download contracts overview') 392 target = 'contracts_overview_slip.pdf' 393 394 395 class ContractManageActionButton(ManageActionButton): 396 grok.order(1) 397 grok.context(IContract) 398 grok.view(ContractDisplayFormPage) 399 399 grok.require('waeup.manageCustomer') 400 400 text = _('Manage') … … 402 402 403 403 404 class ApplicationEditActionButton(ManageActionButton):405 grok.order(1) 406 grok.context(I Application)407 grok.view( ApplicationDisplayFormPage)404 class ContractEditActionButton(ManageActionButton): 405 grok.order(1) 406 grok.context(IContract) 407 grok.view(ContractDisplayFormPage) 408 408 grok.require('waeup.handleCustomer') 409 409 text = _('Edit') … … 417 417 418 418 419 class ApplicationTrigTransActionButton(ManageActionButton):420 grok.order(2) 421 grok.context(I Application)422 grok.view( ApplicationDisplayFormPage)419 class ContractTrigTransActionButton(ManageActionButton): 420 grok.order(2) 421 grok.context(IContract) 422 grok.view(ContractDisplayFormPage) 423 423 grok.require('waeup.triggerTransition') 424 424 icon = 'actionicon_trigtrans.png' … … 427 427 428 428 429 class ApplicationViewActionButton(ManageActionButton):430 grok.order(1) 431 grok.context(I Application)432 grok.view( ApplicationManageFormPage)429 class ContractViewActionButton(ManageActionButton): 430 grok.order(1) 431 grok.context(IContract) 432 grok.view(ContractManageFormPage) 433 433 grok.require('waeup.handleCustomer') 434 434 text = _('View') … … 437 437 438 438 439 class PDF ApplicationSlipActionButton(ManageActionButton):440 grok.order(3) 441 grok.context(I Application)442 grok.view( ApplicationDisplayFormPage)439 class PDFContractSlipActionButton(ManageActionButton): 440 grok.order(3) 441 grok.context(IContract) 442 grok.view(ContractDisplayFormPage) 443 443 grok.require('waeup.viewCustomer') 444 444 icon = 'actionicon_pdf.png' 445 text = _('Download applicationslip')446 target = ' application_slip.pdf'447 445 text = _('Download contract slip') 446 target = 'contract_slip.pdf' 447 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/vocabularies.py
r12093 r12097 121 121 122 122 class AppCatProductSource(SmartBasicContextualSourceFactory): 123 """An applicationcategory product delivers all products124 which belong to a certain application_category.123 """An contract category product delivers all products 124 which belong to a certain contract_category. 125 125 """ 126 126 def contains(self, context, value): 127 appcat = getattr(context, ' application_category', None)128 if value. application_category == appcat:127 appcat = getattr(context, 'contract_category', None) 128 if value.contract_category == appcat: 129 129 return True 130 130 return False 131 131 132 132 def getValues(self, context): 133 appcat = getattr(context, ' application_category', None)133 appcat = getattr(context, 'contract_category', None) 134 134 products = grok.getSite()['products'].values() 135 135 if not appcat: 136 136 return products 137 137 resultlist = [ 138 value for value in products if value. application_category == appcat]138 value for value in products if value.contract_category == appcat] 139 139 return resultlist 140 140 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py
r12089 r12097 31 31 from waeup.ikoba.customers.interfaces import ( 32 32 ICustomer, ICustomersUtils, 33 I Application)33 IContract) 34 34 from waeup.ikoba.utils.helpers import get_current_principal 35 35 from waeup.ikoba.documents.workflow import VERIFICATION_TRANSITIONS … … 142 142 return 143 143 144 # Applicationworkflow (the same as verification workflow)145 146 IMPORTABLE_ APPLICATION_STATES = (CREATED, SUBMITTED, APPROVED, REJECTED, EXPIRED)147 148 APPLICATION_TRANSITIONS = (144 # Contract workflow (the same as verification workflow) 145 146 IMPORTABLE_CONTRACT_STATES = (CREATED, SUBMITTED, APPROVED, REJECTED, EXPIRED) 147 148 CONTRACT_TRANSITIONS = ( 149 149 Transition( 150 150 transition_id = 'create', 151 title = _('Create applicationrecord'),151 title = _('Create contract record'), 152 152 source = None, 153 153 condition = NullCondition, 154 msg = _(' Applicationrecord created'),154 msg = _('Contract record created'), 155 155 destination = CREATED), 156 156 … … 213 213 214 214 215 IMPORTABLE_ APPLICATION_TRANSITIONS = [215 IMPORTABLE_CONTRACT_TRANSITIONS = [ 216 216 i.transition_id for i in REGISTRATION_TRANSITIONS] 217 217 218 application_workflow = IkobaWorkflow(APPLICATION_TRANSITIONS)219 220 class ApplicationWorkflowState(WorkflowState, grok.Adapter):221 """An adapter to adapt Applicationobjects to workflow states.222 """ 223 grok.context(I Application)218 contract_workflow = IkobaWorkflow(CONTRACT_TRANSITIONS) 219 220 class ContractWorkflowState(WorkflowState, grok.Adapter): 221 """An adapter to adapt Contract objects to workflow states. 222 """ 223 grok.context(IContract) 224 224 grok.provides(IWorkflowState) 225 225 226 state_key = 'wf. application.state'227 state_id = 'wf. application.id'228 229 class ApplicationWorkflowInfo(IkobaWorkflowInfo, grok.Adapter):230 """Adapter to adapt Applicationobjects to workflow info objects.231 """ 232 grok.context(I Application)226 state_key = 'wf.contract.state' 227 state_id = 'wf.contract.id' 228 229 class ContractWorkflowInfo(IkobaWorkflowInfo, grok.Adapter): 230 """Adapter to adapt Contract objects to workflow info objects. 231 """ 232 grok.context(IContract) 233 233 grok.provides(IIkobaWorkflowInfo) 234 234 235 235 def __init__(self, context): 236 236 self.context = context 237 self.wf = application_workflow238 239 @grok.subscribe(I Application, IWorkflowTransitionEvent)237 self.wf = contract_workflow 238 239 @grok.subscribe(IContract, IWorkflowTransitionEvent) 240 240 def handle_document_transition_event(obj, event): 241 """Append message to applicationhistory and log file and update241 """Append message to contract history and log file and update 242 242 last_transition_date when transition happened. 243 243 """ -
main/waeup.ikoba/trunk/src/waeup/ikoba/permissions.py
r12090 r12097 144 144 'waeup.triggerTransition', 145 145 'waeup.viewCustomersTab', 146 'waeup.edit Applications'146 'waeup.editContracts' 147 147 ) 148 148 … … 170 170 'waeup.triggerTransition', 171 171 'waeup.viewCustomersTab', 172 'waeup.edit Applications'172 'waeup.editContracts' 173 173 ) 174 174 -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/interfaces.py
r12078 r12097 24 24 25 25 class AppCatSource(ContextualDictSourceFactoryBase): 26 """A application category source delivers all applicationcategories26 """A contract category source delivers all contract categories 27 27 provided in the portal. 28 28 """ … … 55 55 ) 56 56 57 application_category = schema.Choice(58 title = _(u' ApplicationCategory'),57 contract_category = schema.Choice( 58 title = _(u'Contract Category'), 59 59 source = AppCatSource(), 60 60 default = u'license', -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/product.py
r12095 r12097 66 66 def handle_product_removed(product, event): 67 67 """If a product is deleted, we make sure that also referrers to 68 customer applicationobjects are removed.68 customer contract objects are removed. 69 69 """ 70 70 prodid = product.product_id 71 71 72 # Find all customer applications that refer to given product...72 # Find all customer contracts that refer to given product... 73 73 try: 74 cat = getUtility(ICatalog, name=' applications_catalog')74 cat = getUtility(ICatalog, name='contracts_catalog') 75 75 except ComponentLookupError: 76 76 # catalog not available. This might happen during tests. 77 77 return 78 78 results = cat.searchResults(last_product_id=(prodid, prodid)) 79 for applicationin results:79 for contract in results: 80 80 # Remove that referrer... 81 application.product = None82 notify(grok.ObjectModifiedEvent( application))83 application.customer.__parent__.logger.info(81 contract.product = None 82 notify(grok.ObjectModifiedEvent(contract)) 83 contract.customer.__parent__.logger.info( 84 84 'ObjectRemovedEvent - %s - %s - removed: product' % ( 85 application.customer.customer_id, application.application_id))85 contract.customer.customer_id, contract.contract_id)) 86 86 return 87 87 -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/sample_product_data.csv
r12078 r12097 1 product_id,title, application_category1 product_id,title,contract_category 2 2 ABC,ABC title,license 3 3 CDE,CDE title,license -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_batching.py
r12078 r12097 165 165 'INFO - system - Product Processor - sample_product_data - ' 166 166 'EFG - updated: product_id=EFG, title=EFG title, ' 167 ' application_category=license\n'167 'contract_category=license\n' 168 168 in logcontent) 169 169 failcontent = open(fail_file).read() -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_export.py
r12078 r12097 62 62 result = open(self.outfile, 'rb').read() 63 63 self.assertTrue( 64 ' application_category,product_id,title,users_with_local_roles\r\n'64 'contract_category,product_id,title,users_with_local_roles\r\n' 65 65 'license,LIC,Unnamed,"[{\'user_name\': u\'john\', \'local_role\': ' 66 66 'u\'johnsrole\'}]"\r\n' … … 75 75 result = open(self.outfile, 'rb').read() 76 76 self.assertTrue( 77 ' application_category,product_id,title,users_with_local_roles\r\n'77 'contract_category,product_id,title,users_with_local_roles\r\n' 78 78 'license,LIC,Unnamed,"[{\'user_name\': u\'john\', \'local_role\': ' 79 79 'u\'johnsrole\'}]"\r\n' -
main/waeup.ikoba/trunk/src/waeup/ikoba/webservices.py
r11954 r12097 20 20 from zope.component import getUtility 21 21 from zope.catalog.interfaces import ICatalog 22 from waeup.ikoba.interfaces import ICompany , application_sessions_vocab22 from waeup.ikoba.interfaces import ICompany 23 23 24 24 class XMLRPCPermission(grok.Permission):
Note: See TracChangeset for help on using the changeset viewer.