Changeset 15154 for main/waeup.kofa


Ignore:
Timestamp:
19 Sep 2018, 21:17:50 (6 years ago)
Author:
Henrik Bettermann
Message:

First draft of transcript officer landing page.

Location:
main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/browser/pages.py

    r15116 r15154  
    6060    ISessionConfiguration, ISessionConfigurationAdd, IJobManager,
    6161    IPasswordValidator, IContactForm, IKofaUtils, ICSVExporter,
    62     academic_sessions_vocab, DOCLINK, registration_states_vocab)
     62    academic_sessions_vocab, DOCLINK, registration_states_vocab,
     63    TRANSREQ, TRANSVAL)
     64from waeup.kofa.university.faculty import Faculty
    6365from waeup.kofa.university.department import Department
    6466from waeup.kofa.university.course import Course
     
    375377                    self.redirect(self.application_url() + rel_link)
    376378                    return
    377                 # Redirect lecturer after login
     379                # Redirect some officers after login
    378380                local_roles = get_user_account(self.request).getLocalRoles()
    379381                if local_roles.has_key('waeup.local.Lecturer'):
    380382                    self.redirect(self.application_url() + '/my_courses')
     383                    return
     384                if local_roles.has_key('waeup.local.TranscriptOfficer'):
     385                    self.redirect(self.application_url() + '/my_transcript_requests')
     386                    return
     387                if local_roles.has_key('waeup.local.TranscriptSignee'):
     388                    self.redirect(self.application_url() + '/my_transcript_signing_requests')
    381389                    return
    382390                if not self.camefrom:
     
    10231031        return courses
    10241032
     1033class TranscriptOfficerLandingPage(KofaPage):
     1034    """Display students, who requested a transcript, when
     1035    transcript officer logs in.
     1036    """
     1037    grok.name('my_transcript_requests')
     1038    grok.require('waeup.Authenticated')
     1039    grok.context(IUniversity)
     1040    grok.template('mytranscriptrequests')
     1041    label =_('My Transcript Requests')
     1042
     1043    @property
     1044    def getStudents(self):
     1045        students = ([],[])
     1046        cat = queryUtility(ICatalog, name='students_catalog')
     1047        local_roles = get_user_account(self.request).getLocalRoles()
     1048        for item in local_roles.get('waeup.local.TranscriptOfficer', []):
     1049            if isinstance(item, Faculty):
     1050                faccode = item.code
     1051                results1 = cat.searchResults(
     1052                    state=(TRANSREQ, TRANSREQ), faccode=(faccode, faccode))
     1053                for result in results1:
     1054                    students[0].append(StudentQueryResultItem(result, self))
     1055                results2 = cat.searchResults(
     1056                    state=(TRANSVAL, TRANSVAL), faccode=(faccode, faccode))
     1057                for result in results2:
     1058                    students[1].append(StudentQueryResultItem(result, self))
     1059        return students
     1060
    10251061#
    10261062# Search pages...
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/tests/test_browser.py

    r15153 r15154  
    22672267        self.assertEqual(self.student.transcript_signees, None)
    22682268
     2269    def test_landingpage_transcript_officer(self):
     2270        IWorkflowState(self.student).setState('transcript requested')
     2271        notify(grok.ObjectModifiedEvent(self.student))
     2272        self.student.transcript_comment = (
     2273            u'On 07/08/2013 08:59:54 UTC K1000000 wrote:\n\nComment line 1 \n'
     2274            'Comment line2\n\nDispatch Address:\nAddress line 1 \n'
     2275            'Address line2\n\n')
     2276        # Create transcript officer
     2277        self.app['users'].addUser('mrtranscript', 'mrtranscriptsecret')
     2278        self.app['users']['mrtranscript'].email = 'mrtranscript@foo.ng'
     2279        self.app['users']['mrtranscript'].title = 'Ruth Gordon'
     2280        # We assign transcript officer role at faculty level
     2281        fac = self.app['faculties']['fac1']
     2282        prmlocal = IPrincipalRoleManager(fac)
     2283        prmlocal.assignRoleToPrincipal(
     2284            'waeup.local.TranscriptOfficer', 'mrtranscript')
     2285        notify(LocalRoleSetEvent(
     2286            fac, 'waeup.local.TranscriptOfficer', 'mrtranscript', granted=True))
     2287        # Login as transcript officer
     2288        self.browser.open(self.login_path)
     2289        self.browser.getControl(name="form.login").value = 'mrtranscript'
     2290        self.browser.getControl(name="form.password").value = 'mrtranscriptsecret'
     2291        self.browser.getControl("Login").click()
     2292        self.assertMatches('...You logged in...', self.browser.contents)
     2293        # Officer is on landing page
     2294        self.assertTrue(
     2295            'http://localhost/app/students/K1000000/studycourse/transcript'
     2296            in self.browser.contents)
     2297
    22692298
    22702299class StudentUITests(StudentsFullSetup):
Note: See TracChangeset for help on using the changeset viewer.