Changeset 3436
- Timestamp:
- 15 Apr 2008, 15:26:29 (17 years ago)
- Location:
- WAeUP_SRP
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/Widgets.py
r3413 r3436 13 13 from Products.CPSSchemas.BasicWidgets import renderHtmlTag,CPSSelectWidget, CPSStringWidget 14 14 from Products.CPSSchemas.ExtendedWidgets import CPSDateTimeWidget 15 from Products.CPSSchemas.Vocabulary import Vocabulary 15 16 from Products.CPSSchemas.Widget import widgetRegistry 16 17 from Products.CPSUtil.file import PersistableFileUpload … … 765 766 766 767 widgetRegistry.register(StudyCourseWidget) 768 ###) 769 770 class 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 845 class 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 876 InitializeClass(ApplicationCourseWidget) 877 878 widgetRegistry.register(ApplicationCourseWidget) 767 879 ###) 768 880 -
WAeUP_SRP/uniben/profiles/default/layouts/application_cest.xml
r2984 r3436 457 457 <property name="vocabulary">application_status</property> 458 458 </widget> 459 <widget name="course1" meta_type=" SelectWidget">459 <widget name="course1" meta_type="Application Course Widget"> 460 460 <property name="title">1st Choice Course of Study</property> 461 461 <property name="fields"> … … 478 478 <property name="css_class_expr">string:row</property> 479 479 </widget> 480 <widget name="course2" meta_type=" SelectWidget">480 <widget name="course2" meta_type="Application Course Widget"> 481 481 <property name="title">2nd Choice Course of Study</property> 482 482 <property name="fields"> … … 499 499 <property name="css_class_expr">string:row</property> 500 500 </widget> 501 <widget name="course3" meta_type=" SelectWidget">501 <widget name="course3" meta_type="Application Course Widget"> 502 502 <property name="title">3rd Choice Course of Study</property> 503 503 <property name="fields"> … … 520 520 <property name="css_class_expr">string:row</property> 521 521 </widget> 522 <widget name="course_admitted" meta_type=" SelectWidget">522 <widget name="course_admitted" meta_type="Application Course Widget"> 523 523 <property name="title">Admitted Course of Study</property> 524 524 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_manage.xml
r3426 r3436 629 629 <property name="vocabulary">application_status</property> 630 630 </widget> 631 <widget name="course1" meta_type=" SelectWidget">631 <widget name="course1" meta_type="Application Course Widget"> 632 632 <property name="title">1st Choice Course of Study</property> 633 633 <property name="fields"> … … 649 649 <property name="css_class_expr">string:row</property> 650 650 </widget> 651 <widget name="course2" meta_type=" SelectWidget">651 <widget name="course2" meta_type="Application Course Widget"> 652 652 <property name="title">2nd Choice Course of Study</property> 653 653 <property name="fields"> … … 670 670 <property name="css_class_expr">string:row</property> 671 671 </widget> 672 <widget name="course3" meta_type=" SelectWidget">672 <widget name="course3" meta_type="Application Course Widget"> 673 673 <property name="title">3rd Choice Course of Study</property> 674 674 <property name="fields"> … … 692 692 </widget> 693 693 694 <widget name="course_admitted" meta_type=" SelectWidget">694 <widget name="course_admitted" meta_type="Application Course Widget"> 695 695 <property name="title">Admitted Course of Study</property> 696 696 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_pce.xml
r3019 r3436 45 45 <property name="time_setting">False</property> 46 46 </widget> 47 <widget name="course1" meta_type=" SelectWidget">47 <widget name="course1" meta_type="Application Course Widget"> 48 48 <property name="title">1st Choice Course of Study</property> 49 49 <property name="fields"> … … 62 62 <property name="vocabulary">cos</property> 63 63 </widget> 64 <widget name="course2" meta_type=" SelectWidget">64 <widget name="course2" meta_type="Application Course Widget"> 65 65 <property name="title">2nd Choice Course of Study</property> 66 66 <property name="fields"> … … 77 77 <property name="vocabulary">cos</property> 78 78 </widget> 79 <widget name="course3" meta_type=" SelectWidget">79 <widget name="course3" meta_type="Application Course Widget"> 80 80 <property name="title">3rd Choice Course of Study</property> 81 81 <property name="fields"> … … 93 93 <property name="sorted">True</property> 94 94 </widget> 95 <widget name="course_admitted" meta_type=" SelectWidget">95 <widget name="course_admitted" meta_type="Application Course Widget"> 96 96 <property name="title">Admitted Course of Study</property> 97 97 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_pde.xml
r2984 r3436 630 630 <property name="vocabulary">application_status</property> 631 631 </widget> 632 <widget name="course1" meta_type=" SelectWidget">632 <widget name="course1" meta_type="Application Course Widget"> 633 633 <property name="title">1st Choice Course of Study</property> 634 634 <property name="fields"> … … 652 652 <property name="css_class_expr">string:row</property> 653 653 </widget> 654 <widget name="course2" meta_type=" SelectWidget">654 <widget name="course2" meta_type="Application Course Widget"> 655 655 <property name="title">2nd Choice Course of Study</property> 656 656 <property name="fields"> … … 673 673 <property name="css_class_expr">string:row</property> 674 674 </widget> 675 <widget name="course3" meta_type=" SelectWidget">675 <widget name="course3" meta_type="Application Course Widget"> 676 676 <property name="title">3rd Choice Course of Study</property> 677 677 <property name="fields"> … … 694 694 <property name="css_class_expr">string:row</property> 695 695 </widget> 696 <widget name="course_admitted" meta_type=" SelectWidget">696 <widget name="course_admitted" meta_type="Application Course Widget"> 697 697 <property name="title">Admitted Course of Study</property> 698 698 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_prence.xml
r2984 r3436 578 578 <property name="vocabulary">application_status</property> 579 579 </widget> 580 <widget name="course1" meta_type=" SelectWidget">580 <widget name="course1" meta_type="Application Course Widget"> 581 581 <property name="title">1st Choice Course of Study</property> 582 582 <property name="fields"> … … 599 599 <property name="css_class_expr">string:row</property> 600 600 </widget> 601 <widget name="course2" meta_type=" SelectWidget">601 <widget name="course2" meta_type="Application Course Widget"> 602 602 <property name="title">2nd Choice Course of Study</property> 603 603 <property name="fields"> … … 620 620 <property name="css_class_expr">string:row</property> 621 621 </widget> 622 <widget name="course3" meta_type=" SelectWidget">622 <widget name="course3" meta_type="Application Course Widget"> 623 623 <property name="title">3rd Choice Course of Study</property> 624 624 <property name="fields"> … … 641 641 <property name="css_class_expr">string:row</property> 642 642 </widget> 643 <widget name="course_admitted" meta_type=" SelectWidget">643 <widget name="course_admitted" meta_type="Application Course Widget"> 644 644 <property name="title">Admitted Course of Study</property> 645 645 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_pume.xml
r2984 r3436 549 549 <property name="vocabulary">application_status</property> 550 550 </widget> 551 <widget name="course1" meta_type=" SelectWidget">551 <widget name="course1" meta_type="Application Course Widget"> 552 552 <property name="title">1st Choice Course of Study</property> 553 553 <property name="fields"> … … 570 570 <property name="css_class_expr">string:row</property> 571 571 </widget> 572 <widget name="course2" meta_type=" SelectWidget">572 <widget name="course2" meta_type="Application Course Widget"> 573 573 <property name="title">2nd Choice Course of Study</property> 574 574 <property name="fields"> … … 591 591 <property name="css_class_expr">string:row</property> 592 592 </widget> 593 <widget name="course3" meta_type=" SelectWidget">593 <widget name="course3" meta_type="Application Course Widget"> 594 594 <property name="title">3rd Choice Course of Study</property> 595 595 <property name="fields"> … … 613 613 </widget> 614 614 615 <widget name="course_admitted" meta_type=" SelectWidget">615 <widget name="course_admitted" meta_type="Application Course Widget"> 616 616 <property name="title">Admitted Course of Study</property> 617 617 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_sandwich.xml
r3244 r3436 457 457 <property name="vocabulary">application_status</property> 458 458 </widget> 459 <widget name="course1" meta_type=" SelectWidget">459 <widget name="course1" meta_type="Application Course Widget"> 460 460 <property name="title">1st Choice Course of Study</property> 461 461 <property name="fields"> … … 478 478 <property name="css_class_expr">string:row</property> 479 479 </widget> 480 <widget name="course2" meta_type=" SelectWidget">480 <widget name="course2" meta_type="Application Course Widget"> 481 481 <property name="title">2nd Choice Course of Study</property> 482 482 <property name="fields"> … … 499 499 <property name="css_class_expr">string:row</property> 500 500 </widget> 501 <widget name="course3" meta_type=" SelectWidget">501 <widget name="course3" meta_type="Application Course Widget"> 502 502 <property name="title">3rd Choice Course of Study</property> 503 503 <property name="fields"> … … 520 520 <property name="css_class_expr">string:row</property> 521 521 </widget> 522 <widget name="course_admitted" meta_type=" SelectWidget">522 <widget name="course_admitted" meta_type="Application Course Widget"> 523 523 <property name="title">Admitted Course of Study</property> 524 524 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/certificate.xml
r3333 r3436 66 66 <property name="hidden_readonly_layout_modes"/> 67 67 </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> 68 80 <widget name="end_level" meta_type="Select Widget"> 69 81 <property name="title">End Level</property> … … 256 268 </row> 257 269 <row> 270 <cell name="application_category"/> 271 </row> 272 <row> 258 273 <cell name="study_mode"/> 259 274 </row> -
WAeUP_SRP/uniben/profiles/default/schemas/certificate.xml
r3333 r3436 5 5 <field name="admin_status" meta_type="CPS String Field"/> 6 6 <field name="category" meta_type="CPS String Field"/> 7 <field name="application_category" meta_type="CPS String Field"/> 7 8 <field name="code" meta_type="CPS String Field"> 8 9 <property name="is_searchabletext">False</property> -
WAeUP_SRP/uniben/profiles/default/vocabularies.xml
r3196 r3436 5 5 <object name="acco_hall_beds" meta_type="CPS Method Vocabulary"/> 6 6 <object name="acco_hall_reserved_rooms" meta_type="CPS Method Vocabulary"/> 7 <object name="application_categories" meta_type="CPS Vocabulary"/> 7 8 <object name="levels" meta_type="CPS Vocabulary"/> 8 9 <object name="student_levels" meta_type="CPS Method Vocabulary"/>
Note: See TracChangeset for help on using the changeset viewer.