- Timestamp:
- 12/23/09 06:06:58 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
enpraxis.educommons/trunk/enpraxis/educommons/portlet/coursebuilderform.py
r506 r632 25 25 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm 26 26 from plone.app.form.base import AddForm 27 from plone.app.form.validators import null_validator28 27 from plone.app.controlpanel.widgets import MultiCheckBoxVocabularyWidget 29 from zope.formlib.form import FormFields, action , applyChanges28 from zope.formlib.form import FormFields, action 30 29 from zope.app.form.browser import DropdownWidget, FileWidget, RadioWidget 31 30 from zope.app.form.browser.widget import renderElement 32 31 from zope.app.form.interfaces import WidgetInputError 33 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile34 32 from Products.CMFPlone import PloneMessageFactory 35 33 from enpraxis.educommons import eduCommonsMessageFactory as _ 36 from zope.app.i18n import ZopeMessageFactory as __37 34 from Products.CMFCore.utils import getToolByName 38 35 from collective.imstransport.browser.importform import ZipFileLine … … 51 48 return widget 52 49 50 #def schoolsvocab(context): 51 # """ Get the list of current divisions and return it as a vocabulary. """ 52 # path = {'query':('/'), } 53 # brains = context.portal_catalog.searchResults(path=path, Type='School', sort_on='sortable_title') 54 # terms = [SimpleTerm(x.getId, title=x.Title.decode('utf-8') ) for x in brains] 55 56 # return SimpleVocabulary(terms) 57 53 58 def divisionsvocab(context): 54 59 """ Get the list of current divisions and return it as a vocabulary. """ 55 60 path = {'query':('/'), } 56 61 brains = context.portal_catalog.searchResults(path=path, Type='Division', sort_on='sortable_title') 57 terms = [SimpleTerm(x.getId, title=x.Title.decode('utf-8') ) for x in brains] 62 terms = [] 63 for brain in brains: 64 if brain.getObject().aq_parent.portal_type == 'School': 65 title = '%s : %s' % (brain.getObject().aq_parent.Title().decode('utf-8'), brain.Title.decode('utf-8')) 66 else: 67 title = brain.Title.decode('utf-8') 68 terms += [SimpleTerm(brain.getId, title=title),] 69 #terms = [SimpleTerm(x.getId, title=x.Title.decode('utf-8') ) for x in brains] 70 58 71 return SimpleVocabulary(terms) 59 72 … … 122 135 value = '' 123 136 contents = [] 124 have_results = False125 137 126 138 # Render the Drop Down … … 133 145 contents.append(self._div('value', renderElement('input', 134 146 type='text', 135 name=' form.newdivision',136 id=' form.division.textfield')))147 name='.new'.join(self.name.split(',')), 148 id='%s.textfield' % self.name))) 137 149 138 150 contents.append(self._emptyMarker()) … … 148 160 vocabulary='eduCommons.divisionsvocab') 149 161 150 coursename = TextLine(title=PloneMessageFactory(u'Title') ) 162 # school = Choice(title=_(u'School'), 163 # required=False, 164 # vocabulary='eduCommons.schoolsvocab') 165 166 167 coursename = TextLine(title=PloneMessageFactory(u'Course Title') ) 151 168 152 169 courseid = TextLine(title=_(u'Course ID'), … … 181 198 form_fields = FormFields(ICourseBuilderForm) 182 199 form_fields['division'].custom_widget = EitherOrWidget 200 # form_fields['school'].custom_widget = EitherOrWidget 183 201 form_fields['templates'].custom_widget = MultiPreSelectCheckBoxVocabularyWidget 184 202 form_fields['filename'].custom_widget = FileWidget … … 220 238 divname = self.request.form['form.division'] 221 239 newdivision = self.request.form['form.newdivision'] 240 222 241 if newdivision: 223 242 portal = self.context.portal_url
