Ignore:
Timestamp:
15 Apr 2011, 14:07:35 (14 years ago)
Author:
Henrik Bettermann
Message:

Implement 'Add' interfaces for Faculties, Departments, Courses and Certificates. The add methods are broken for the views which use these interfaces for form field generation. I don't know why.

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

Legend:

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

    r5950 r5951  
    66    IWAeUPObject, IUniversity, IUserContainer, IDataCenter)
    77from waeup.sirp.university.interfaces import (
    8     IFacultyContainer, IFaculty, IDepartment, ICourseContainer, ICourse,
    9     ICertificateContainer, ICertificate, ICertificateCourse, CourseSource)
    10 
     8    IFacultyContainer, IFaculty, IFacultyAdd, IDepartment, IDepartmentAdd,
     9    ICourseContainer, ICourse, ICourseAdd, ICertificateContainer,
     10    ICertificate, ICertificateAdd, ICertificateCourse, ICertificateCourseAdd)
    1111class IBreadcrumb(Interface):
    1212    """Provide breadcrumbs.
     
    5555        """Get the list of breadcrumbs as real Python list.
    5656        """
    57        
    58 class ICertificateCourseAdd(ICertificateCourse):
    59     """A certificatecourse is a course referenced by a certificate, which
    60        provides some own attributes.
    61     """
    62     course = schema.Choice(
    63         title = u'Course to be referenced',
    64         source = CourseSource(),
    65         readonly = False,
    66         )
    67    
    68     level = schema.Int(
    69         title = u'Level of this course',
    70         required = True,
    71         default = 100,
    72         readonly = False,
    73         )   
    7457
    75     core_or_elective = schema.Bool(
    76         title = u'Is mandatory course (not elective)',
    77         required = True,
    78         default = True
    79         )       
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r5950 r5951  
    3333    WAeUPDisplayFormPage, NullValidator)
    3434from waeup.sirp.browser.interfaces import (
    35     IUniversity, IFacultyContainer, IFaculty, IDepartment, ICourse,
    36     ICertificate, ICertificateCourse, ICertificateCourseAdd)
     35    IUniversity, IFacultyContainer, IFaculty, IFacultyAdd,
     36    IDepartment, IDepartmentAdd, ICourse, ICourseAdd, ICertificate,
     37    ICertificateAdd, ICertificateCourse, ICertificateCourseAdd)
    3738from waeup.sirp.catalog import search_context
    3839from waeup.sirp.interfaces import(
     
    864865    label = ''
    865866    title = 'Add faculty'
    866     pnav = 1
    867    
    868     # We need a deepcopy here, because otherwise also all other
    869     # IFaculty forms would be affected.
    870     form_fields = copy.deepcopy(grok.AutoFields(IFaculty))
    871     form_fields.get('code').field.readonly = False   
     867    form_fields = grok.AutoFields(IFacultyAdd)
     868    pnav = 1
    872869
    873870    @grok.action('Add faculty')
     
    929926    title = 'Add department'
    930927    label = ''
    931     pnav = 1
    932    
    933     # We need a deepcopy here, because otherwise also all other
    934     # IDepartment forms would be affected.
    935     form_fields = copy.deepcopy(grok.AutoFields(IDepartment))
    936     form_fields.get('code').field.readonly = False
     928    form_fields = grok.AutoFields(IDepartmentAdd)
     929    pnav = 1
    937930   
    938931    @grok.action('Add department')
     
    10551048    grok.require('waeup.manageUniversity')
    10561049    title = u'Add course'
    1057     pnav = 1
    1058    
    1059     # We need a deepcopy here, because otherwise also all other
    1060     # ICourse forms would be affected.
    1061     form_fields = copy.deepcopy(grok.AutoFields(ICourse))
    1062     form_fields.get('code').field.readonly = False
    1063 
     1050    form_fields = grok.AutoFields(ICourseAdd)
     1051    pnav = 1
     1052   
    10641053    @grok.action('Add course')
    10651054    def addCourse(self, **data):
     
    10901079    grok.require('waeup.manageUniversity')
    10911080    title = u'Add certificate'
    1092     pnav = 1
    1093    
    1094     # We need a deepcopy here, because otherwise also all other
    1095     # ICertificate forms would be affected.
    1096     form_fields = copy.deepcopy(grok.AutoFields(ICertificate))
    1097     form_fields.get('code').field.readonly = False
     1081    form_fields = grok.AutoFields(ICertificateAdd)
     1082    pnav = 1
     1083   
    10981084       
    10991085    @grok.action('Add certificate')
  • main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py

    r5950 r5951  
    4949        required = True,
    5050        )
     51       
     52class IFacultyAdd(IFaculty):
     53    """Representation of a university faculty.
     54    """
     55    code = schema.TextLine(
     56        title = u'Code',
     57        description = u'Abbreviated code of the faculty',
     58        default = u'NA',
     59        required = True,
     60        readonly = False,
     61        )
     62                 
     63IFacultyAdd['code'].order =  IFaculty['code'].order           
    5164   
    5265class IFacultyContainer(IWAeUPContainer):
     
    8497    certificates = Attribute("A container for certificates.")
    8598
     99class IDepartmentAdd(IDepartment):
     100    """Representation of a university department.
     101    """
     102    code = schema.TextLine(
     103        title = u'Code',
     104        default = u'NA',
     105        description = u'Abbreviated code of the department',
     106        required = True,
     107        readonly = False,
     108        )
     109                 
     110IDepartmentAdd['code'].order =  IDepartment['code'].order         
    86111
    87112class ICourseContainer(IWAeUPContainer):
     
    132157        )
    133158
     159class ICourseAdd(ICourse):
     160    """Representation of a course.
     161    """
     162    code = schema.TextLine(
     163        title = u'Code',
     164        default = u'NA',
     165        description = u'Abbreviated code of the course',
     166        required = True,
     167        readonly = False,
     168        )
     169       
     170ICourseAdd['code'].order =  ICourse['code'].order         
    134171
    135172class ICertificate(IWAeUPObject):
     
    152189    title = schema.TextLine(
    153190        title = u'Title',
     191        default = u'Unnamed',
    154192        required = True,
    155193        )
     
    157195    study_mode = schema.TextLine(
    158196        title = u'Study Mode',
     197        default = u'ug_ft',
    159198        required = True,
    160199        )
     
    162201    start_level = schema.TextLine(
    163202        title = u'Start Level',
     203        default = u'100',
    164204        required = True,
    165205        )
     
    167207    end_level = schema.TextLine(
    168208        title = u'End Level',
     209        default = u'500',
    169210        required = True,
    170211        )
     
    172213    application_category = schema.TextLine(
    173214        title = u'Application Category',
     215        default = u'basic',
    174216        required = False,
    175217        )   
    176218
     219class ICertificateAdd(ICertificate):
     220    """Representation of a certificate.
     221    """
     222    code = schema.TextLine(
     223        title = u'Code',
     224        default = u'NA',
     225        description = u'Abbreviated code of the certificate.',
     226        required = True,
     227        readonly = False,
     228        )
     229       
     230ICertificateAdd['code'].order =  ICertificate['code'].order         
    177231   
    178232class ICertificateContainer(IWAeUPContainer):
     
    196250   
    197251    level = schema.Int(
    198         title = u'Level of this course',
     252        title = u'Level',
    199253        required = True,
    200254        default = 100,
     
    213267        This is needed for cataloging.
    214268        """
     269       
     270       
     271class ICertificateCourseAdd(ICertificateCourse):
     272    """A certificatecourse is a course referenced by a certificate, which
     273       provides some own attributes.
     274    """
     275    course = schema.Choice(
     276        title = u'Course to be referenced',
     277        source = CourseSource(),
     278        readonly = False,
     279        )
     280                 
     281ICertificateCourseAdd['course'].order =  ICertificateCourse['course'].order                 
Note: See TracChangeset for help on using the changeset viewer.