Show
Ignore:
Timestamp:
12/23/09 06:06:58 (2 years ago)
Author:
dray
Message:

freeversity changes, initial work toward deprecating OpenOCW

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • enpraxis.educommons/trunk/enpraxis/educommons/portlet/coursebuilderform.py

    r506 r632  
    2525from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm 
    2626from plone.app.form.base import AddForm 
    27 from plone.app.form.validators import null_validator 
    2827from plone.app.controlpanel.widgets import MultiCheckBoxVocabularyWidget 
    29 from zope.formlib.form import FormFields, action, applyChanges 
     28from zope.formlib.form import FormFields, action 
    3029from zope.app.form.browser import DropdownWidget, FileWidget, RadioWidget 
    3130from zope.app.form.browser.widget import renderElement 
    3231from zope.app.form.interfaces import WidgetInputError 
    33 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile 
    3432from Products.CMFPlone import PloneMessageFactory 
    3533from enpraxis.educommons import eduCommonsMessageFactory as _ 
    36 from zope.app.i18n import ZopeMessageFactory as __ 
    3734from Products.CMFCore.utils import getToolByName 
    3835from collective.imstransport.browser.importform import ZipFileLine 
     
    5148    return widget 
    5249 
     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 
    5358def divisionsvocab(context): 
    5459    """ Get the list of current divisions and return it as a vocabulary. """ 
    5560    path = {'query':('/'), } 
    5661    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 
    5871    return SimpleVocabulary(terms) 
    5972 
     
    122135        value = '' 
    123136        contents = [] 
    124         have_results = False 
    125137 
    126138        # Render the Drop Down 
     
    133145        contents.append(self._div('value', renderElement('input', 
    134146                                                         type='text', 
    135                                                          name='form.newdivision', 
    136                                                          id='form.division.textfield'))) 
     147                                                         name='.new'.join(self.name.split(',')), 
     148                                                         id='%s.textfield' % self.name))) 
    137149                                                       
    138150        contents.append(self._emptyMarker()) 
     
    148160                      vocabulary='eduCommons.divisionsvocab') 
    149161 
    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') ) 
    151168     
    152169    courseid = TextLine(title=_(u'Course ID'), 
     
    181198    form_fields = FormFields(ICourseBuilderForm) 
    182199    form_fields['division'].custom_widget = EitherOrWidget 
     200#    form_fields['school'].custom_widget = EitherOrWidget         
    183201    form_fields['templates'].custom_widget = MultiPreSelectCheckBoxVocabularyWidget 
    184202    form_fields['filename'].custom_widget = FileWidget 
     
    220238        divname = self.request.form['form.division'] 
    221239        newdivision = self.request.form['form.newdivision'] 
     240 
    222241        if newdivision: 
    223242            portal = self.context.portal_url