Ignore:
Timestamp:
11 Jun 2020, 15:22:24 (5 years ago)
Author:
Henrik Bettermann
Message:

Add CheckTranscriptStatus? page.

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

Legend:

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

    r16097 r16116  
    2626from datetime import datetime, date
    2727from time import time, sleep
     28import xmlrpclib
    2829from zope.event import notify
    2930from zope.component import getUtility, queryUtility, createObject, getAdapter
     
    16531654        return
    16541655
     1656class CheckTranscriptStatus(KofaPage):
     1657    """A display page for checking transcript processing status.
     1658    """
     1659    grok.context(IApplicantsRoot)
     1660    grok.name('checktranscript')
     1661    grok.require('waeup.Public')
     1662    label = _('Check transcript status')
     1663    buttonname = _('Check status now')
     1664    pnav = 8
     1665    websites = (('DemoPortal', 'http://localhost:8080/app'),)
     1666    appl_url1 = 'http://localhost:8080/app/applicants'
     1667    appl_url2 = 'http://localhost:8080/app/applicants'
     1668
     1669    def update(self, SUBMIT=None):
     1670        form = self.request.form
     1671        self.button = False
     1672        # Handle captcha
     1673        self.captcha = getUtility(ICaptchaManager).getCaptcha()
     1674        self.captcha_result = self.captcha.verify(self.request)
     1675        self.captcha_code = self.captcha.display(self.captcha_result.error_code)
     1676        if SUBMIT:
     1677            self.results = []
     1678            if not self.captcha_result.is_valid:
     1679                # Captcha will display error messages automatically.
     1680                # No need to flash something.
     1681                return
     1682            unique_id = form.get('unique_id', None)
     1683            email = form.get('email', None)
     1684            if not unique_id or not email:
     1685                self.flash(
     1686                    _('Required input missing.'), type='warning')
     1687                return
     1688            self.button = True
     1689            # Call webservice of all websites
     1690            for website in self.websites:
     1691                server = xmlrpclib.ServerProxy(website[1])
     1692                result = server.get_grad_student(unique_id, email)
     1693                if not result:
     1694                    continue
     1695                self.results.append((result, website))
     1696        return
     1697
    16551698class ExportJobContainerOverview(KofaPage):
    16561699    """Page that lists active applicant data export jobs and provides links
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r16064 r16116  
    15391539          'password is: <strong>%s</strong>' % self.applicant.application_number
    15401540          in self.browser.contents)
    1541        
     1541
     1542    def test_check_transcript_status(self):
     1543        self.applicant.email = 'aa@aa.aa'
     1544        self.browser.open('http://localhost/app/applicants/checktranscript')
     1545        self.browser.getControl(name="unique_id").value = 'nonsense'
     1546        self.browser.getControl(name="email").value = 'aa@aa.aa'
     1547        self.browser.getControl("Check status now").click()
     1548        # Here the test fails because it seems that
     1549        # xmlrpclib.ServerProxy can't be
     1550        # used in tests even if we use
     1551        # zope.app.testing.xmlrpc import ServerProxy with correct
     1552        # URL. Any idea Uli?
     1553        self.assertTrue('No student record was found in Kofa'
     1554            in self.browser.contents)
     1555        self.browser.getControl(
     1556          name="unique_id").value = self.applicant.applicant_id
     1557        self.browser.getControl(name="email").value = 'aa@aa.aa'
     1558        self.browser.getControl("Check status now").click()
    15421559
    15431560class ApplicantsExportTests(ApplicantsFullSetup, FunctionalAsyncTestCase):
Note: See TracChangeset for help on using the changeset viewer.