Changeset 3436


Ignore:
Timestamp:
15 Apr 2008, 15:26:29 (17 years ago)
Author:
joachim
Message:

add application_category to Certificates
fill this attribute with fillApplicationCategory from cos_xxxx vocabularies
add new widget Application Corse Widget
use this widget in all application_xxx layouts for coursexxx

Location:
WAeUP_SRP
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Widgets.py

    r3413 r3436  
    1313from Products.CPSSchemas.BasicWidgets import renderHtmlTag,CPSSelectWidget, CPSStringWidget
    1414from Products.CPSSchemas.ExtendedWidgets import CPSDateTimeWidget
     15from Products.CPSSchemas.Vocabulary import Vocabulary
    1516from Products.CPSSchemas.Widget import widgetRegistry
    1617from Products.CPSUtil.file import PersistableFileUpload
     
    765766
    766767widgetRegistry.register(StudyCourseWidget)
     768###)
     769
     770class VocabularyOnTheFly: ###(
     771    def __init__(self, tuples):
     772        """a nonpersistent vocabulary (copy from CPSSchemas.Vocabulary.Vocabulary).
     773        Allowed parameter syntaxes is:
     774          - Vocabulary((('foo', "Foo", 'label_foo'), ('bar', "Bar", 'label_bar')))
     775            Same as first with message ids (msgids) that can be used for i18n
     776        """
     777        l = []
     778        d = {}
     779        m = {}
     780        # We suppose that initial vocabulary is sorted
     781        # Vocabulary((('foo', "Foo", 'label_foo'), ('bar', "Bar", 'label_bar')))
     782        for k, v, msgid in tuples:
     783            l.append(k)
     784            d[k] = v
     785            m[k] = msgid
     786        self._list = l
     787        self._dict = d
     788        self._msgids = m
     789   
     790    def __getitem__(self, key):
     791        """Get a label for a key."""
     792        return self._dict[key]
     793
     794    def get(self, key, default=None):
     795        """Get a label for a key, default to None."""
     796        try:
     797            v = self._dict.get(key, default)
     798        except TypeError:
     799            # XXX temporary fix, don't know why sometime rendering try to do
     800            # get([]) that returning a typeError
     801            return ''
     802        return v
     803
     804    def getMsgid(self, key, default=None):
     805        """Get a msgid for a key, default to None."""
     806        return self._msgids.get(key, default)
     807
     808    def has_key(self, key):
     809        """Test if a key is present."""
     810        return self._dict.has_key(key)
     811
     812    def keys(self):
     813        """Get the ordered list of keys."""
     814        return self._list[:]
     815
     816    def items(self):
     817        """Get the ordered list of (key, value)."""
     818        return [(key, self._dict.get(key)) for key in self._list]
     819
     820    def values(self):
     821        """Get the ordered list of values."""
     822        return [self._dict.get(key) for key in self._list]
     823
     824    def keysSortedBy(self, crit='id'):
     825        """Return a keys list sorted on a criterium
     826
     827        Crit is one of 'id', 'label' or 'i18n'.
     828        """
     829
     830        if crit == 'label':
     831            l = [(x[1], x[0]) for x in self.items()]
     832            l.sort()
     833            return [x[1] for x in l]
     834        elif crit == 'i18n':
     835            portal = getToolByName(self, 'portal_url').getPortalObject()
     836            cpsmcat = portal.translation_service
     837            l = [(cpsmcat(self.getMsgid(key)).encode('ISO-8859-15', 'ignore'),
     838                  key) for key in self.keys()]
     839            l.sort()
     840            return [x[1] for x in l]
     841        else:
     842            return self.keys()
     843###)
     844
     845class ApplicationCourseWidget(CPSSelectWidget): ###(
     846    """ ApplicationCourse Widget"""
     847    meta_type = "Application Course Widget"
     848
     849    def _getVocabulary(self,datastructure=None):
     850        if self.REQUEST.traverse_subpath:
     851            screening_type = self.REQUEST.traverse_subpath[0].upper()
     852        else:
     853            screening_type = 'ALL'
     854        if screening_type in ("ALL","CEST","SANDWICH"):
     855            application_category = screening_type
     856        else:
     857            application_category = "BASIC"
     858        if not hasattr(self,'_v_certificates_docs'):
     859            res = self.portal_catalog_real.search({'meta_type': "Certificate"})
     860            d = {}
     861            for cert in res:
     862                c = cert.getObject().getContent()
     863                if getattr(c,'application_category',''):
     864                    d[cert.getId] = c
     865            self._v_certificates_docs = d
     866        l  = []
     867        for k,d in self._v_certificates_docs.items():
     868            if application_category == "ALL":
     869                l  += (k,self._v_certificates_docs[k].title,k),
     870            else:
     871                if getattr(d,'application_category','') == application_category:
     872                    l  += (k,self._v_certificates_docs[k].title,k),
     873        #import ipdb;ipdb.set_trace()
     874        return VocabularyOnTheFly(l)
     875                                       
     876InitializeClass(ApplicationCourseWidget)
     877
     878widgetRegistry.register(ApplicationCourseWidget)
    767879###)
    768880
  • WAeUP_SRP/uniben/profiles/default/layouts/application_cest.xml

    r2984 r3436  
    457457  <property name="vocabulary">application_status</property>
    458458 </widget>
    459   <widget name="course1" meta_type="Select Widget">
     459  <widget name="course1" meta_type="Application Course Widget">
    460460    <property name="title">1st Choice Course of Study</property>
    461461    <property name="fields">
     
    478478    <property name="css_class_expr">string:row</property>
    479479  </widget>
    480   <widget name="course2" meta_type="Select Widget">
     480  <widget name="course2" meta_type="Application Course Widget">
    481481    <property name="title">2nd Choice Course of Study</property>
    482482    <property name="fields">
     
    499499    <property name="css_class_expr">string:row</property>
    500500  </widget>
    501   <widget name="course3" meta_type="Select Widget">
     501  <widget name="course3" meta_type="Application Course Widget">
    502502    <property name="title">3rd Choice Course of Study</property>
    503503    <property name="fields">
     
    520520    <property name="css_class_expr">string:row</property>
    521521  </widget>
    522   <widget name="course_admitted" meta_type="Select Widget">
     522  <widget name="course_admitted" meta_type="Application Course Widget">
    523523    <property name="title">Admitted Course of Study</property>
    524524    <property name="fields">
  • WAeUP_SRP/uniben/profiles/default/layouts/application_manage.xml

    r3426 r3436  
    629629  <property name="vocabulary">application_status</property>
    630630 </widget>
    631   <widget name="course1" meta_type="Select Widget">
     631  <widget name="course1" meta_type="Application Course Widget">
    632632    <property name="title">1st Choice Course of Study</property>
    633633    <property name="fields">
     
    649649    <property name="css_class_expr">string:row</property>
    650650  </widget>
    651   <widget name="course2" meta_type="Select Widget">
     651  <widget name="course2" meta_type="Application Course Widget">
    652652    <property name="title">2nd Choice Course of Study</property>
    653653    <property name="fields">
     
    670670    <property name="css_class_expr">string:row</property>
    671671  </widget>
    672   <widget name="course3" meta_type="Select Widget">
     672  <widget name="course3" meta_type="Application Course Widget">
    673673    <property name="title">3rd Choice Course of Study</property>
    674674    <property name="fields">
     
    692692  </widget>
    693693
    694   <widget name="course_admitted" meta_type="Select Widget">
     694  <widget name="course_admitted" meta_type="Application Course Widget">
    695695    <property name="title">Admitted Course of Study</property>
    696696    <property name="fields">
  • WAeUP_SRP/uniben/profiles/default/layouts/application_pce.xml

    r3019 r3436  
    4545  <property name="time_setting">False</property>
    4646 </widget>
    47  <widget name="course1" meta_type="Select Widget">
     47 <widget name="course1" meta_type="Application Course Widget">
    4848  <property name="title">1st Choice Course of Study</property>
    4949  <property name="fields">
     
    6262  <property name="vocabulary">cos</property>
    6363 </widget>
    64  <widget name="course2" meta_type="Select Widget">
     64 <widget name="course2" meta_type="Application Course Widget">
    6565  <property name="title">2nd Choice Course of Study</property>
    6666  <property name="fields">
     
    7777  <property name="vocabulary">cos</property>
    7878 </widget>
    79  <widget name="course3" meta_type="Select Widget">
     79 <widget name="course3" meta_type="Application Course Widget">
    8080  <property name="title">3rd Choice Course of Study</property>
    8181  <property name="fields">
     
    9393  <property name="sorted">True</property>
    9494 </widget>
    95  <widget name="course_admitted" meta_type="Select Widget">
     95 <widget name="course_admitted" meta_type="Application Course Widget">
    9696  <property name="title">Admitted Course of Study</property>
    9797  <property name="fields">
  • WAeUP_SRP/uniben/profiles/default/layouts/application_pde.xml

    r2984 r3436  
    630630  <property name="vocabulary">application_status</property>
    631631 </widget>
    632   <widget name="course1" meta_type="Select Widget">
     632  <widget name="course1" meta_type="Application Course Widget">
    633633    <property name="title">1st Choice Course of Study</property>
    634634    <property name="fields">
     
    652652    <property name="css_class_expr">string:row</property>
    653653  </widget>
    654   <widget name="course2" meta_type="Select Widget">
     654  <widget name="course2" meta_type="Application Course Widget">
    655655    <property name="title">2nd Choice Course of Study</property>
    656656    <property name="fields">
     
    673673    <property name="css_class_expr">string:row</property>
    674674  </widget>
    675   <widget name="course3" meta_type="Select Widget">
     675  <widget name="course3" meta_type="Application Course Widget">
    676676    <property name="title">3rd Choice Course of Study</property>
    677677    <property name="fields">
     
    694694    <property name="css_class_expr">string:row</property>
    695695  </widget>
    696   <widget name="course_admitted" meta_type="Select Widget">
     696  <widget name="course_admitted" meta_type="Application Course Widget">
    697697    <property name="title">Admitted Course of Study</property>
    698698    <property name="fields">
  • WAeUP_SRP/uniben/profiles/default/layouts/application_prence.xml

    r2984 r3436  
    578578  <property name="vocabulary">application_status</property>
    579579 </widget>
    580   <widget name="course1" meta_type="Select Widget">
     580  <widget name="course1" meta_type="Application Course Widget">
    581581    <property name="title">1st Choice Course of Study</property>
    582582    <property name="fields">
     
    599599    <property name="css_class_expr">string:row</property>
    600600  </widget>
    601   <widget name="course2" meta_type="Select Widget">
     601  <widget name="course2" meta_type="Application Course Widget">
    602602    <property name="title">2nd Choice Course of Study</property>
    603603    <property name="fields">
     
    620620    <property name="css_class_expr">string:row</property>
    621621  </widget>
    622   <widget name="course3" meta_type="Select Widget">
     622  <widget name="course3" meta_type="Application Course Widget">
    623623    <property name="title">3rd Choice Course of Study</property>
    624624    <property name="fields">
     
    641641    <property name="css_class_expr">string:row</property>
    642642  </widget>
    643   <widget name="course_admitted" meta_type="Select Widget">
     643  <widget name="course_admitted" meta_type="Application Course Widget">
    644644    <property name="title">Admitted Course of Study</property>
    645645    <property name="fields">
  • WAeUP_SRP/uniben/profiles/default/layouts/application_pume.xml

    r2984 r3436  
    549549  <property name="vocabulary">application_status</property>
    550550 </widget>
    551   <widget name="course1" meta_type="Select Widget">
     551  <widget name="course1" meta_type="Application Course Widget">
    552552    <property name="title">1st Choice Course of Study</property>
    553553    <property name="fields">
     
    570570    <property name="css_class_expr">string:row</property>
    571571  </widget>
    572   <widget name="course2" meta_type="Select Widget">
     572  <widget name="course2" meta_type="Application Course Widget">
    573573    <property name="title">2nd Choice Course of Study</property>
    574574    <property name="fields">
     
    591591    <property name="css_class_expr">string:row</property>
    592592  </widget>
    593   <widget name="course3" meta_type="Select Widget">
     593  <widget name="course3" meta_type="Application Course Widget">
    594594    <property name="title">3rd Choice Course of Study</property>
    595595    <property name="fields">
     
    613613  </widget>
    614614
    615   <widget name="course_admitted" meta_type="Select Widget">
     615  <widget name="course_admitted" meta_type="Application Course Widget">
    616616    <property name="title">Admitted Course of Study</property>
    617617    <property name="fields">
  • WAeUP_SRP/uniben/profiles/default/layouts/application_sandwich.xml

    r3244 r3436  
    457457  <property name="vocabulary">application_status</property>
    458458 </widget>
    459   <widget name="course1" meta_type="Select Widget">
     459  <widget name="course1" meta_type="Application Course Widget">
    460460    <property name="title">1st Choice Course of Study</property>
    461461    <property name="fields">
     
    478478    <property name="css_class_expr">string:row</property>
    479479  </widget>
    480   <widget name="course2" meta_type="Select Widget">
     480  <widget name="course2" meta_type="Application Course Widget">
    481481    <property name="title">2nd Choice Course of Study</property>
    482482    <property name="fields">
     
    499499    <property name="css_class_expr">string:row</property>
    500500  </widget>
    501   <widget name="course3" meta_type="Select Widget">
     501  <widget name="course3" meta_type="Application Course Widget">
    502502    <property name="title">3rd Choice Course of Study</property>
    503503    <property name="fields">
     
    520520    <property name="css_class_expr">string:row</property>
    521521  </widget>
    522   <widget name="course_admitted" meta_type="Select Widget">
     522  <widget name="course_admitted" meta_type="Application Course Widget">
    523523    <property name="title">Admitted Course of Study</property>
    524524    <property name="fields">
  • WAeUP_SRP/uniben/profiles/default/layouts/certificate.xml

    r3333 r3436  
    6666  <property name="hidden_readonly_layout_modes"/>
    6767 </widget>
     68 <widget name="application_category" meta_type="Select Widget">
     69  <property name="title">Application Category</property>
     70  <property name="fields">
     71   <element value="application_category"/>
     72  </property>
     73  <property name="label">Application Category</property>
     74  <property name="label_edit">Application Category</property>
     75  <property name="readonly_layout_modes"/>
     76  <property name="hidden_layout_modes"/>
     77  <property name="hidden_readonly_layout_modes"/>
     78  <property name="vocabulary">application_categories</property>
     79 </widget>
    6880 <widget name="end_level" meta_type="Select Widget">
    6981  <property name="title">End Level</property>
     
    256268  </row>
    257269  <row>
     270   <cell name="application_category"/>
     271  </row>
     272  <row>
    258273   <cell name="study_mode"/>
    259274  </row> 
  • WAeUP_SRP/uniben/profiles/default/schemas/certificate.xml

    r3333 r3436  
    55 <field name="admin_status" meta_type="CPS String Field"/>
    66 <field name="category" meta_type="CPS String Field"/>
     7 <field name="application_category" meta_type="CPS String Field"/>
    78 <field name="code" meta_type="CPS String Field">
    89  <property name="is_searchabletext">False</property>
  • WAeUP_SRP/uniben/profiles/default/vocabularies.xml

    r3196 r3436  
    55 <object name="acco_hall_beds" meta_type="CPS Method Vocabulary"/>
    66 <object name="acco_hall_reserved_rooms" meta_type="CPS Method Vocabulary"/>
     7 <object name="application_categories" meta_type="CPS Vocabulary"/>
    78 <object name="levels" meta_type="CPS Vocabulary"/>
    89 <object name="student_levels" meta_type="CPS Method Vocabulary"/>
Note: See TracChangeset for help on using the changeset viewer.