Changeset 12356 for main/waeup.ikoba/trunk
- Timestamp:
- 1 Jan 2015, 07:44:44 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12353 r12356 863 863 grok.context(ICustomerDocumentsContainer) 864 864 grok.name('adddoc') 865 grok.template('documentadd form')865 grok.template('documentaddpage') 866 866 grok.require('waeup.editCustomerDocuments') 867 867 label = _('Add document') … … 874 874 doctypes = getUtility(ICustomersUtils).SELECTABLE_DOCTYPES_DICT 875 875 return sorted(doctypes.items()) 876 877 @property 878 def edit_documents_allowed(self): 879 right_customer_state = self.context.customer.state in getUtility( 880 ICustomersUtils).DOCMANAGE_CUSTOMER_STATES 881 if isCustomer(self.request.principal) and not right_customer_state: 882 return False 883 return True 884 885 def update(self): 886 if not self.edit_documents_allowed: 887 emit_lock_message(self) 888 return 889 return super(DocumentAddFormPage, self).update() 876 890 877 891 @action(_('Add document'), style='primary') … … 889 903 self.context.writeLogMessage( 890 904 self,'added: %s %s' % (doctype, document.document_id)) 891 self.redirect(self.url(self.context)) 905 isCustomer = getattr( 906 self.request.principal, 'user_type', None) == 'customer' 907 if isCustomer: 908 self.redirect(self.url(document, 'edit') + '#tab2') 909 else: 910 self.redirect(self.url(document, 'manage') + '#tab2') 892 911 return 893 912 … … 1207 1226 1208 1227 1209 class ContractAdd Page(IkobaAddFormPage):1228 class ContractAddFormPage(IkobaAddFormPage): 1210 1229 """ Page to add an contract 1211 1230 … … 1234 1253 emit_lock_message(self) 1235 1254 return 1236 return super(ContractAdd Page, self).update()1255 return super(ContractAddFormPage, self).update() 1237 1256 1238 1257 @property -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py
r12352 r12356 65 65 """This is a customer document baseclass. 66 66 """ 67 grok.implements(ICustomerDocument, ICustomerNavigation)68 grok.provides(ICustomerDocument)69 67 grok.baseclass() 70 68 … … 189 187 """This is a sample customer document. 190 188 """ 189 190 grok.implements(ICustomerDocument, ICustomerNavigation) 191 grok.provides(ICustomerDocument) 191 192 192 193 # Ikoba can store any number of files per Document object. -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12353 r12356 931 931 self.browser.getLink("Documents").click() 932 932 self.browser.getControl("Add document").click() 933 self.assertTrue('The requested form is locked' in self.browser.contents) 934 # Customer is in wrong state 935 IWorkflowState(self.customer).setState(APPROVED) 936 self.browser.getControl("Add document").click() 933 937 self.browser.getControl(name="doctype").value = ['CustomerSampleDocument'] 934 938 self.browser.getControl(name="form.title").value = 'My Sample Document' … … 937 941 docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0] 938 942 document = self.customer['documents'][docid] 939 940 # Document can be edited ...941 self.browser.getLink(docid[:6]).click()942 self.browser.open(self.documents_path + '/' + docid + '/edit')943 #self.browser.getLink("Edit").click()944 self.assertTrue('The requested form is locked' in self.browser.contents)945 # Customer is in wrong state946 IWorkflowState(self.customer).setState(APPROVED)947 self.browser.open(self.documents_path + '/' + docid + '/edit')948 943 self.browser.getControl(name="form.title").value = 'My second doc' 949 944 self.browser.getControl("Save").click() … … 953 948 self.assertEqual( 954 949 self.browser.url, self.documents_path + '/%s/index' % docid) 955 # C ostumer can upload a document.950 # Customer can upload a document. 956 951 self.browser.getLink("Edit").click() 957 952 ctrl = self.browser.getControl(name='samplescaneditupload') … … 964 959 'href="http://localhost/app/customers/K1000000/documents/%s/sample"' 965 960 % docid in self.browser.contents) 966 # C ostumer can submit the form. The form is also saved.961 # Customer can submit the form. The form is also saved. 967 962 self.browser.getControl(name="form.title").value = 'My third doc' 968 963 self.browser.getControl("Final Submit").click() … … 1217 1212 in logcontent) 1218 1213 self.assertTrue( 1219 'INFO - zope.mgr - customers.browser.ContractAdd Page '1214 'INFO - zope.mgr - customers.browser.ContractAddFormPage ' 1220 1215 '- K1000000 - added: Sample Contract %s' 1221 1216 % contract.contract_id in logcontent)
Note: See TracChangeset for help on using the changeset viewer.