Ignore:
Timestamp:
30 May 2012, 19:24:51 (13 years ago)
Author:
Henrik Bettermann
Message:

Add container statistics property, browser page and button viewlets.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r8562 r8563  
    286286        return self.context.p_id
    287287
     288class ApplicantsStatisticsPage(KofaDisplayFormPage):
     289    """Some statistics about applicants in a container.
     290    """
     291    grok.context(IApplicantsContainer)
     292    grok.name('statistics')
     293    grok.require('waeup.manageApplication')
     294    grok.template('applicantcontainerstatistics')
     295
     296    @property
     297    def label(self):
     298        return "%s" % self.context.title
     299
    288300class ApplicantsContainerPage(KofaDisplayFormPage):
    289301    """The standard view for regular applicant containers.
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py

    r8543 r8563  
    2828    )
    2929from waeup.kofa.utils.helpers import attrs_to_fields
     30from waeup.kofa.applicants.workflow import (INITIALIZED,
     31    STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED)
    3032
    3133def generate_applicant_id(container=None):
     
    9597        return
    9698
     99    @property
     100    def statistics(self):
     101        statistics = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0,
     102            ADMITTED:0, NOT_ADMITTED:0, CREATED:0}
     103        for key in self.keys():
     104            statistics[self[key].state] += 1
     105        return statistics
     106
    97107ApplicantsContainer = attrs_to_fields(ApplicantsContainer)
    98108
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py

    r8435 r8563  
    2323from waeup.kofa.applicants.interfaces import (
    2424    IApplicant, IApplicantsRoot, IApplicantsContainer,
    25     IApplicantOnlinePayment,
     25    IApplicantOnlinePayment
    2626    )
    2727from waeup.kofa.applicants.browser import (
    2828    ApplicantsRootPage, ApplicantsContainerPage, ApplicantManageFormPage,
    29     ApplicantDisplayFormPage, OnlinePaymentDisplayFormPage
     29    ApplicantDisplayFormPage, OnlinePaymentDisplayFormPage,
     30    ApplicantsContainerManageFormPage, ApplicantsStatisticsPage
    3031    )
    3132
     
    9899    text = _('Manage application section')
    99100
    100 #class ApplicantsContainerManageActionButton(ManageActionButton):
    101 #    grok.order(1)
    102 #    grok.context(IApplicantsContainer)
    103 #    grok.view(ApplicantsContainerPage)
    104 #    grok.require('waeup.manageApplication')
    105 #    text = _('Manage application records')
    106 
    107101class ApplicantRegisterActionButton(ManageActionButton):
    108     grok.order(2)
     102    grok.order(1)
    109103    grok.context(IApplicantsContainer)
    110104    grok.view(ApplicantsContainerPage)
     
    114108    target = 'register'
    115109
     110class ApplicantsContainerStatisticsActionButton(ManageActionButton):
     111    grok.order(1)
     112    grok.context(IApplicantsContainer)
     113    grok.view(ApplicantsContainerManageFormPage)
     114    grok.require('waeup.manageApplication')
     115    icon = 'actionicon_statistics.png'
     116    text = _('Container statistics')
     117    target = 'statistics'
     118
     119class ApplicantsContainerStatisticsActionButton2(ApplicantsContainerStatisticsActionButton):
     120    grok.order(3)
     121    grok.view(ApplicantsContainerPage)
     122
     123class ApplicantsContainerManageActionButton(ManageActionButton):
     124    grok.order(2)
     125    grok.context(IApplicantsContainer)
     126    grok.view(ApplicantsContainerPage)
     127    grok.require('waeup.manageApplication')
     128    text = _('Manage container')
     129    target = 'manage'
     130
    116131class ApplicantViewActionButton(ManageActionButton):
    117132    grok.context(IApplicant)
Note: See TracChangeset for help on using the changeset viewer.