Ignore:
Timestamp:
14 May 2015, 13:11:55 (10 years ago)
Author:
Henrik Bettermann
Message:

Implement public page to view all (customizable) sources, vocabularies and dicts (work in progress).

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

Legend:

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

    r12926 r12932  
    5959    ISessionConfiguration, ISessionConfigurationAdd, IJobManager,
    6060    IPasswordValidator, IContactForm, IKofaUtils, ICSVExporter,
    61     academic_sessions_vocab, DOCLINK)
     61    academic_sessions_vocab, DOCLINK, registration_states_vocab)
    6262from waeup.kofa.permissions import (
    6363    get_users_with_local_roles, get_all_roles, get_all_users,
     
    7373from waeup.kofa.students.catalog import StudentQueryResultItem
    7474from waeup.kofa.students.interfaces import IStudentsUtils
     75from waeup.kofa.students.vocabularies import StudyLevelSource
    7576
    7677FORBIDDEN_CHARACTERS = (160,)
     
    493494            return html
    494495
     496class SourcesOverview(KofaPage):
     497    grok.context(IUniversity)
     498    grok.name('sources')
     499    grok.require('waeup.Public')
     500    label = _(u'Sources & Vocabularies')
     501    pnav = 0
     502
     503    def _set_inst_types(self):
     504        study_modes = getUtility(IKofaUtils).INST_TYPES_DICT
     505        self.inst_types = study_modes.items()
     506        return
     507
     508    def _set_sessions(self):
     509        vocab_terms = academic_sessions_vocab.by_value.values()
     510        self.sessions = [(x.token, x.title,) for x in vocab_terms]
     511        return
     512
     513    def _set_levels(self):
     514        studylevelsource = StudyLevelSource().factory
     515        self.levels = []
     516        for code in studylevelsource.getValues(None):
     517            title = studylevelsource.getTitle(None, code)
     518            self.levels.append((code, title))
     519        return
     520
     521    def _set_study_modes(self):
     522        study_modes = getUtility(IKofaUtils).STUDY_MODES_DICT
     523        self.study_modes = study_modes.items()
     524        return
     525
     526    def _set_student_states(self):
     527        vocab_terms = registration_states_vocab.by_value.values()
     528        self.student_states = [(x.token, x.title) for x in vocab_terms]
     529        return
     530
     531    def _set_verdicts(self):
     532        verdicts = getUtility(IStudentsUtils).VERDICTS_DICT
     533        self.verdicts = verdicts.items()
     534        return
     535
     536    def _set_exam_subjects(self):
     537        exam_subjects = getUtility(IKofaUtils).EXAM_SUBJECTS_DICT
     538        self.exam_subjects = exam_subjects.items()
     539        return
     540
     541    def _set_exam_grades(self):
     542        self.exam_grades = getUtility(IKofaUtils).EXAM_GRADES
     543        return
     544
     545    def _set_app_cats(self):
     546        app_cats = getUtility(IKofaUtils).APP_CATS_DICT
     547        self.app_cats = app_cats.items()
     548        return
     549
     550    def _set_payment_cats(self):
     551        payment_cats = getUtility(IKofaUtils).PAYMENT_CATEGORIES
     552        self.payment_cats = payment_cats.items()
     553        return
     554
     555    def update(self):
     556        self._set_inst_types()
     557        self._set_sessions()
     558        self._set_levels()
     559        self._set_study_modes()
     560        self._set_student_states()
     561        self._set_verdicts()
     562        self._set_exam_subjects()
     563        self._set_exam_grades()
     564        self._set_app_cats()
     565        self._set_payment_cats()
     566
    495567class AdministrationPage(KofaPage):
    496568    """ The administration overview page.
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r12929 r12932  
    500500            'This account has been suspended.' in self.browser.contents)
    501501        return
     502
     503    def test_sources_overview(self):
     504        self.browser.open('http://localhost/app/sources')
     505        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     506        self.assertTrue('id="headingStudentStates"' in self.browser.contents)
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py

    r12919 r12932  
    5959    grok.name('widgets')
    6060
     61class SourcesLeft(grok.ViewletManager):
     62    grok.name('sources_left')
     63
     64class SourcesRight(grok.ViewletManager):
     65    grok.name('sources_right')
     66
    6167
    6268#
     
    853859            '<input class="text-right" type="submit" value="remove" />' + \
    854860            '</form></div>'
     861
     862class InstTypesSource(grok.Viewlet):
     863    """Avalable institution types for the sources overview page.
     864    """
     865    grok.order(1)
     866    grok.viewletmanager(SourcesLeft)
     867    grok.require('waeup.Public')
     868    grok.template('source')
     869    column = 'left'
     870    name = 'InstTypes'
     871    source_name = 'inst_types'
     872    title = _('Institution Types')
     873
     874    def heading(self):
     875        return 'heading%s' % self.name
     876
     877    def accordion(self):
     878        return '#accordion-%s' % self.column
     879
     880    def collapse(self):
     881        return 'collapse%s' % self.name
     882
     883    def hash_collapse(self):
     884        return '#collapse%s' % self.name
     885
     886    def source(self):
     887        return getattr(self.view, self.source_name)
     888
     889class SessionSource(InstTypesSource):
     890    """Avalable sessions for the sources overview page.
     891    """
     892    grok.order(2)
     893    name = 'Sessions'
     894    source_name = 'sessions'
     895    title = _('Academic Sessions')
     896
     897class StudyLevelSource(InstTypesSource):
     898    """Avalable study levels for the sources overview page.
     899    """
     900    grok.order(3)
     901    name = 'Levels'
     902    source_name = 'levels'
     903    title = _('Study Levels')
     904
     905class StudyModeSource(InstTypesSource):
     906    """Avalable study modes for the sources overview page.
     907    """
     908    grok.order(4)
     909    name = 'StudyModes'
     910    source_name = 'study_modes'
     911    title = _('Study Modes')
     912
     913class AppCatsSource(InstTypesSource):
     914    """Avalable application categories for the sources overview page.
     915    """
     916    grok.order(5)
     917    name = 'AppCats'
     918    source_name = 'app_cats'
     919    title = _('Application Categories')
     920
     921class StudentStatesSource(InstTypesSource):
     922    """Avalable student sates for the sources overview page.
     923    """
     924    grok.order(1)
     925    grok.viewletmanager(SourcesRight)
     926    column = 'right'
     927    name = 'StudentStates'
     928    source_name = 'student_states'
     929    title = _('Student Registration States')
     930
     931class VerdictsSource(InstTypesSource):
     932    """Avalable verdicts for the sources overview page.
     933    """
     934    grok.order(2)
     935    grok.viewletmanager(SourcesRight)
     936    column = 'right'
     937    name = 'Verdicts'
     938    source_name = 'verdicts'
     939    title = _('Verdicts')
     940
     941class PaymentCatsSource(InstTypesSource):
     942    """Avalable payment categories for the sources overview page.
     943    """
     944    grok.order(3)
     945    grok.viewletmanager(SourcesRight)
     946    column = 'right'
     947    name = 'PaymentCats'
     948    source_name = 'payment_cats'
     949    title = _('Payment Categories')
     950
     951class ExamSubjectsSource(InstTypesSource):
     952    """Avalable exam subjects for the sources overview page.
     953    """
     954    grok.order(4)
     955    grok.viewletmanager(SourcesRight)
     956    column = 'right'
     957    name = 'ExamSubjects'
     958    source_name = 'exam_subjects'
     959    title = _('Exam Subjects')
     960
     961class ExamGradesSource(InstTypesSource):
     962    """Avalable exam grades for the sources overview page.
     963    """
     964    grok.order(5)
     965    grok.viewletmanager(SourcesRight)
     966    column = 'right'
     967    name = 'ExamGrades'
     968    source_name = 'exam_grades'
     969    title = _('Exam Grades')
     970
Note: See TracChangeset for help on using the changeset viewer.