Changeset 7620


Ignore:
Timestamp:
9 Feb 2012, 19:29:24 (13 years ago)
Author:
Henrik Bettermann
Message:

getVerdictsDict should be part of the students package. The only way to reach this ist to move the VerdictSource? to interfaces in order to avoid circular imports.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r7619 r7620  
    1717##
    1818from datetime import datetime
     19from zope.component import getUtility
    1920from zope.interface import Attribute, Interface
    2021from zope import schema
     22from zc.sourcefactory.contextual import BasicContextualSourceFactory
    2123from waeup.sirp.interfaces import (
    2224    ISIRPObject, academic_sessions_vocab, validate_email)
     
    2426from waeup.sirp.university.vocabularies import CourseSource, study_modes
    2527from waeup.sirp.students.vocabularies import (
    26   CertificateSource, VerdictSource, StudyLevelSource,
     28  CertificateSource, StudyLevelSource,
    2729  contextual_reg_num_source, contextual_mat_num_source,
    2830  GenderSource, nats_vocab,
    2931  )
    3032from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment
     33
     34# VerdictSource can't be placed into the vocabularies module because it
     35# requires importing IStudentsUtils which then leads to circular imports.
     36class VerdictSource(BasicContextualSourceFactory):
     37    """A verdicts source delivers all verdicts provided
     38    in the portal.
     39    """
     40    def getValues(self, context):
     41        self.verdicts_dict = getUtility(IStudentsUtils).getVerdictsDict()
     42        return self.verdicts_dict.keys()
     43
     44    def getToken(self, context, value):
     45        return value
     46
     47    def getTitle(self, context, value):
     48        return self.verdicts_dict[value]
    3149
    3250class IStudentsUtils(Interface):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py

    r7615 r7620  
    338338            'Content-Type', 'application/pdf')
    339339        return pdf.getpdfdata()
     340
     341    def getVerdictsDict(self):
     342        """Provide a dictionary of verdicts.
     343        """
     344        return {
     345            'A1': 'First Class',
     346            '0': 'not yet',
     347            'A3': 'Second Class Lower',
     348            'A2': 'Second Class Upper',
     349            'A5': 'Pass',
     350            'A4': 'Third Class',
     351            'A7': 'Credit',
     352            'A6': 'Distinction',
     353            'A8': 'Merit',
     354            'A': 'Successful student',
     355            'C': 'Student on probation',
     356            'B': 'Student with carryover courses',
     357            'E': 'Student who were previously on probation',
     358            'D': 'Withdrawn from the faculty',
     359            'G': 'Absent from examination',
     360            'F': 'Medical case',
     361            'I': 'Expelled/rusticated/suspended student',
     362            'H': 'Withheld results',
     363            'K': 'Unregistered student',
     364            'J': 'Temporary withdrawn from the university',
     365            'M': 'Reinstatement',
     366            'L': 'Referred student',
     367            'O': 'NCE-III repeater',
     368            'N': 'Student on transfer',
     369            'Y': 'No previous verdict',
     370            'X': 'New 300 level student',
     371            'Z': 'Successful student (provisional)'}
  • main/waeup.sirp/trunk/src/waeup/sirp/students/vocabularies.py

    r7619 r7620  
    2525from zc.sourcefactory.basic import BasicSourceFactory
    2626from zc.sourcefactory.contextual import BasicContextualSourceFactory
    27 from waeup.sirp.interfaces import SimpleSIRPVocabulary, ISIRPUtils
     27from waeup.sirp.interfaces import SimpleSIRPVocabulary
    2828from waeup.sirp.students.lgas import LGAS
    2929from waeup.sirp.students.nats import NATS
     
    8585            return "%s on %d. probation" % (title, repeat)
    8686        return title
    87 
    88 class VerdictSource(BasicContextualSourceFactory):
    89     """A verdicts source delivers all verdicts provided
    90     in the portal.
    91     """
    92 
    93     def getValues(self, context):
    94         self.verdicts_dict = getUtility(ISIRPUtils).getVerdictsDict()
    95         return self.verdicts_dict.keys()
    96 
    97     def getToken(self, context, value):
    98         return value
    99 
    100     def getTitle(self, context, value):
    101         return self.verdicts_dict[value]
    10287
    10388class CertificateSource(BasicContextualSourceFactory):
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py

    r7619 r7620  
    108108        return send_mail(
    109109            from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
    110 
    111 
    112     def getVerdictsDict(self):
    113         """Provide a dictionary of verdicts.
    114         """
    115         return {
    116             'A1': 'First Class',
    117             '0': 'not yet',
    118             'A3': 'Second Class Lower',
    119             'A2': 'Second Class Upper',
    120             'A5': 'Pass',
    121             'A4': 'Third Class',
    122             'A7': 'Credit',
    123             'A6': 'Distinction',
    124             'A8': 'Merit',
    125             'A': 'Successful student',
    126             'C': 'Student on probation',
    127             'B': 'Student with carryover courses',
    128             'E': 'Student who were previously on probation',
    129             'D': 'Withdrawn from the faculty',
    130             'G': 'Absent from examination',
    131             'F': 'Medical case',
    132             'I': 'Expelled/rusticated/suspended student',
    133             'H': 'Withheld results',
    134             'K': 'Unregistered student',
    135             'J': 'Temporary withdrawn from the university',
    136             'M': 'Reinstatement',
    137             'L': 'Referred student',
    138             'O': 'NCE-III repeater',
    139             'N': 'Student on transfer',
    140             'Y': 'No previous verdict',
    141             'X': 'New 300 level student',
    142             'Z': 'Successful student (provisional)'}
Note: See TracChangeset for help on using the changeset viewer.