Ignore:
Timestamp:
17 Jan 2013, 13:03:55 (12 years ago)
Author:
Henrik Bettermann
Message:

Let's create all students from applicants root.

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

Legend:

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

    r9795 r9900  
    3434    IApplicantRegisterUpdate
    3535    )
     36from waeup.kofa.applicants.container import ApplicantsContainer
    3637from waeup.kofa.applicants.applicant import search
    3738from waeup.kofa.applicants.workflow import (
     
    578579    be provided and only PortalManagers can do this.
    579580    """
    580     grok.context(IApplicantsContainer)
     581    #grok.context(IApplicantsContainer)
    581582    grok.name('createallstudents')
    582583    grok.require('waeup.managePortal')
     
    586587        results = list(cat.searchResults(state=(ADMITTED, ADMITTED)))
    587588        created = []
     589        container_only = False
     590        applicants_root = grok.getSite()['applicants']
     591        if isinstance(self.context, ApplicantsContainer):
     592            container_only = True
    588593        for result in results:
    589             if result.__parent__ is not self.context:
     594            if container_only and result.__parent__ is not self.context:
    590595                continue
    591596            success, msg = result.createStudent(view=self)
     
    594599            else:
    595600                ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
    596                 self.context.__parent__.logger.info(
     601                applicants_root.logger.info(
    597602                    '%s - %s - %s' % (ob_class, result.applicant_id, msg))
    598603        if len(created):
     
    601606        else:
    602607            self.flash(_('No student could be created.'))
    603         self.redirect(self.url(self.context, u'statistics'))
     608        self.redirect(self.url(self.context))
    604609        return
    605610
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py

    r9544 r9900  
    144144        self.assertTrue('1 students successfully created' in self.browser.contents)
    145145
    146     def test_hidden_batch_copying(self):
     146    def test_hidden_batch_copying_container(self):
    147147        logfile = os.path.join(
    148148            self.app['datacenter'].storage, 'logs', 'applicants.log')
     
    171171        self.assertTrue('1 students successfully created' in self.browser.contents)
    172172
     173    def test_hidden_batch_copying_all(self):
     174        logfile = os.path.join(
     175            self.app['datacenter'].storage, 'logs', 'applicants.log')
     176        self.prepare_applicant()
     177        self.browser.open(self.manage_path)
     178        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
     179        #self.browser.getControl(name="form.course_admitted").value = ['CERT1']
     180        self.browser.getControl("Save").click()
     181        IWorkflowState(self.applicant).setState('admitted')
     182        notify(grok.ObjectModifiedEvent(self.applicant))
     183        self.browser.open(self.root_path + '/createallstudents')
     184        self.assertTrue('No student could be created' in self.browser.contents)
     185        logcontent = open(logfile).read()
     186        self.assertTrue('No course admitted provided' in logcontent)
     187        self.applicant.course_admitted = self.certificate
     188        self.browser.open(self.root_path + '/createallstudents')
     189        self.assertTrue('1 students successfully created' in self.browser.contents)
     190
    173191    def test_copier_wo_passport(self):
    174192        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py

    r9759 r9900  
    139139
    140140class AllStudentsCreateActionButton(ManageActionButton):
    141     grok.order(1)
    142     grok.context(IApplicantsContainer)
    143     grok.view(ApplicantsStatisticsPage)
     141    grok.order(3)
     142    grok.context(IApplicantsRoot)
     143    grok.view(ApplicantsRootPage)
    144144    grok.require('waeup.managePortal')
    145145    icon = 'actionicon_entrance.png'
    146146    text = _('Create all student records')
    147147    target ='createallstudents'
     148
     149class ContainerStudentsCreateActionButton(AllStudentsCreateActionButton):
     150    grok.context(IApplicantsContainer)
     151    grok.order(1)
     152    grok.view(ApplicantsStatisticsPage)
    148153
    149154class ApplicantViewActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.