Changeset 12018 for main/waeup.ikoba/trunk/src/waeup
- Timestamp:
- 21 Nov 2014, 08:07:15 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12016 r12018 43 43 from waeup.ikoba.browser.interfaces import ICaptchaManager 44 44 from waeup.ikoba.mandates.mandate import PasswordMandate 45 from waeup.ikoba.documents.workflow import VERIFIED, REJECTED, OUTDATED 45 46 from waeup.ikoba.utils.helpers import get_current_principal, to_timezone, now 46 47 from waeup.ikoba.customers.interfaces import ( … … 577 578 578 579 def update(self): 579 PWCHANGE_STATES = getUtility(ICustomersUtils).PWCHANGE_STATES580 if self.context.customer.state not in PWCHANGE_STATES:580 CUSTMANAGE_STATES = getUtility(ICustomersUtils).CUSTMANAGE_STATES 581 if self.context.customer.state not in CUSTMANAGE_STATES: 581 582 emit_lock_message(self) 582 583 return … … 756 757 pnav = 4 757 758 759 #@property 760 #def label(self): 761 # return _('${a}: Document ${b}', mapping = { 762 # 'a':self.context.customer.display_fullname, 763 # 'b':self.context.document_id}) 764 758 765 @property 759 766 def label(self): 760 return _('${a}: Document ${b}', mapping = { 761 'a':self.context.customer.display_fullname, 762 'b':self.context.document_id}) 763 return self.context.document_id 767 return _('${a}', mapping = {'a':self.context.title}) 764 768 765 769 … … 770 774 grok.name('manage') 771 775 grok.require('waeup.manageCustomer') 776 grok.template('documenteditpage') 772 777 form_fields = grok.AutoFields(ICustomerDocument) 773 778 pnav = 4 774 779 780 #@property 781 #def label(self): 782 # return _('${a}: Document ${b}', mapping = { 783 # 'a':self.context.customer.display_fullname, 784 # 'b':self.context.document_id}) 785 775 786 @property 776 787 def label(self): 777 return _('${a}: Document ${b}', mapping = { 778 'a':self.context.customer.display_fullname, 779 'b':self.context.document_id}) 780 return self.context.document_id 788 return _('${a}', mapping = {'a':self.context.title}) 781 789 782 790 @action(_('Save'), style='primary') … … 784 792 msave(self, **data) 785 793 return 794 795 class DocumentEditFormPage(DocumentManageFormPage): 796 """ Page to edit a document 797 """ 798 grok.context(ICustomerDocument) 799 grok.name('edit') 800 grok.require('waeup.handleCustomer') 801 form_fields = grok.AutoFields(ICustomerDocument) 802 pnav = 4 803 804 def update(self): 805 if not self.context.is_editable: 806 emit_lock_message(self) 807 return 808 return super(DocumentEditFormPage, self).update() -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py
r12015 r12018 20 20 """ 21 21 import grok 22 from zope.component import queryUtility, getUtility 22 23 from zope.component.interfaces import IFactory 23 24 from zope.interface import implementedBy 24 25 from waeup.ikoba.interfaces import MessageFactory as _ 25 26 from waeup.ikoba.customers.interfaces import ( 26 ICustomerDocumentsContainer, ICustomerNavigation, ICustomerDocument) 27 ICustomerDocumentsContainer, ICustomerNavigation, ICustomerDocument, 28 ICustomersUtils) 27 29 from waeup.ikoba.documents import DocumentsContainer, Document 30 from waeup.ikoba.documents.interfaces import IDocumentsUtils 28 31 from waeup.ikoba.utils.helpers import attrs_to_fields 29 32 … … 67 70 return self.__parent__.__parent__.writeLogMessage(view, message) 68 71 72 @property 73 def is_editable(self): 74 try: 75 # Customer must be approved 76 cond1 = self.customer.state in getUtility( 77 ICustomersUtils).DOCMANAGE_STATES 78 # Document must be in state created 79 cond2 = self.state in getUtility( 80 IDocumentsUtils).DOCMANAGE_STATES 81 if not (cond1 and cond2): 82 return False 83 except AttributeError: 84 pass 85 return True 86 69 87 CustomerDocument = attrs_to_fields(CustomerDocument) 70 88 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/export.py
r12007 r12018 145 145 fields = tuple( 146 146 sorted(iface_names( 147 ICustomerDocument, exclude_attribs=False))) + ( 147 ICustomerDocument, 148 exclude_attribs=False, 149 omit=['is_editable']))) + ( 148 150 'customer_id',) 149 151 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r11997 r12018 1 ## $Id : interfaces.py 11589 2014-04-22 07:13:16Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 241 241 """ 242 242 243 is_editable = Attribute('Document editable by customer') -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12016 r12018 107 107 # Set password 108 108 IUserAccount( 109 self.app['customers'][self.customer_id]).setPassword(' spwd')109 self.app['customers'][self.customer_id]).setPassword('cpwd') 110 110 111 111 self.login_path = 'http://localhost/app/login' … … 484 484 self.browser.open(self.login_path) 485 485 self.browser.getControl(name="form.login").value = self.customer_id 486 self.browser.getControl(name="form.password").value = ' spwd'486 self.browser.getControl(name="form.password").value = 'cpwd' 487 487 self.browser.getControl("Login").click() 488 488 self.assertMatches( … … 511 511 self.browser.open(self.login_path) 512 512 self.browser.getControl(name="form.login").value = self.customer_id 513 self.browser.getControl(name="form.password").value = ' spwd'513 self.browser.getControl(name="form.password").value = 'cpwd' 514 514 self.browser.getControl("Login").click() 515 515 self.assertEqual(self.browser.url, self.customer_path) … … 554 554 self.browser.open(self.login_path) 555 555 self.browser.getControl(name="form.login").value = self.customer_id 556 self.browser.getControl(name="form.password").value = ' spwd'556 self.browser.getControl(name="form.password").value = 'cpwd' 557 557 self.browser.getControl("Login").click() 558 558 self.assertMatches( … … 575 575 self.browser.open(self.login_path) 576 576 self.browser.getControl(name="form.login").value = self.customer_id 577 self.browser.getControl(name="form.password").value = ' spwd'577 self.browser.getControl(name="form.password").value = 'cpwd' 578 578 self.browser.getControl("Login").click() 579 579 self.assertEqual(self.browser.url, self.customer_path) … … 594 594 self.browser.open(self.login_path) 595 595 self.browser.getControl(name="form.login").value = self.customer_id 596 self.browser.getControl(name="form.password").value = ' spwd'596 self.browser.getControl(name="form.password").value = 'cpwd' 597 597 self.browser.getControl("Login").click() 598 598 self.assertTrue( … … 600 600 # We set the password again 601 601 IUserAccount( 602 self.app['customers'][self.customer_id]).setPassword(' spwd')602 self.app['customers'][self.customer_id]).setPassword('cpwd') 603 603 # Customers can't login if their account is suspended/deactivated 604 604 self.customer.suspended = True 605 605 self.browser.open(self.login_path) 606 606 self.browser.getControl(name="form.login").value = self.customer_id 607 self.browser.getControl(name="form.password").value = ' spwd'607 self.browser.getControl(name="form.password").value = 'cpwd' 608 608 self.browser.getControl("Login").click() 609 609 self.assertMatches( … … 613 613 self.customer.suspended_comment = u'Aetsch baetsch!' 614 614 self.browser.getControl(name="form.login").value = self.customer_id 615 self.browser.getControl(name="form.password").value = ' spwd'615 self.browser.getControl(name="form.password").value = 'cpwd' 616 616 self.browser.getControl("Login").click() 617 617 self.assertMatches( … … 622 622 # is not expired 623 623 self.app['customers'][self.customer_id].setTempPassword( 624 'anybody', 'temp_ spwd')625 self.browser.open(self.login_path) 626 self.browser.getControl(name="form.login").value = self.customer_id 627 self.browser.getControl(name="form.password").value = ' spwd'624 'anybody', 'temp_cpwd') 625 self.browser.open(self.login_path) 626 self.browser.getControl(name="form.login").value = self.customer_id 627 self.browser.getControl(name="form.password").value = 'cpwd' 628 628 self.browser.getControl("Login").click() 629 629 self.assertMatches( … … 633 633 self.browser.open(self.login_path) 634 634 self.browser.getControl(name="form.login").value = self.customer_id 635 self.browser.getControl(name="form.password").value = 'temp_ spwd'635 self.browser.getControl(name="form.password").value = 'temp_cpwd' 636 636 self.browser.getControl("Login").click() 637 637 self.assertMatches( … … 652 652 self.browser.open(self.login_path) 653 653 self.browser.getControl(name="form.login").value = self.customer_id 654 self.browser.getControl(name="form.password").value = ' spwd'654 self.browser.getControl(name="form.password").value = 'cpwd' 655 655 self.browser.getControl("Login").click() 656 656 self.assertMatches( … … 825 825 '- K1000000 - removed: %s' 826 826 % document.document_id in logcontent) 827 828 def test_edit_document(self): 829 # Customers can manage documents under certain conditions 830 self.browser.open(self.login_path) 831 self.browser.getControl(name="form.login").value = self.customer_id 832 self.browser.getControl(name="form.password").value = 'cpwd' 833 self.browser.getControl("Login").click() 834 self.assertMatches( 835 '...You logged in...', self.browser.contents) 836 self.browser.getLink("Documents").click() 837 self.browser.getLink("Add document").click() 838 self.browser.getControl(name="doctype").value = ['generic'] 839 self.browser.getControl("Create document").click() 840 self.assertTrue('Generic Document created.' in self.browser.contents) 841 document = self.customer['documents']['d102'] 842 843 # Document can be edited ... 844 self.browser.getLink("d102").click() 845 846 847 self.browser.open(self.documents_path + '/d102/edit') 848 #self.browser.getLink("Edit").click() 849 self.assertTrue('The requested form is locked' in self.browser.contents) 850 851 852 853 854 855 856 857 self.browser.getControl(name="form.title").value = 'My second doc' 858 self.browser.getControl("Save").click() 859 self.assertTrue('Form has been saved.' in self.browser.contents) 860 self.browser.getLink("View").click() 861 self.assertEqual(self.browser.url, self.documents_path + '/d102/index') -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py
r11997 r12018 1 ## $Id : utils.py 11875 2014-10-24 12:47:13Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 19 19 """ 20 20 import grok 21 from waeup.ikoba.interfaces import STARTED 21 from waeup.ikoba.interfaces import STARTED, APPROVED 22 22 from waeup.ikoba.customers.interfaces import ICustomersUtils 23 23 … … 38 38 CUSTOMER_ID_PREFIX = u'K' 39 39 40 PWCHANGE_STATES = (STARTED,) 40 CUSTMANAGE_STATES = (STARTED,) 41 42 DOCMANAGE_STATES = (APPROVED,) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py
r12016 r12018 307 307 target = 'manage' 308 308 309 310 class DocumentEditActionButton(ManageActionButton): 311 grok.order(1) 312 grok.context(ICustomerDocument) 313 grok.view(DocumentDisplayFormPage) 314 grok.require('waeup.handleCustomer') 315 text = _('Edit') 316 target = 'edit' 317 318 @property 319 def target_url(self): 320 if not self.context.is_editable: 321 return '' 322 return self.view.url(self.view.context, self.target) 323 324 309 325 class DocumentViewActionButton(ManageActionButton): 310 326 grok.order(1) 311 327 grok.context(ICustomerDocument) 312 328 grok.view(DocumentManageFormPage) 313 grok.require('waeup. manageCustomer')329 grok.require('waeup.handleCustomer') 314 330 text = _('View') 315 331 target = 'index' -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py
r12017 r12018 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 from zope.interface import Attribute 18 from zope.interface import Attribute, Interface 19 19 from zope import schema 20 20 from waeup.ikoba.interfaces import ( … … 52 52 ) 53 53 54 class IDocumentsUtils(Interface): 55 """A collection of methods which are subject to customization. 54 56 57 """ 58 -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/utils.py
r12005 r12018 19 19 """ 20 20 import grok 21 from waeup.ikoba.documents.workflow import CREATED 22 from waeup.ikoba.documents.interfaces import IDocumentsUtils 21 23 22 24 … … 24 26 new_id = grok.getSite().unique_document_id 25 27 return new_id 28 29 30 class DocumentssUtils(grok.GlobalUtility): 31 """A collection of methods subject to customization. 32 """ 33 grok.implements(IDocumentsUtils) 34 35 DOCMANAGE_STATES = (CREATED,)
Note: See TracChangeset for help on using the changeset viewer.