Changeset 13218


Ignore:
Timestamp:
24 Aug 2015, 08:44:35 (9 years ago)
Author:
Henrik Bettermann
Message:

Add UI components to purge applicants containers.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
1 added
5 edited
1 moved

Legend:

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

    r13217 r13218  
    477477
    478478class ApplicantsContainerPrefillFormPage(KofaAddFormPage):
    479     """Add-form to pre-fill applicants containers.
     479    """Form to pre-fill applicants containers.
    480480    """
    481481    grok.context(IApplicantsContainer)
    482482    grok.require('waeup.manageApplication')
    483483    grok.name('prefill')
    484     grok.template('prefill_container')
     484    grok.template('prefillcontainer')
    485485    label = _('Pre-fill container')
    486486    pnav = 3
     
    497497
    498498    @action(_('Pre-fill now'), style='primary')
    499     def addApplicants(self, **data):
     499    def addApplicants(self):
    500500        form = self.request.form
    501501        if 'number' in form and form['number']:
     
    506506        self.flash(_('%s application records created.' % number))
    507507        self.context.writeLogMessage(self, '%s applicants created' % (number))
     508        self.redirect(self.url(self.context, 'index'))
     509        return
     510
     511    @action(_('Cancel'), validator=NullValidator)
     512    def cancel(self, **data):
     513        self.redirect(self.url(self.context))
     514        return
     515
     516class ApplicantsContainerPurgeFormPage(KofaEditFormPage):
     517    """Form to pre-fill applicants containers.
     518    """
     519    grok.context(IApplicantsContainer)
     520    grok.require('waeup.manageApplication')
     521    grok.name('purge')
     522    grok.template('purgecontainer')
     523    label = _('Purge container')
     524    pnav = 3
     525    doclink = DOCLINK + '/applicants.html'
     526
     527    @action(_('Remove initialized records'), style='primary')
     528    def purgeInitialized(self):
     529        form = self.request.form
     530        purged = 0
     531        keys = [key for key in self.context.keys()]
     532        for key in keys:
     533            if self.context[key].state == 'initialized':
     534                del self.context[key]
     535                purged += 1
     536        self.flash(_('%s application records purged.' % purged))
     537        self.context.writeLogMessage(self, '%s applicants purged' % (purged))
    508538        self.redirect(self.url(self.context, 'index'))
    509539        return
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r13216 r13218  
    333333    translated_state = Attribute('Real name of the application state')
    334334    special = Attribute('True if special application')
    335     application_number = Attribute('The key under which the record is stored')
    336335
    337336    application_date = Attribute('UTC datetime of submission, used for export only')
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r13217 r13218  
    467467        return
    468468
    469     def test_prefill_container(self):
     469    def test_prefill_purge_container(self):
    470470        # Managers can pre-fill containers in create mode
    471471        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    500500            {'not admitted': 0, 'started': 0, 'created': 0,
    501501            'admitted': 0, 'submitted': 0, 'initialized': 1, 'paid': 0})
     502        # Container can be purged
     503        self.browser.open(self.container_manage_path)
     504        self.browser.getLink("Purge").click()
     505        self.browser.getControl("Remove").click()
     506        self.assertTrue('11 application records purged' in self.browser.contents)
     507        self.assertEqual(self.applicantscontainer.counts[0], 0)
     508        self.assertEqual(self.applicantscontainer.counts[1], 0)
    502509        return
    503510
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py

    r13217 r13218  
    116116    target = 'addapplicant'
    117117
    118 class ApplicantsContainerPrefillActionButton(AddActionButton):
     118class ApplicantsContainerPrefillActionButton(ManageActionButton):
    119119    grok.order(2)
    120120    grok.context(IApplicantsContainer)
     
    125125    target = 'prefill'
    126126
     127class ApplicantsContainerPurgeActionButton(ManageActionButton):
     128    grok.order(3)
     129    grok.context(IApplicantsContainer)
     130    grok.view(ApplicantsContainerManageFormPage)
     131    grok.require('waeup.manageApplication')
     132    icon = 'actionicon_sweep.png'
     133    text = _('Purge container')
     134    target = 'purge'
     135
    127136class ApplicantsContainerStatisticsActionButton(ManageActionButton):
    128     grok.order(3)
     137    grok.order(4)
    129138    grok.context(IApplicantsContainer)
    130139    grok.view(ApplicantsContainerManageFormPage)
     
    136145class ApplicantsContainerStatisticsActionButton2(
    137146        ApplicantsContainerStatisticsActionButton):
    138     grok.order(4)
     147    grok.order(5)
    139148    grok.view(ApplicantsContainerPage)
    140149
  • main/waeup.kofa/trunk/src/waeup/kofa/documents/browser.py

    r13144 r13218  
    2121import sys
    2222import grok
    23 import pytz
    2423from urllib import urlencode
    2524from datetime import datetime
Note: See TracChangeset for help on using the changeset viewer.