Ignore:
Timestamp:
30 Nov 2014, 20:49:22 (10 years ago)
Author:
Henrik Bettermann
Message:

The term 'application' should really not be used in Python-based portal software.

Replace 'application' by 'contract': batch 1

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  
    7676
    7777    @property
    78     def unique_application_id(self):
    79         """A unique application id for all application objects in customers.
     78    def unique_contract_id(self):
     79        """A unique contract id for all contract objects in customers.
    8080
    81         The application id returned is guaranteed to be unique.
     81        The contract id returned is guaranteed to be unique.
    8282
    83         Once a application id was issued, it won't be issued again.
     83        Once a contract id was issued, it won't be issued again.
    8484
    85         Obtaining an application id is currently not thread-safe but can be
     85        Obtaining an contract id is currently not thread-safe but can be
    8686        made easily by enabling commented lines.
    8787        """
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py

    r12094 r12097  
    4343from waeup.ikoba.customers.interfaces import (
    4444    ICustomer, ICustomerUpdateByRegNo,
    45     ICustomerDocument, IApplication)
     45    ICustomerDocument, IContract)
    4646from waeup.ikoba.customers.workflow import  (
    4747    IMPORTABLE_REGISTRATION_STATES, IMPORTABLE_REGISTRATION_TRANSITIONS,
    48     IMPORTABLE_APPLICATION_STATES, IMPORTABLE_APPLICATION_TRANSITIONS)
     48    IMPORTABLE_CONTRACT_STATES, IMPORTABLE_CONTRACT_TRANSITIONS)
    4949from waeup.ikoba.utils.batching import BatchProcessor
    5050
     
    463463
    464464
    465 class ApplicationProcessor(CustomerProcessorBase):
    466     """A batch processor for IApplication objects.
     465class ContractProcessor(CustomerProcessorBase):
     466    """A batch processor for IContract objects.
    467467    """
    468468    grok.implements(IBatchProcessor)
    469469    grok.provides(IBatchProcessor)
    470470    grok.context(Interface)
    471     util_name = 'applicationprocessor'
     471    util_name = 'contractprocessor'
    472472    grok.name(util_name)
    473473
    474     name = _('Application Processor')
    475     iface = IApplication
    476     factory_name = 'waeup.SampleApplication'
     474    name = _('Contract Processor')
     475    iface = IContract
     476    factory_name = 'waeup.SampleContract'
    477477
    478478    location_fields = []
    479     additional_fields = ['application_id', 'class_name']
     479    additional_fields = ['contract_id', 'class_name']
    480480    additional_headers = ['class_name']
    481481
    482482    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!")
    487487        return True
    488488
     
    491491        if customer is None:
    492492            return None
    493         return customer['applications']
     493        return customer['contracts']
    494494
    495495    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)
    503503        return entry
    504504
     
    506506        """Update obj to the values given in row.
    507507        """
    508         items_changed = super(ApplicationProcessor, self).updateEntry(
     508        items_changed = super(ContractProcessor, self).updateEntry(
    509509            obj, row, site, filename)
    510510        customer = self.getParent(row, site).__parent__
     
    516516    def addEntry(self, obj, row, site):
    517517        parent = self.getParent(row, site)
    518         application_id = row['application_id'].strip('#')
    519         parent[application_id] = obj
     518        contract_id = row['contract_id'].strip('#')
     519        parent[contract_id] = obj
    520520        return
    521521
    522522    def delEntry(self, row, site):
    523         application = self.getEntry(row, site)
     523        contract = self.getEntry(row, site)
    524524        parent = self.getParent(row, site)
    525         if application is not None:
     525        if contract is not None:
    526526            customer = self._getCustomer(row, site)
    527             customer.__parent__.logger.info('%s - Application removed: %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]
    530530        return
    531531
     
    534534        """
    535535        errs, inv_errs, conv_dict = super(
    536             ApplicationProcessor, self).checkConversion(row, mode=mode)
     536            ContractProcessor, self).checkConversion(row, mode=mode)
    537537        # We need to check if the class_name corresponds with the
    538538        # processor chosen. This is to avoid accidentally wrong imports.
     
    541541            if class_name != self.factory_name.strip('waeup.'):
    542542                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)
    545545        if mode == 'create':
    546             if not application_id:
    547                 application_id = generate_application_id()
    548                 conv_dict['application_id'] = application_id
     546            if not contract_id:
     547                contract_id = generate_contract_id()
     548                conv_dict['contract_id'] = contract_id
    549549                return errs, inv_errs, conv_dict
    550             cat = queryUtility(ICatalog, name='applications_catalog')
     550            cat = queryUtility(ICatalog, name='contracts_catalog')
    551551            results = list(
    552                 cat.searchResults(application_id=(application_id, application_id)))
     552                cat.searchResults(contract_id=(contract_id, contract_id)))
    553553            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'))
    556556        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'))
    559559        return errs, inv_errs, conv_dict
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py

    r12096 r12097  
    5151    ICustomer, ICustomersContainer, ICustomerRequestPW, ICustomersUtils,
    5252    ICustomerDocument, ICustomerDocumentsContainer, ICustomerCreate,
    53     ICustomerPDFDocument, IApplicationsContainer, IApplication, IApplicationEdit
     53    ICustomerPDFDocument, IContractsContainer, IContract, IContractEdit
    5454    )
    5555from waeup.ikoba.customers.catalog import search
     
    10291029            omit_fields=self.omit_fields)
    10301030
    1031 # Pages for customer applications
    1032 
    1033 class ApplicationsBreadcrumb(Breadcrumb):
    1034     """A breadcrumb for the applications container.
    1035     """
    1036     grok.context(IApplicationsContainer)
    1037     title = _('Applications')
    1038 
    1039 
    1040 class ApplicationBreadcrumb(Breadcrumb):
     1031# Pages for customer contracts
     1032
     1033class ContractsBreadcrumb(Breadcrumb):
     1034    """A breadcrumb for the contracts container.
     1035    """
     1036    grok.context(IContractsContainer)
     1037    title = _('Contracts')
     1038
     1039
     1040class ContractBreadcrumb(Breadcrumb):
    10411041    """A breadcrumb for the customer container.
    10421042    """
    1043     grok.context(IApplication)
     1043    grok.context(IContract)
    10441044
    10451045    @property
    10461046    def title(self):
    1047         return self.context.application_id
    1048 
    1049 
    1050 class ApplicationsManageFormPage(IkobaEditFormPage):
    1051     """ Page to manage the customer applications
     1047        return self.context.contract_id
     1048
     1049
     1050class ContractsManageFormPage(IkobaEditFormPage):
     1051    """ Page to manage the customer contracts
    10521052
    10531053    This manage form page is for both customers and officers.
    10541054    """
    1055     grok.context(IApplicationsContainer)
     1055    grok.context(IContractsContainer)
    10561056    grok.name('index')
    10571057    grok.require('waeup.viewCustomer')
    1058     form_fields = grok.AutoFields(IApplicationsContainer)
    1059     grok.template('applicationsmanagepage')
    1060     pnav = 4
    1061 
    1062     @property
    1063     def manage_applications_allowed(self):
    1064         return checkPermission('waeup.editApplications', 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):
    10671067        usertype = getattr(self.request.principal, 'user_type', None)
    10681068        if not usertype:
    10691069            return False
    1070         if not self.manage_applications_allowed:
     1070        if not self.manage_contracts_allowed:
    10711071            return True
    10721072        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',
    10781078            mapping = {'a':self.context.__parent__.display_fullname})
    10791079
    1080     @jsaction(_('Remove selected applications'))
    1081     def delApplication(self, **data):
     1080    @jsaction(_('Remove selected contracts'))
     1081    def delContract(self, **data):
    10821082        form = self.request.form
    10831083        if 'val_id' in form:
    10841084            child_id = form['val_id']
    10851085        else:
    1086             self.flash(_('No application selected.'), type="warning")
     1086            self.flash(_('No contract selected.'), type="warning")
    10871087            self.redirect(self.url(self.context))
    10881088            return
     
    10911091        deleted = []
    10921092        for id in child_id:
    1093             # Customers are not allowed to remove used applications
    1094             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):
    10961096                del self.context[id]
    10971097                deleted.append(id)
     
    11051105
    11061106
    1107 class ApplicationAddFormPage(IkobaAddFormPage):
    1108     """ Page to add an application
    1109     """
    1110     grok.context(IApplicationsContainer)
     1107class ContractAddFormPage(IkobaAddFormPage):
     1108    """ Page to add an contract
     1109    """
     1110    grok.context(IContractsContainer)
    11111111    grok.name('addapp')
    1112     grok.template('applicationaddform')
    1113     grok.require('waeup.editApplications')
    1114     form_fields = grok.AutoFields(IApplication)
    1115     label = _('Add application')
     1112    grok.template('contractaddform')
     1113    grok.require('waeup.editContracts')
     1114    form_fields = grok.AutoFields(IContract)
     1115    label = _('Add contract')
    11161116    pnav = 4
    11171117
     
    11211121        return sorted(apptypes.items())
    11221122
    1123     @action(_('Create application'), style='primary')
    1124     def createApplication(self, **data):
     1123    @action(_('Create contract'), style='primary')
     1124    def createContract(self, **data):
    11251125        form = self.request.form
    11261126        customer = self.context.__parent__
    11271127        apptype = form.get('apptype', None)
    1128         # Here we can create various instances of Application derived
     1128        # Here we can create various instances of Contract derived
    11291129        # classes depending on the apptype parameter given in form.
    1130         application = createObject('waeup.%s' % apptype)
    1131         self.context.addApplication(application)
     1130        contract = createObject('waeup.%s' % apptype)
     1131        self.context.addContract(contract)
    11321132        apptype = getUtility(ICustomersUtils).SELECTABLE_APPTYPES_DICT[apptype]
    11331133        self.flash(_('${a} created.',
    11341134            mapping = {'a': apptype}))
    11351135        self.context.writeLogMessage(
    1136             self,'added: %s %s' % (apptype, application.application_id))
     1136            self,'added: %s %s' % (apptype, contract.contract_id))
    11371137        self.redirect(self.url(self.context))
    11381138        return
     
    11431143
    11441144
    1145 class ApplicationDisplayFormPage(IkobaDisplayFormPage):
    1146     """ Page to view a application
    1147     """
    1148     grok.context(IApplication)
     1145class ContractDisplayFormPage(IkobaDisplayFormPage):
     1146    """ Page to view a contract
     1147    """
     1148    grok.context(IContract)
    11491149    grok.name('index')
    11501150    grok.require('waeup.viewCustomer')
    1151     grok.template('applicationpage')
    1152     form_fields = grok.AutoFields(IApplication).omit('last_transition_date')
     1151    grok.template('contractpage')
     1152    form_fields = grok.AutoFields(IContract).omit('last_transition_date')
    11531153    pnav = 4
    11541154
     
    11581158
    11591159
    1160 class ApplicationManageFormPage(IkobaEditFormPage):
    1161     """ Page to edit a application
    1162     """
    1163     grok.context(IApplication)
     1160class ContractManageFormPage(IkobaEditFormPage):
     1161    """ Page to edit a contract
     1162    """
     1163    grok.context(IContract)
    11641164    grok.name('manage')
    11651165    grok.require('waeup.manageCustomer')
    1166     grok.template('applicationeditpage')
    1167     form_fields = grok.AutoFields(IApplication).omit('last_transition_date')
     1166    grok.template('contracteditpage')
     1167    form_fields = grok.AutoFields(IContract).omit('last_transition_date')
    11681168    pnav = 4
    11691169    deletion_warning = _('Are you sure?')
     
    11791179
    11801180
    1181 class ApplicationEditFormPage(ApplicationManageFormPage):
    1182     """ Page to edit a application
     1181class ContractEditFormPage(ContractManageFormPage):
     1182    """ Page to edit a contract
    11831183    """
    11841184    grok.name('edit')
    11851185    grok.require('waeup.handleCustomer')
    1186     form_fields = grok.AutoFields(IApplicationEdit).omit('last_transition_date')
     1186    form_fields = grok.AutoFields(IContractEdit).omit('last_transition_date')
    11871187
    11881188    def update(self):
     
    11901190            emit_lock_message(self)
    11911191            return
    1192         return super(ApplicationEditFormPage, self).update()
     1192        return super(ContractEditFormPage, self).update()
    11931193
    11941194    @action(_('Save'), style='primary')
     
    12061206
    12071207
    1208 class ApplicationTriggerTransitionFormPage(IkobaEditFormPage):
    1209     """ View to trigger customer application transitions
    1210     """
    1211     grok.context(IApplication)
     1208class ContractTriggerTransitionFormPage(IkobaEditFormPage):
     1209    """ View to trigger customer contract transitions
     1210    """
     1211    grok.context(IContract)
    12121212    grok.name('trigtrans')
    12131213    grok.require('waeup.triggerTransition')
    12141214    grok.template('trigtrans')
    1215     label = _('Trigger application transition')
     1215    label = _('Trigger contract transition')
    12161216    pnav = 4
    12171217
     
    12401240        return
    12411241
    1242 class PDFApplicationsOverviewPage(UtilityView, grok.View):
     1242class PDFContractsOverviewPage(UtilityView, grok.View):
    12431243    """Deliver an overview slip.
    12441244    """
    1245     grok.context(IApplicationsContainer)
    1246     grok.name('applications_overview_slip.pdf')
     1245    grok.context(IContractsContainer)
     1246    grok.name('contracts_overview_slip.pdf')
    12471247    grok.require('waeup.viewCustomer')
    12481248    prefix = 'form'
     
    12561256    def label(self):
    12571257        portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
    1258         return translate(_('Applications of'),
     1258        return translate(_('Contracts of'),
    12591259            'waeup.ikoba', target_language=portal_language) \
    12601260            + ' %s' % self.context.customer.display_fullname
     
    12641264        portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
    12651265        tabletitle = []
    1266         tabletitle.append(translate(_('Customer Applications'), 'waeup.ikoba',
     1266        tabletitle.append(translate(_('Customer Contracts'), 'waeup.ikoba',
    12671267            target_language=portal_language))
    12681268        return tabletitle
     
    12811281            tabledata.append(sorted(
    12821282                [value for value in self.context.values()]))
    1283             tableheader.append([(Id, 'application_id', 2),
     1283            tableheader.append([(Id, 'contract_id', 2),
    12841284                             (Title, 'title', 6),
    12851285                             (Type, 'translated_class_name', 6),
     
    12981298
    12991299
    1300 class PDFApplicationSlipPage(UtilityView, grok.View):
     1300class PDFContractSlipPage(UtilityView, grok.View):
    13011301    """Deliver pdf file including metadata.
    13021302    """
    1303     grok.context(IApplication)
    1304     grok.name('application_slip.pdf')
     1303    grok.context(IContract)
     1304    grok.name('contract_slip.pdf')
    13051305    grok.require('waeup.viewCustomer')
    13061306    prefix = 'form'
     
    13091309                   'suspended_comment',)
    13101310
    1311     #form_fields = grok.AutoFields(ICustomerPDFApplication).omit(
     1311    #form_fields = grok.AutoFields(ICustomerPDFContract).omit(
    13121312    #    'last_transition_date')
    13131313    form_fields =()
     
    13271327        customers_utils = getUtility(ICustomersUtils)
    13281328        return customers_utils.renderPDF(
    1329             self, 'application_slip.pdf',
     1329            self, 'contract_slip.pdf',
    13301330            self.context.customer, customerview,
    13311331            omit_fields=self.omit_fields)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractaddform.pt

    r12096 r12097  
    55      <tr>
    66        <td class="fieldname">
    7           <span i18n:translate="">Application Type</span>:
     7          <span i18n:translate="">Contract Type</span>:
    88        </td>
    99        <td>
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractpage.pt

    r12096 r12097  
    11<div class="wfstatus-sub"  i18n:domain="waeup.ikoba">
    2   Application State: <span tal:replace="context/translated_state">
    3     APPLICATIONSTATE</span>
     2  Contract State: <span tal:replace="context/translated_state">
     3    CONTRACTSTATE</span>
    44</div>
    55
     
    1414    <tr>
    1515      <td i18n:translate="" class="fieldname">
    16         Application Type:
     16        Contract Type:
    1717      </td>
    1818      <td>
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractsmanagepage.pt

    r12096 r12097  
    2323        <td>
    2424          <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>
    2626        </td>
    2727        <td>
     
    4343  </table>
    4444
    45   <div tal:condition="python: view.availableActions and view.manage_applications_allowed">
     45  <div tal:condition="python: view.availableActions and view.manage_contracts_allowed">
    4646    <span tal:repeat="action view/actions"
    4747          tal:omit-tag="">
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/catalog.py

    r12094 r12097  
    2727from waeup.ikoba.interfaces import (
    2828    ICompany, IQueryResultItem)
    29 from waeup.ikoba.customers.interfaces import ICustomer, IApplication
     29from waeup.ikoba.customers.interfaces import ICustomer, IContract
    3030
    3131
     
    119119
    120120
    121 # Catalog for customer applications
     121# Catalog for customer contracts
    122122
    123 class ApplicationIndexes(grok.Indexes):
    124     """A catalog for all applications.
     123class ContractIndexes(grok.Indexes):
     124    """A catalog for all contracts.
    125125    """
    126126    grok.site(ICompany)
    127     grok.name('applications_catalog')
    128     grok.context(IApplication)
     127    grok.name('contracts_catalog')
     128    grok.context(IContract)
    129129
    130     application_id = grok.index.Field(attribute='application_id')
     130    contract_id = grok.index.Field(attribute='contract_id')
    131131    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  
    1717##
    1818"""
    19 Customer application components.
     19Customer contract components.
    2020"""
    2121import os
     
    2828from waeup.ikoba.interfaces import IIkobaUtils, IObjectHistory
    2929from waeup.ikoba.customers.interfaces import (
    30     IApplicationsContainer, ICustomerNavigation,
    31     IApplication, IApplicationEdit, ICustomersUtils,
     30    IContractsContainer, ICustomerNavigation,
     31    IContract, IContractEdit, ICustomersUtils,
    3232    )
    33 from waeup.ikoba.customers.utils import generate_application_id
     33from waeup.ikoba.customers.utils import generate_contract_id
    3434from waeup.ikoba.utils.helpers import attrs_to_fields
    3535
    36 class ApplicationsContainer(grok.Container):
    37     """This is a container for customer applications.
     36class ContractsContainer(grok.Container):
     37    """This is a container for customer contracts.
    3838    """
    39     grok.implements(IApplicationsContainer, ICustomerNavigation)
    40     grok.provides(IApplicationsContainer)
     39    grok.implements(IContractsContainer, ICustomerNavigation)
     40    grok.provides(IContractsContainer)
    4141
    42     def addApplication(self, application):
    43         if not IApplication.providedBy(application):
     42    def addContract(self, contract):
     43        if not IContract.providedBy(contract):
    4444            raise TypeError(
    45                 'ApplicationsContainers contain only IApplication instances')
    46         self[application.application_id] = application
     45                'ContractsContainers contain only IContract instances')
     46        self[contract.contract_id] = contract
    4747        return
    4848
     
    5454        return self.__parent__.writeLogMessage(view, message)
    5555
    56 ApplicationsContainer = attrs_to_fields(ApplicationsContainer)
     56ContractsContainer = attrs_to_fields(ContractsContainer)
    5757
    58 class ApplicationBase(grok.Container):
    59     """This is a customer application baseclass.
     58class ContractBase(grok.Container):
     59    """This is a customer contract baseclass.
    6060    """
    61     grok.implements(IApplication, IApplicationEdit, ICustomerNavigation)
    62     grok.provides(IApplication)
     61    grok.implements(IContract, IContractEdit, ICustomerNavigation)
     62    grok.provides(IContract)
    6363    grok.baseclass()
    6464
    65     application_category = None
     65    contract_category = None
    6666
    6767    def __init__(self):
    68         super(ApplicationBase, self).__init__()
     68        super(ContractBase, self).__init__()
    6969        # The site doesn't exist in unit tests
    7070        try:
    71             self.application_id = generate_application_id()
     71            self.contract_id = generate_contract_id()
    7272        except AttributeError:
    73             self.application_id = u'a123'
     73            self.contract_id = u'a123'
    7474        self.last_product_id = None
    7575        return
     
    8888        try:
    8989            TRANSLATED_STATES = getUtility(
    90                 ICustomersUtils).TRANSLATED_APPLICATION_STATES
     90                ICustomersUtils).TRANSLATED_CONTRACT_STATES
    9191            return TRANSLATED_STATES[self.state]
    9292        except KeyError:
     
    120120            cond1 = self.customer.state in getUtility(
    121121                ICustomersUtils).APPMANAGE_CUSTOMER_STATES
    122             # Application must be in state created
     122            # Contract must be in state created
    123123            cond2 = self.state in getUtility(
    124                 ICustomersUtils).APPMANAGE_APPLICATION_STATES
     124                ICustomersUtils).APPMANAGE_CONTRACT_STATES
    125125            if not (cond1 and cond2):
    126126                return False
     
    138138
    139139
    140 class SampleApplication(ApplicationBase):
    141     """This is a sample application.
     140class SampleContract(ContractBase):
     141    """This is a sample contract.
    142142    """
    143143
    144     application_category = 'sample'
     144    contract_category = 'sample'
    145145
    146 SampleApplication = attrs_to_fields(SampleApplication)
     146SampleContract = attrs_to_fields(SampleContract)
    147147
    148148
    149 # Applications must be importable. So we might need a factory.
    150 class SampleApplicationFactory(grok.GlobalUtility):
    151     """A factory for applications.
     149# Contracts must be importable. So we might need a factory.
     150class SampleContractFactory(grok.GlobalUtility):
     151    """A factory for contracts.
    152152    """
    153153    grok.implements(IFactory)
    154     grok.name(u'waeup.SampleApplication')
    155     title = u"Create a new application.",
    156     description = u"This factory instantiates new sample application instances."
     154    grok.name(u'waeup.SampleContract')
     155    title = u"Create a new contract.",
     156    description = u"This factory instantiates new sample contract instances."
    157157
    158158    def __call__(self, *args, **kw):
    159         return SampleApplication(*args, **kw)
     159        return SampleContract(*args, **kw)
    160160
    161161    def getInterfaces(self):
    162         return implementedBy(SampleApplication)
     162        return implementedBy(SampleContract)
    163163
    164 @grok.subscribe(IApplication, grok.IObjectAddedEvent)
    165 def handle_application_added(application, event):
    166     """If an application is added the transition create is fired.
     164@grok.subscribe(IContract, grok.IObjectAddedEvent)
     165def handle_contract_added(contract, event):
     166    """If an contract is added the transition create is fired.
    167167    The latter produces a logging message.
    168168    """
    169     if IWorkflowState(application).getState() is None:
    170         IWorkflowInfo(application).fireTransition('create')
     169    if IWorkflowState(contract).getState() is None:
     170        IWorkflowInfo(contract).fireTransition('create')
    171171    return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/customer.py

    r12090 r12097  
    4343from waeup.ikoba.customers.utils import generate_customer_id, path_from_custid
    4444from waeup.ikoba.customers.documents import CustomerDocumentsContainer
    45 from waeup.ikoba.customers.applications import ApplicationsContainer
     45from waeup.ikoba.customers.contracts import ContractsContainer
    4646from waeup.ikoba.utils.helpers import attrs_to_fields, now, copy_filesystem_tree
    4747
     
    184184    documents = CustomerDocumentsContainer()
    185185    customer['documents'] = documents
    186     applications = ApplicationsContainer()
    187     customer['applications'] = applications
     186    contracts = ContractsContainer()
     187    customer['contracts'] = contracts
    188188    return
    189189
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12095 r12097  
    2323from waeup.ikoba.interfaces import MessageFactory as _
    2424from waeup.ikoba.interfaces import (
    25     IIkobaObject, application_sessions_vocab, validate_email, ICSVExporter)
     25    IIkobaObject, validate_email, ICSVExporter)
    2626from waeup.ikoba.schema import TextLineChoice, FormattedDate, PhoneNumber
    2727from waeup.ikoba.browser.interfaces import ICustomerNavigationBase
     
    248248    """
    249249
    250 # Customer application interfaces
    251 
    252 class IApplicationsContainer(IIkobaObject):
     250# Customer contract interfaces
     251
     252class IContractsContainer(IIkobaObject):
    253253    """A container for customer aplication objects.
    254254
    255255    """
    256256
    257     def addApplication(application):
    258         """Add an application object.
    259         """
    260 
    261 
    262 class IApplication(IIkobaObject):
    263     """A customer application.
    264 
    265     """
    266     application_id = Attribute('Application Identifier')
     257    def addContract(contract):
     258        """Add an contract object.
     259        """
     260
     261
     262class IContract(IIkobaObject):
     263    """A customer contract.
     264
     265    """
     266    contract_id = Attribute('Contract Identifier')
    267267    history = Attribute('Object history, a list of messages')
    268     state = Attribute('Returns the application state')
     268    state = Attribute('Returns the contract state')
    269269    translated_state = Attribute(
    270270        'Returns a translated, more verbose appliction state')
    271     class_name = Attribute('Name of the application class')
     271    class_name = Attribute('Name of the contract class')
    272272    formatted_transition_date = Attribute(
    273273        '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')
    275275    last_product_id = Attribute(
    276         'Id of product recently stored with the application')
     276        'Id of product recently stored with the contract')
    277277
    278278    title = schema.TextLine(
    279         title = _(u'Application Title'),
     279        title = _(u'Contract Title'),
    280280        required = True,
    281281        )
     
    293293        )
    294294
    295 class IApplicationEdit(IApplication):
    296     """Interface for editing application data by customers.
     295class IContractEdit(IContract):
     296    """Interface for editing contract data by customers.
    297297
    298298    """
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/permissions.py

    r12091 r12097  
    4848
    4949
    50 class EditApplications(grok.Permission):
    51     grok.name('waeup.editApplications')
     50class EditContracts(grok.Permission):
     51    grok.name('waeup.editContracts')
    5252
    5353
     
    7474    grok.permissions('waeup.handleCustomer', 'waeup.uploadCustomerFile',
    7575                     'waeup.viewCustomer', 'waeup.editCustomerDocuments',
    76                      'waeup.editApplications')
     76                     'waeup.editContracts')
    7777
    7878
     
    9999                     'waeup.editCustomerDocuments', 'waeup.uploadCustomerFile',
    100100                     'waeup.viewCustomersTab', 'waeup.triggerTransition',
    101                      'waeup.editApplications')
     101                     'waeup.editContracts')
    102102
    103103
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12096 r12097  
    9696        self.product.product_id = u'SAM'
    9797        self.product.title = u'Our Samle Product'
    98         self.product.application_category = u'sample'
     98        self.product.contract_category = u'sample'
    9999        self.app['products'].addProduct(self.product)
    100100
     
    114114        document.title = u'My first document'
    115115        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)
    119119
    120120        # Set password
     
    131131        self.history_path = self.customer_path + '/history'
    132132        self.documents_path = self.customer_path + '/documents'
    133         self.applications_path = self.customer_path + '/applications'
     133        self.contracts_path = self.customer_path + '/contracts'
    134134
    135135        self.app['configuration'].carry_over = True
     
    10521052
    10531053
    1054 class ApplicationUITests(CustomersFullSetup):
    1055     # Tests for CustomerSampleApplication relates views and pages
    1056 
    1057     def test_manage_application(self):
    1058         # Managers can access the pages of customer applicationsconter
     1054class 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
    10591059        # and can perform actions
    10601060        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    10631063        self.assertEqual(self.browser.url, self.customer_path)
    10641064        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 = ['SampleApplication']
    1068         self.browser.getControl("Create application").click()
    1069         self.assertTrue('Sample Application created.' in self.browser.contents)
    1070         application = self.customer['applications']['a102']
    1071 
    1072         # Application can be edited
     1065        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
    10731073        self.browser.getLink("a102").click()
    10741074        self.browser.getLink("Manage").click()
     
    10781078        self.assertTrue('Form has been saved.' in self.browser.contents)
    10791079        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')
    10811081
    10821082        # Transitions can be performed
     
    10861086        self.browser.getControl(name="transition").value = ['approve']
    10871087        self.browser.getControl("Save").click()
    1088         self.assertEqual(application.state, 'approved')
    1089 
    1090         # Applications can be removed
    1091         self.browser.getLink("Applications").click()
     1088        self.assertEqual(contract.state, 'approved')
     1089
     1090        # Contracts can be removed
     1091        self.browser.getLink("Contracts").click()
    10921092        ctrl = self.browser.getControl(name='val_id')
    1093         ctrl.getControl(value=application.application_id).selected = True
     1093        ctrl.getControl(value=contract.contract_id).selected = True
    10941094        self.browser.getControl("Remove selected", index=0).click()
    10951095        self.assertTrue('Successfully removed' in self.browser.contents)
     
    11001100        logcontent = open(logfile).read()
    11011101        self.assertTrue(
    1102             'INFO - zope.mgr - customers.browser.ApplicationManageFormPage '
     1102            'INFO - zope.mgr - customers.browser.ContractManageFormPage '
    11031103            '- K1000000 - a102 - saved: title'
    11041104            in logcontent)
    11051105        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 '
    11111111            '- 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):
    11151115        # We add a second product.
    11161116        product = createObject('waeup.Product')
    11171117        product.product_id = u'LIC'
    11181118        product.title = u'Our License Product'
    1119         product.application_category = u'license'
     1119        product.contract_category = u'license'
    11201120        self.app['products'].addProduct(product)
    1121         # Customers can manage applications under certain conditions
     1121        # Customers can manage contracts under certain conditions
    11221122        self.browser.open(self.login_path)
    11231123        self.browser.getControl(name="form.login").value = self.customer_id
     
    11261126        self.assertMatches(
    11271127            '...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 = ['SampleApplication']
    1131         self.browser.getControl("Create application").click()
    1132         self.assertTrue('Sample Application created.' in self.browser.contents)
    1133         application = self.customer['applications']['a102']
    1134         # Application can 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 ...
    11351135        self.browser.getLink("a102").click()
    1136         self.browser.open(self.applications_path + '/a102/edit')
     1136        self.browser.open(self.contracts_path + '/a102/edit')
    11371137        #self.browser.getLink("Edit").click()
    11381138        self.assertTrue('The requested form is locked' in self.browser.contents)
    11391139        # Customer is in wrong state
    11401140        IWorkflowState(self.customer).setState(APPROVED)
    1141         self.browser.open(self.applications_path + '/a102/edit')
     1141        self.browser.open(self.contracts_path + '/a102/edit')
    11421142        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 ...
    11441144        self.assertTrue('<option value="SAM">' in self.browser.contents)
    11451145        # ... but NOTSAM not.
    11461146        self.assertFalse('<option value="LIC">' in self.browser.contents)
    11471147        # 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)
    11491149        self.browser.getControl(name="form.product").value = ['SAM']
    11501150        self.browser.getControl("Save").click()
    11511151        # 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')
    11531153        self.assertTrue('Form has been saved.' in self.browser.contents)
    11541154        # 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')
    11581158        self.assertTrue('Form has been saved.' in self.browser.contents)
    11591159        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')
    11611161        # Customer can submit the form. The form is also saved.
    11621162        self.browser.getLink("Edit").click()
    11631163        self.browser.getControl(name="form.title").value = 'My third app'
    11641164        self.browser.getControl("Apply now").click()
    1165         self.assertEqual(application.title, 'My third app')
    1166         self.assertEqual(application.state, 'submitted')
    1167         self.assertTrue('Application State: submitted for approval' in self.browser.contents)
    1168         # Customer can't edit the application once it has been submitted
    1169         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')
    11701170        self.assertTrue('The requested form is locked' in self.browser.contents)
    11711171
    11721172    def test_view_slips(self):
    11731173        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1174         # Officers can open the application overview
    1175         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()
    11771177        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    11781178        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')
    11801180        open(path, 'wb').write(self.browser.contents)
    11811181        print "Sample PDF overview_slip.pdf written to %s" % path
    1182         # Officers can open application slips
    1183         self.browser.open(self.customer_path + '/applications/a101')
    1184         self.browser.getLink("Download application slip").click()
     1182        # Officers can open contract slips
     1183        self.browser.open(self.customer_path + '/contracts/a101')
     1184        self.browser.getLink("Download contract slip").click()
    11851185        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    11861186        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')
    11881188        open(path, 'wb').write(self.browser.contents)
    1189         print "Sample application_slip.pdf written to %s" % path
    1190 
     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  
    2727from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
    2828from waeup.ikoba.customers.customer import Customer
    29 from waeup.ikoba.customers.applications import SampleApplication
     29from waeup.ikoba.customers.contracts import SampleContract
    3030
    3131
     
    6161        product.product_id = u'SAM'
    6262        product.title = u'Our Samle Product'
    63         product.application_category = u'sample'
     63        product.contract_category = u'sample'
    6464        self.app['products'].addProduct(product)
    6565        self.product_id = product.product_id
    6666        self.product = self.app['products'][self.product_id]
    6767
    68         application = createObject('waeup.SampleApplication')
    69         application.title = u'My Samle Application'
    70         application.product = product
    71         application.last_product_id = product.product_id
    72         self.customer['applications'].addApplication(application)
    73         self.application_id = application.application_id
    74         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]
    7575
    7676        document = createObject('waeup.CustomerSampleDocument')
     
    125125
    126126    def test_search_by_id(self):
    127         # We can find a certain application id
     127        # We can find a certain contract id
    128128        cat = queryUtility(ICatalog, name='documents_catalog')
    129129        results = cat.searchResults(document_id=(self.document_id,
     
    134134
    135135
    136 class ApplicationsCatalogTests(CatalogTestSetup):
     136class ContractsCatalogTests(CatalogTestSetup):
    137137
    138138    layer = FunctionalLayer
     
    140140    def test_get_catalog(self):
    141141        # We can get an customers catalog if we wish
    142         cat = queryUtility(ICatalog, name='applications_catalog')
     142        cat = queryUtility(ICatalog, name='contracts_catalog')
    143143        assert cat is not None
    144144
    145145    def test_search_by_id(self):
    146         # We can find a certain application id
    147         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))
    150150        results = [x for x in results] # Turn results generator into list
    151151        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]
    153153
    154154    def test_search_by_category(self):
    155155        # 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'))
    158158        results = [x for x in results] # Turn results generator into list
    159159        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]
    161161
    162162    def test_search_by_last_product_id(self):
    163163        # We can find a certain name
    164         cat = queryUtility(ICatalog, name='applications_catalog')
     164        cat = queryUtility(ICatalog, name='contracts_catalog')
    165165        results = cat.searchResults(last_product_id=('SAM', 'SAM'))
    166166        results = [x for x in results] # Turn results generator into list
    167167        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]
    169169        assert results[0].product is self.product
    170170
    171171    def test_product_removal(self):
    172172        # This test does not only test catalog components, it also ensures
    173         # that the product attribute of an application is cleared
     173        # that the product attribute of an contract is cleared
    174174        # but the last_product_id is not.
    175175        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')
    179179        results = cat.searchResults(last_product_id=('SAM', 'SAM'))
    180180        results = [x for x in results]
    181181        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]
    183183        assert results[0].product is None
    184184        # Product removal is being logged in customers.log
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_contract.py

    r12096 r12097  
    1717##
    1818"""
    19 Tests for applications.
     19Tests for contracts.
    2020"""
    2121from zope.interface.verify import verifyClass, verifyObject
     
    2424    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
    2525from waeup.ikoba.customers.interfaces import (
    26     IApplicationsContainer, IApplication)
     26    IContractsContainer, IContract)
    2727from waeup.ikoba.interfaces import IObjectHistory
    28 from waeup.ikoba.customers.applications import (
    29     ApplicationsContainer, SampleApplication)
     28from waeup.ikoba.customers.contracts import (
     29    ContractsContainer, SampleContract)
    3030from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase)
    3131
    32 class ApplicationsContainerTestCase(FunctionalTestCase):
     32class ContractsContainerTestCase(FunctionalTestCase):
    3333
    3434    layer = FunctionalLayer
     
    3838        self.assertTrue(
    3939            verifyClass(
    40                 IApplicationsContainer, ApplicationsContainer)
     40                IContractsContainer, ContractsContainer)
    4141            )
    4242        self.assertTrue(
    4343            verifyObject(
    44                 IApplicationsContainer, ApplicationsContainer())
     44                IContractsContainer, ContractsContainer())
    4545            )
    4646        self.assertTrue(
    4747            verifyClass(
    48                 IApplication, SampleApplication)
     48                IContract, SampleContract)
    4949            )
    5050        self.assertTrue(
    5151            verifyObject(
    52                 IApplication, SampleApplication())
     52                IContract, SampleContract())
    5353            )
    5454        return
    5555
    56     def test_addApplication(self):
    57         container = ApplicationsContainer()
    58         application = createObject(u'waeup.SampleApplication')
    59         id = application.application_id
    60         container.addApplication(application)
    61         self.assertEqual(container[id], application)
    62         self.assertRaises(TypeError, container.addApplication, 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')
    6464        self.assertEqual(id, 'a123')
    6565        return
    6666
    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')
    7979        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')
    8484        return
    8585
    86     def test_application_history(self):
    87         doc = createObject(u'waeup.SampleApplication')
     86    def test_contract_history(self):
     87        doc = createObject(u'waeup.SampleContract')
    8888        IWorkflowInfo(doc).fireTransition('create')
    8989        messages = ' '.join(doc.history.messages)
    90         self.assertTrue('Application record created by system' in messages)
     90        self.assertTrue('Contract record created by system' in messages)
    9191        return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py

    r12091 r12097  
    268268        )
    269269
    270 def generate_application_id():
    271     new_id = grok.getSite().unique_application_id
     270def generate_contract_id():
     271    new_id = grok.getSite().unique_contract_id
    272272    return new_id
    273273
     
    289289    APPMANAGE_CUSTOMER_STATES = DOCMANAGE_CUSTOMER_STATES
    290290
    291     APPMANAGE_APPLICATION_STATES = (CREATED,)
     291    APPMANAGE_CONTRACT_STATES = (CREATED,)
    292292
    293293    SKIP_UPLOAD_VIEWLETS = ()
     
    301301
    302302
    303     TRANSLATED_APPLICATION_STATES = {
     303    TRANSLATED_CONTRACT_STATES = {
    304304        CREATED: _('created'),
    305305        SUBMITTED: _('submitted for approval'),
     
    315315
    316316    APPTYPES_DICT = {
    317         'SampleApplication': 'Sample Application',
     317        'SampleContract': 'Sample Contract',
    318318        }
    319319
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py

    r12091 r12097  
    2828    ICustomer, ICustomersContainer,
    2929    ICustomerDocumentsContainer, ICustomerDocument,
    30     IApplicationsContainer, IApplication)
     30    IContractsContainer, IContract)
    3131from waeup.ikoba.customers.browser import (
    3232    CustomersContainerPage, CustomersContainerManagePage,
    3333    CustomerBaseDisplayFormPage,
    3434    DocumentsManageFormPage, DocumentDisplayFormPage, DocumentManageFormPage,
    35     ApplicationsManageFormPage, ApplicationDisplayFormPage,
    36     ApplicationManageFormPage)
     35    ContractsManageFormPage, ContractDisplayFormPage,
     36    ContractManageFormPage)
    3737
    3838grok.context(IIkobaObject)  # Make IIkobaObject the default context
     
    110110        targets += [
    111111            {'url':customer_url, 'title':'Base Data'},
    112             {'url':customer_url + '/applications', 'title':_('My Applications')},
     112            {'url':customer_url + '/contracts', 'title':_('My Contracts')},
    113113            {'url':customer_url + '/documents', 'title':_('My Documents')},
    114114            {'url':customer_url + '/history', 'title':_('History')},
     
    153153
    154154
    155 class CustomerManageApplicationsLink(CustomerManageLink):
    156     grok.order(3)
    157     link = 'applications'
    158     text = _(u'Applications')
     155class CustomerManageContractsLink(CustomerManageLink):
     156    grok.order(3)
     157    link = 'contracts'
     158    text = _(u'Contracts')
    159159
    160160
     
    372372    target = 'document_slip.pdf'
    373373
    374 # Viewlets for customer applications
    375 
    376 class AddApplicationActionButton(AddActionButton):
    377     grok.order(1)
    378     grok.context(IApplicationsContainer)
    379     grok.view(ApplicationsManageFormPage)
    380     grok.require('waeup.editApplications')
    381     text = _('Add application')
     374# Viewlets for customer contracts
     375
     376class AddContractActionButton(AddActionButton):
     377    grok.order(1)
     378    grok.context(IContractsContainer)
     379    grok.view(ContractsManageFormPage)
     380    grok.require('waeup.editContracts')
     381    text = _('Add contract')
    382382    target = 'addapp'
    383383
    384384
    385 class PDFApplicationOverviewActionButton(ManageActionButton):
    386     grok.order(2)
    387     grok.context(IApplicationsContainer)
    388     grok.view(ApplicationsManageFormPage)
     385class PDFContractOverviewActionButton(ManageActionButton):
     386    grok.order(2)
     387    grok.context(IContractsContainer)
     388    grok.view(ContractsManageFormPage)
    389389    grok.require('waeup.viewCustomer')
    390390    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(IApplication)
    398     grok.view(ApplicationDisplayFormPage)
     391    text = _('Download contracts overview')
     392    target = 'contracts_overview_slip.pdf'
     393
     394
     395class ContractManageActionButton(ManageActionButton):
     396    grok.order(1)
     397    grok.context(IContract)
     398    grok.view(ContractDisplayFormPage)
    399399    grok.require('waeup.manageCustomer')
    400400    text = _('Manage')
     
    402402
    403403
    404 class ApplicationEditActionButton(ManageActionButton):
    405     grok.order(1)
    406     grok.context(IApplication)
    407     grok.view(ApplicationDisplayFormPage)
     404class ContractEditActionButton(ManageActionButton):
     405    grok.order(1)
     406    grok.context(IContract)
     407    grok.view(ContractDisplayFormPage)
    408408    grok.require('waeup.handleCustomer')
    409409    text = _('Edit')
     
    417417
    418418
    419 class ApplicationTrigTransActionButton(ManageActionButton):
    420     grok.order(2)
    421     grok.context(IApplication)
    422     grok.view(ApplicationDisplayFormPage)
     419class ContractTrigTransActionButton(ManageActionButton):
     420    grok.order(2)
     421    grok.context(IContract)
     422    grok.view(ContractDisplayFormPage)
    423423    grok.require('waeup.triggerTransition')
    424424    icon = 'actionicon_trigtrans.png'
     
    427427
    428428
    429 class ApplicationViewActionButton(ManageActionButton):
    430     grok.order(1)
    431     grok.context(IApplication)
    432     grok.view(ApplicationManageFormPage)
     429class ContractViewActionButton(ManageActionButton):
     430    grok.order(1)
     431    grok.context(IContract)
     432    grok.view(ContractManageFormPage)
    433433    grok.require('waeup.handleCustomer')
    434434    text = _('View')
     
    437437
    438438
    439 class PDFApplicationSlipActionButton(ManageActionButton):
    440     grok.order(3)
    441     grok.context(IApplication)
    442     grok.view(ApplicationDisplayFormPage)
     439class PDFContractSlipActionButton(ManageActionButton):
     440    grok.order(3)
     441    grok.context(IContract)
     442    grok.view(ContractDisplayFormPage)
    443443    grok.require('waeup.viewCustomer')
    444444    icon = 'actionicon_pdf.png'
    445     text = _('Download application slip')
    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  
    121121
    122122class AppCatProductSource(SmartBasicContextualSourceFactory):
    123     """An application category product delivers all products
    124     which belong to a certain application_category.
     123    """An contract category product delivers all products
     124    which belong to a certain contract_category.
    125125    """
    126126    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:
    129129            return True
    130130        return False
    131131
    132132    def getValues(self, context):
    133         appcat = getattr(context, 'application_category', None)
     133        appcat = getattr(context, 'contract_category', None)
    134134        products = grok.getSite()['products'].values()
    135135        if not appcat:
    136136            return products
    137137        resultlist = [
    138             value for value in products if value.application_category == appcat]
     138            value for value in products if value.contract_category == appcat]
    139139        return resultlist
    140140
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py

    r12089 r12097  
    3131from waeup.ikoba.customers.interfaces import (
    3232    ICustomer, ICustomersUtils,
    33     IApplication)
     33    IContract)
    3434from waeup.ikoba.utils.helpers import get_current_principal
    3535from waeup.ikoba.documents.workflow import VERIFICATION_TRANSITIONS
     
    142142    return
    143143
    144 # Application workflow (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
     146IMPORTABLE_CONTRACT_STATES = (CREATED, SUBMITTED, APPROVED, REJECTED, EXPIRED)
     147
     148CONTRACT_TRANSITIONS = (
    149149    Transition(
    150150        transition_id = 'create',
    151         title = _('Create application record'),
     151        title = _('Create contract record'),
    152152        source = None,
    153153        condition = NullCondition,
    154         msg = _('Application record created'),
     154        msg = _('Contract record created'),
    155155        destination = CREATED),
    156156
     
    213213
    214214
    215 IMPORTABLE_APPLICATION_TRANSITIONS = [
     215IMPORTABLE_CONTRACT_TRANSITIONS = [
    216216    i.transition_id for i in REGISTRATION_TRANSITIONS]
    217217
    218 application_workflow = IkobaWorkflow(APPLICATION_TRANSITIONS)
    219 
    220 class ApplicationWorkflowState(WorkflowState, grok.Adapter):
    221     """An adapter to adapt Application objects to workflow states.
    222     """
    223     grok.context(IApplication)
     218contract_workflow = IkobaWorkflow(CONTRACT_TRANSITIONS)
     219
     220class ContractWorkflowState(WorkflowState, grok.Adapter):
     221    """An adapter to adapt Contract objects to workflow states.
     222    """
     223    grok.context(IContract)
    224224    grok.provides(IWorkflowState)
    225225
    226     state_key = 'wf.application.state'
    227     state_id = 'wf.application.id'
    228 
    229 class ApplicationWorkflowInfo(IkobaWorkflowInfo, grok.Adapter):
    230     """Adapter to adapt Application objects to workflow info objects.
    231     """
    232     grok.context(IApplication)
     226    state_key = 'wf.contract.state'
     227    state_id = 'wf.contract.id'
     228
     229class ContractWorkflowInfo(IkobaWorkflowInfo, grok.Adapter):
     230    """Adapter to adapt Contract objects to workflow info objects.
     231    """
     232    grok.context(IContract)
    233233    grok.provides(IIkobaWorkflowInfo)
    234234
    235235    def __init__(self, context):
    236236        self.context = context
    237         self.wf = application_workflow
    238 
    239 @grok.subscribe(IApplication, IWorkflowTransitionEvent)
     237        self.wf = contract_workflow
     238
     239@grok.subscribe(IContract, IWorkflowTransitionEvent)
    240240def handle_document_transition_event(obj, event):
    241     """Append message to application history and log file and update
     241    """Append message to contract history and log file and update
    242242    last_transition_date when transition happened.
    243243    """
  • main/waeup.ikoba/trunk/src/waeup/ikoba/permissions.py

    r12090 r12097  
    144144                     'waeup.triggerTransition',
    145145                     'waeup.viewCustomersTab',
    146                      'waeup.editApplications'
     146                     'waeup.editContracts'
    147147                     )
    148148
     
    170170                     'waeup.triggerTransition',
    171171                     'waeup.viewCustomersTab',
    172                      'waeup.editApplications'
     172                     'waeup.editContracts'
    173173                     )
    174174
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/interfaces.py

    r12078 r12097  
    2424
    2525class AppCatSource(ContextualDictSourceFactoryBase):
    26     """A application category source delivers all application categories
     26    """A contract category source delivers all contract categories
    2727    provided in the portal.
    2828    """
     
    5555        )
    5656
    57     application_category = schema.Choice(
    58         title = _(u'Application Category'),
     57    contract_category = schema.Choice(
     58        title = _(u'Contract Category'),
    5959        source = AppCatSource(),
    6060        default = u'license',
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/product.py

    r12095 r12097  
    6666def handle_product_removed(product, event):
    6767    """If a product is deleted, we make sure that also referrers to
    68     customer application objects are removed.
     68    customer contract objects are removed.
    6969    """
    7070    prodid = product.product_id
    7171
    72     # Find all customer applications that refer to given product...
     72    # Find all customer contracts that refer to given product...
    7373    try:
    74         cat = getUtility(ICatalog, name='applications_catalog')
     74        cat = getUtility(ICatalog, name='contracts_catalog')
    7575    except ComponentLookupError:
    7676        # catalog not available. This might happen during tests.
    7777        return
    7878    results = cat.searchResults(last_product_id=(prodid, prodid))
    79     for application in results:
     79    for contract in results:
    8080        # Remove that referrer...
    81         application.product = None
    82         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(
    8484            'ObjectRemovedEvent - %s - %s - removed: product' % (
    85                 application.customer.customer_id, application.application_id))
     85                contract.customer.customer_id, contract.contract_id))
    8686    return
    8787
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/sample_product_data.csv

    r12078 r12097  
    1 product_id,title,application_category
     1product_id,title,contract_category
    22ABC,ABC title,license
    33CDE,CDE title,license
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_batching.py

    r12078 r12097  
    165165            'INFO - system - Product Processor - sample_product_data - '
    166166            'EFG - updated: product_id=EFG, title=EFG title, '
    167             'application_category=license\n'
     167            'contract_category=license\n'
    168168            in logcontent)
    169169        failcontent = open(fail_file).read()
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_export.py

    r12078 r12097  
    6262        result = open(self.outfile, 'rb').read()
    6363        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'
    6565            'license,LIC,Unnamed,"[{\'user_name\': u\'john\', \'local_role\': '
    6666            'u\'johnsrole\'}]"\r\n'
     
    7575        result = open(self.outfile, 'rb').read()
    7676        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'
    7878            'license,LIC,Unnamed,"[{\'user_name\': u\'john\', \'local_role\': '
    7979            'u\'johnsrole\'}]"\r\n'
  • main/waeup.ikoba/trunk/src/waeup/ikoba/webservices.py

    r11954 r12097  
    2020from zope.component import getUtility
    2121from zope.catalog.interfaces import ICatalog
    22 from waeup.ikoba.interfaces import ICompany, application_sessions_vocab
     22from waeup.ikoba.interfaces import ICompany
    2323
    2424class XMLRPCPermission(grok.Permission):
Note: See TracChangeset for help on using the changeset viewer.