Example #1
0
 def setUpWidgets(self, ignore_request=False):
     # First part is copied from zope.formlib.form.EditForm licensed under
     # the ZPL 2.1
     self.adapters = {}
     # In order to support fieldsets, we need to setup the widgets on all
     # the fieldsets as well.
     if self.is_fieldsets():
         self.widgets = None
         for fieldset in self.form_fields.fieldsets:
             fieldset.widgets = form.setUpEditWidgets(
                 fieldset,
                 self.prefix,
                 self.context,
                 self.request,
                 adapters=self.adapters,
                 ignore_request=ignore_request)
             if self.widgets is None:
                 self.widgets = fieldset.widgets
             else:
                 self.widgets += fieldset.widgets
     else:
         self.widgets = form.setUpEditWidgets(self.form_fields,
                                              self.prefix,
                                              self.context,
                                              self.request,
                                              adapters=self.adapters,
                                              ignore_request=ignore_request)
Example #2
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         session = Session()
         trusted = removeSecurityProxy(self.context)
         sitting = session.query(domain.GroupSitting) \
                         .options( eagerload("hansard"),
                         eagerload("hansard.media_paths")).get(trusted.sitting_id) 
         if sitting.hansard.media_paths is not None:
             web_optimised_video_path = sitting.hansard. \
                                 media_paths.web_optimised_video_path
             audio_only_path = sitting.hansard. \
                                     media_paths.audio_only_path
             high_quality_video_path = sitting.hansard. \
                                     media_paths.high_quality_video_path
         else:
             web_optimised_video_path = None
             audio_only_path = None
             high_quality_video_path = None
         
     self.adapters = {
         self.IEditMediaPathForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
         adapters=self.adapters, ignore_request=ignore_request)
Example #3
0
 def setUpWidgets( self, ignore_request=False ):
     self.adapters = { self.model_schema : self.getValue() }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
         adapters=self.adapters, for_display=True,
         ignore_request=ignore_request
         )
Example #4
0
    def _extractDataManagers(self):
        # we extract object values from the request for conveinent use by any
        # step.
        data_adapters = {}
        fields = form.Fields()
        for step in self.controller.getTraversedFormSteps():
            # call processInputs to convert request.form to unicode
            processInputs(step.request)
            # Five only convert request.form to unicode, but (some) formlib
            # widgets use request so we need to get unicode values from
            # request.form and copy them to request
            for key in step.request.form.keys():
                step.request[key] = step.request.form[key]
            if not interfaces.IWizardFormStep.providedBy(step):
                continue
            data_adapters.update(step.getSchemaAdapters())

            widgets = form.setUpEditWidgets(
                step.form_fields,
                step.prefix,
                step.context,
                step.request,
                adapters=data_adapters,
                ignore_request=False
                )
            fields += step.form_fields
            data = {}
            form.getWidgetsData(widgets, step.prefix, data)

            # extract the form data to the adapters actualize
            # their state.
            self._restoreAdapterValues(data, data_adapters)

        return data_adapters, fields
Example #5
0
 def setUpWidgets(self, ignore_request=False):
     self.adapters = {}
     wvconfig = IWeblogConfiguration(self.context)
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, wvconfig, self.request,
         adapters=self.adapters, ignore_request=ignore_request
         )
Example #6
0
 def setUpWidgets(self, ignore_request=False):
     # We setup the add form like an edit form, in order to read
     # the default values provided in the settings.
     self.adapters = {}
     self.widgets = setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
         adapters=self.adapters, ignore_request=ignore_request)
Example #7
0
 def setUpWidgets(self, ignore_request=False):
     self.adapters = {}
     self.widgets = setUpEditWidgets(
         self.form_fields, self.prefix, self.request.principal,
         self.request, adapters=self.adapters,
         ignore_request=ignore_request
         )
Example #8
0
    def setUpWidgets(self, ignore_request=False):
        class context:
            ids = None
            event_pid = None
            short_name = None
            start_date = None
            end_date = None
            location = None
            language = None
            venue = None
            rec_type = None
            event_length = None
            nativeeditor_status = None
            activity_type = None
            meeting_type = None
            convocation_type = None

        context.__parent__ = self.context
        self.adapters = {interfaces.IDhtmlxCalendarSittingsEditForm: context}
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             "",
                                             self.context,
                                             self.request,
                                             adapters=self.adapters,
                                             ignore_request=ignore_request)
Example #9
0
    def setUpWidgets(self, ignore_request=False):
        self.adapters = self.adapters is not None and self.adapters or {}

        # grab all the adapters and fields from the entire wizard form
        # sequence (till the current step)
        adapters = self.wizard.data_manager.adapters
        fields = self.wizard.data_manager.fields

        # display widgets for bill/ship address
        bill_ship_fields = []
        form_schemas = component.getUtility(interfaces.IFormSchemas)
        for i in (form_schemas.getInterface('billing_address'),
                  form_schemas.getInterface('shipping_address')):
            bill_ship_fields.append(
                fields.select(*schema.getFieldNamesInOrder(i)))
        # make copies of custom widgets.. (typically for edit, we want display)
        bill_ship_fields = sanitize_custom_widgets(
            reduce(operator.__add__, bill_ship_fields))

        self.widgets = form.setUpEditWidgets(bill_ship_fields,
                                             self.prefix,
                                             self.context,
                                             self.request,
                                             adapters=adapters,
                                             for_display=True,
                                             ignore_request=ignore_request)
Example #10
0
 def setUpWidgets( self, ignore_request=False ):
     self.adapters = self.adapters or {}
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
         adapters=self.adapters, for_display=True,
         ignore_request=ignore_request
         )
Example #11
0
    def setUpWidgets(self, ignore_request=False):
        class context:
            session = Session()
            trusted = removeSecurityProxy(self.context)
            sitting = session.query(domain.GroupSitting) \
                            .options( eagerload("hansard"),
                            eagerload("hansard.media_paths")).get(trusted.sitting_id)
            if sitting.hansard.media_paths is not None:
                web_optimised_video_path = sitting.hansard. \
                                    media_paths.web_optimised_video_path
                audio_only_path = sitting.hansard. \
                                        media_paths.audio_only_path
                high_quality_video_path = sitting.hansard. \
                                        media_paths.high_quality_video_path
            else:
                web_optimised_video_path = None
                audio_only_path = None
                high_quality_video_path = None

        self.adapters = {self.IEditMediaPathForm: context}
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             self.prefix,
                                             self.context,
                                             self.request,
                                             adapters=self.adapters,
                                             ignore_request=ignore_request)
Example #12
0
    def setUpWidgets(self, ignore_request=False):
        self.set_untranslatable_fields_for_display()

        #get the translation if available
        language = self.request.get('language')

        translation = get_translation_for(self.context, language)
        if translation:
            self.is_translation = True
        else:
            self.is_translation = False
        context = copy(removeSecurityProxy(self.context))
        for field_translation in translation:
            setattr(context, field_translation.field_name,
                    field_translation.field_text)
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             self.prefix,
                                             context,
                                             self.request,
                                             adapters=self.adapters,
                                             ignore_request=ignore_request)

        if language is not None:
            widget = self.widgets['language']
            try:
                self.language = language
                widget.vocabulary = CurrentLanguageVocabulary().__call__(self)
                widget.vocabulary.getTermByToken(language)
            except LookupError:
                raise BadRequest("No such language token: '%s'" % language)

            # if the term exists in the vocabulary, set the value on
            # the widget
            widget.setRenderedValue(language)
        # for translations, add a ``render_original`` method to each
        # widget, which will render the display widget bound to the
        # original (HEAD) document
        head = self.context
        form_fields = setUpFields(self.context.__class__, "view")
        for widget in self.widgets:
            form_field = form_fields.get(widget.context.__name__)
            if form_field is None:
                form_field = form.Field(widget.context)

            # bind field to head document
            field = form_field.field.bind(head)

            # create custom widget or instantiate widget using
            # component lookup
            if form_field.custom_widget is not None:
                display_widget = form_field.custom_widget(field, self.request)
            else:
                display_widget = component.getMultiAdapter(
                    (field, self.request), IDisplayWidget)

            display_widget.setRenderedValue(field.get(head))

            # attach widget as ``render_original``
            widget.render_original = display_widget
Example #13
0
 def setUpWidgets(self, ignore_request=False):
     """ setup edit widgets """
     self.widgets = form.setUpEditWidgets(self.form_fields,
                                          self.prefix,
                                          self.context,
                                          self.request,
                                          adapters=self.adapters,
                                          ignore_request=ignore_request)
 def setUpWidgets(self, ignore_request=False):
     self.adapters = self.adapters is not None and self.adapters or {}
     self.widgets = form.setUpEditWidgets(self.form_fields,
                                          self.prefix,
                                          self.context,
                                          self.request,
                                          adapters=self.adapters,
                                          ignore_request=ignore_request)
 def _json_properties(self, factory):
     request = utils.getRequest()
     widgets = form.setUpEditWidgets(factory.form_fields, form_prefix=self.properties_prefix,
                                     request=request, context=self)
     properties = dict()
     for widget in widgets:
         properties.update({widget.name:widget._getCurrentValue()})
     return properties
 def setUpWidgets(self, ignore_request=False):
     self.adapters = {self.model_schema: self.getValue()}
     self.widgets = form.setUpEditWidgets(self.form_fields,
                                          self.prefix,
                                          self.context,
                                          self.request,
                                          adapters=self.adapters,
                                          ignore_request=ignore_request)
Example #17
0
 def setUpWidgets(self, ignore_request=True):
     context = removeSecurityProxy(self.context).media_paths
     self.adapters = {
         self.IEditMediaPathForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, context, self.request,
         adapters=self.adapters, ignore_request=ignore_request)
Example #18
0
 def setUpWidgets(self, ignore_request=False):
     #import pdb; pdb.set_trace()
     self.adapters = {}
     self.widgets = setUpEditWidgets(
         self.form_fields, self.prefix, self.request.principal,
         self.request, adapters=self.adapters,
         ignore_request=ignore_request
         )
Example #19
0
 def setUpWidgets(self, ignore_request=False):
     self.adapters = {}
     self.widgets = form.setUpEditWidgets(self.form_fields,
                                          self.prefix,
                                          self.getContent(),
                                          self.request,
                                          adapters=self.adapters,
                                          ignore_request=ignore_request)
Example #20
0
            def setUpWidgets( self, ignore_request=False):
                self.adapters = dict(
                    [(iface, self.context) for iface in ifaces])

                self.widgets = form.setUpEditWidgets(
                    self.form_fields, self.prefix, self.context, self.request,
                    adapters=self.adapters, for_display=True,
                    ignore_request=ignore_request
                    )
Example #21
0
    def setUpWidgets(self, ignore_request=False):
        self.set_untranslatable_fields_for_display()
        
        #get the translation if available
        language = self.request.get('language')
        
        translation = get_translation_for(self.context, language)
        if translation:
            self.is_translation = True
        else:
            self.is_translation = False
        context = copy(removeSecurityProxy(self.context))
        for field_translation in translation:
            setattr(context, field_translation.field_name, 
                    field_translation.field_text)
        self.widgets = form.setUpEditWidgets(
            self.form_fields, self.prefix, context, self.request,
            adapters=self.adapters, ignore_request=ignore_request)

        if language is not None:
            widget = self.widgets['language']
            try:
                self.language = language
                widget.vocabulary = CurrentLanguageVocabulary().__call__(self)
                widget.vocabulary.getTermByToken(language)
            except LookupError:
                raise BadRequest("No such language token: '%s'" % language)

            # if the term exists in the vocabulary, set the value on
            # the widget
            widget.setRenderedValue(language)
        # for translations, add a ``render_original`` method to each
        # widget, which will render the display widget bound to the
        # original (HEAD) document
        head = self.context
        form_fields = setUpFields(self.context.__class__, "view")
        for widget in self.widgets:
            form_field = form_fields.get(widget.context.__name__)
            if form_field is None:
                form_field = form.Field(widget.context)

            # bind field to head document
            field = form_field.field.bind(head)

            # create custom widget or instantiate widget using
            # component lookup
            if form_field.custom_widget is not None:
                display_widget = form_field.custom_widget(
                    field, self.request)
            else:
                display_widget = component.getMultiAdapter(
                    (field, self.request), IDisplayWidget)
            
            display_widget.setRenderedValue(field.get(head))

            # attach widget as ``render_original``
            widget.render_original = display_widget
Example #22
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         xml = None
     self.adapters = {
         self.ISpeechXMLForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request)
Example #23
0
 def setUpWidgets(self, ignore_request=True):
     context = removeSecurityProxy(self.context).media_paths
     self.adapters = {self.IEditMediaPathForm: context}
     self.widgets = form.setUpEditWidgets(self.form_fields,
                                          self.prefix,
                                          context,
                                          self.request,
                                          adapters=self.adapters,
                                          ignore_request=ignore_request)
Example #24
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         xml = None
     self.adapters = {
         self.ISpeechXMLForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request)
Example #25
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         duration = None
     self.adapters = {
         self.IGenerateTakes: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request)
Example #26
0
    def setUpWidgets(self, ignore_request=False):
        if IGroupSitting.providedBy(self.context):

            class context:
                item_types = 'Bills'
                bill_options = 'Title'
                agenda_options = 'Title'
                question_options = 'Title'
                motion_options = 'Title'
                tabled_document_options = 'Title'
                note = None

            self.adapters = {self.IReportingForm2: context}
            self.widgets = form.setUpEditWidgets(self.form_fields2,
                                                 self.prefix,
                                                 self.context,
                                                 self.request,
                                                 adapters=self.adapters,
                                                 ignore_request=ignore_request)
        elif ISchedulingContext.providedBy(self.context):

            class context:
                date = self.date or datetime.date.today()
                #time_span = TIME_SPAN.daily
                doc_type = 'Order of the day'
                item_types = 'Bills'
                bill_options = 'Title'
                agenda_options = 'Title'
                question_options = 'Title'
                motion_options = 'Title'
                tabled_document_options = 'Title'
                note = None
                draft = 'No'

            self.adapters = {self.IReportingForm: context}
            self.widgets = form.setUpEditWidgets(self.form_fields,
                                                 self.prefix,
                                                 self.context,
                                                 self.request,
                                                 adapters=self.adapters,
                                                 ignore_request=ignore_request)
        else:
            raise NotImplementedError
Example #27
0
    def setUpWidgets(self, ignore_request=False):
        class context:
            duration = None

        self.adapters = {self.IGenerateTakes: context}
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             self.prefix,
                                             self.context,
                                             self.request,
                                             adapters=self.adapters,
                                             ignore_request=ignore_request)
Example #28
0
    def begin(self, formname, fieldname, structure='false'):
        """Begin inline editing - find the widget for the given field name
        in the given form (looked up as a view on the context), then hide the
        block with the id '${fieldname}-display' and display an edit form in
        its place. If 'structure' is 'true' (a string), then the inline 
        editable field will eventually permit HTML input to be rendered
        unescaped.
        """
        context = aq_inner(self.context)
        request = aq_inner(self.request)
        
        form = getMultiAdapter((context, request), name=formname)
        form = form.__of__(context)
        
        if fieldname.startswith(form.prefix):
            fieldname = fieldname[len(form.prefix)+1:]
            
        formlib_field = form.form_fields[fieldname]
        widgets = formlib.setUpEditWidgets((formlib_field,), form.prefix, 
            context, request, ignore_request=True)
            
        widget = widgets[fieldname]
        
        display_id = '%s-display' % fieldname
        form_id = '%s-form' % fieldname
        
        ksscore = self.getCommandSet('core')
        zopecommands = self.getCommandSet('zope')
        plonecommands = self.getCommandSet('plone')
        
        # lock the context (or issue warning)
        locking = ILockable(context, None)
        if locking:
            if not locking.can_safely_unlock():
                selector = ksscore.getHtmlIdSelector('plone-lock-status')
                zopecommands.refreshViewlet(selector, 'plone.abovecontent', 'plone.lockinfo')
                plonecommands.refreshContentMenu()
                return
            else: # we are locking the content
                locking.lock()
        
        plonecommands.issuePortalMessage('')
        
        # hide the existing display field
        display_selector = ksscore.getHtmlIdSelector(display_id)
        ksscore.addClass(display_selector, 'hiddenStructure')
        
        # show the form
        form_html = self.form_template(widget=widget,
                                       form_id=form_id,
                                       fieldname=fieldname,
                                       structure=structure)

        ksscore.insertHTMLAfter(display_selector, form_html)
Example #29
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         editors = get_assigned_staff(self.context, "Editor")
         readers = get_assigned_staff(self.context, "Reader")
         reporters = get_assigned_staff(self.context, "Reporter")
     self.adapters = {
         self.IAssignmentForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request)
Example #30
0
 def setUpWidgets(self, ignore_request=False):
     # First part is copied from zope.formlib.form.EditForm licensed under
     # the ZPL 2.1
     self.adapters = {}
     # In order to support fieldsets, we need to setup the widgets on all
     # the fieldsets as well.
     if self.is_fieldsets():
         self.widgets = None
         for fieldset in self.form_fields.fieldsets:
             fieldset.widgets = form.setUpEditWidgets(
                 fieldset, self.prefix, self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request
                 )
             if self.widgets is None:
                 self.widgets = fieldset.widgets
             else:
                 self.widgets += fieldset.widgets
     else:
         self.widgets = form.setUpEditWidgets(
             self.form_fields, self.prefix, self.context, self.request,
             adapters=self.adapters, ignore_request=ignore_request
             )
Example #31
0
 def setUpWidgets(self, ignore_request=False):
     """Override to find context using request data (id) if provided.
     """
     self.adapters = {}
     context = _get_posto(self.request) or self.context
     self.widgets = form.setUpEditWidgets(
             self.form_fields, self.prefix, context, self.request,
             adapters=self.adapters, ignore_request=ignore_request,
             for_display=True
             )
     self.widgets_hidden = """<input type="hidden"
                                     name="form.id"
                                     value="%s" />""" % self.request.get('form.id')
Example #32
0
    def setUpWidgets(self, ignore_request=False):
        class context:
            editors = get_assigned_staff(self.context, "Editor")
            readers = get_assigned_staff(self.context, "Reader")
            reporters = get_assigned_staff(self.context, "Reporter")

        self.adapters = {self.IAssignmentForm: context}
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             self.prefix,
                                             self.context,
                                             self.request,
                                             adapters=self.adapters,
                                             ignore_request=ignore_request)
    def setUpWidgets(self, ignore_request=False):
        self.adapters = self.adapters is not None and self.adapters or {}

        # grab all the adapters and fields from the entire wizard form sequence
        # (till the current step)
        adapters = self.wizard.data_manager.adapters
        fields = self.wizard.data_manager.fields

        formSchemas = component.getUtility(interfaces.IFormSchemas)
        # edit widgets for payment info
        self.widgets = form.setUpEditWidgets(
            self.form_fields.select(
                *schema.getFieldNamesInOrder(
                    formSchemas.getInterface('payment')
                )
            ),
            self.prefix, self.context, self.request,
            adapters=adapters, ignore_request=ignore_request
            )

        # display widgets for bill/ship address
        bill_ship_fields = []
        for i in (formSchemas.getInterface('billing_address'),
                  formSchemas.getInterface('shipping_address')):
            bill_ship_fields.append(
                fields.select(
                    *schema.getFieldNamesInOrder(i)
                )
            )
        # make copies of custom widgets.. (typically for edit, we want display)
        bill_ship_fields = sanitize_custom_widgets(
            reduce(operator.__add__, bill_ship_fields)
            )

        self.widgets += form.setUpEditWidgets(
            bill_ship_fields,  self.prefix, self.context, self.request,
            adapters=adapters, for_display=True, ignore_request=ignore_request
            )
Example #34
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         start_date = None
         end_date = None
         body_text = None
         note = None
         short_name = None
         sittings = None
     self.adapters = {
         self.ISaveReportForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request)
 def _aaData(self, brains):
     results = list()
     for brain in brains:
         row = list()
         widgets =form.setUpEditWidgets(self._formfields(), request=self.request,
                                        context=brain, form_prefix='', for_display=True)
         for widget in widgets:
             row.append(widget())
         for ac in self.actions:
             row.append(self._linkbuilder(ac, brain))
         for input in self.inputs:
             row.insert(0, self._inputbuilder(input, brain))
         results.append(row)
     return results
Example #36
0
    def __init__(self, field, request):
        self.context = field
        self.request = request
        self.name = self._prefix + field.__name__

        value = field.query(field.context)
        adapters = {}
        adapters[IPhoneData] = PhoneWidgetData(self, value)
        self.widgets = form.setUpEditWidgets(
            form.FormFields(IPhoneData),
            self.name, value, request, adapters=adapters)
        self.widgets['first'].displayWidth = 3
        self.widgets['second'].displayWidth = 3
        self.widgets['third'].displayWidth = 4
Example #37
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         session = Session()
         trusted = removeSecurityProxy(self.context)
         sitting = session.query(domain.Sitting).get(trusted.sitting_id)
         if sitting is not None:
             media_path = sitting.media_path
         else:
             media_path = None
         
     self.adapters = {
         self.IEditMediaPathForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
         adapters=self.adapters, ignore_request=ignore_request)
Example #38
0
    def __init__(self, field, request):
        self.context = field
        self.request = request
        self.name = self._prefix + field.__name__

        value = field.query(field.context)
        adapters = {}
        adapters[IPhoneData] = PhoneWidgetData(self, value)
        self.widgets = form.setUpEditWidgets(form.FormFields(IPhoneData),
                                             self.name,
                                             value,
                                             request,
                                             adapters=adapters)
        self.widgets['first'].displayWidth = 3
        self.widgets['second'].displayWidth = 3
        self.widgets['third'].displayWidth = 4
Example #39
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         ids = None
         start_date = None
         end_date = None
         location = None
         language = None
         recurrence_type = None
         event_length = None
         nativeeditor_status = None
     self.adapters = {
         self.DhtmlxCalendarSittingsEditForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, "", self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request)
Example #40
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         item_types = "Bills"
         bills_options = "Title"
         agenda_items_options = "Title"
         questions_options = "Title"
         motions_options = "Title"
         tabled_documents_options = "Title"
         note = None
         date = None
         short_name = _(u"Order of the day")
     self.adapters = {
         self.IReportForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request)
Example #41
0
    def setUpWidgets(self, ignore_request=False):
        class context:
            session = Session()
            trusted = removeSecurityProxy(self.context)
            sitting = session.query(domain.Sitting).get(trusted.sitting_id)
            if sitting is not None:
                media_path = sitting.media_path
            else:
                media_path = None

        self.adapters = {self.IEditMediaPathForm: context}
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             self.prefix,
                                             self.context,
                                             self.request,
                                             adapters=self.adapters,
                                             ignore_request=ignore_request)
Example #42
0
 def setUpWidgets(self, ignore_request=False):
     class context:
         item_types = 'Bills'
         bills_options = 'Title'
         agenda_items_options = 'Title'
         questions_options = 'Title'
         motions_options = 'Title'
         tabled_documents_options = 'Title'
         note = None
         date = None
         doc_type = 'Order of the day'
     self.adapters = {
         self.IReportForm: context
         }
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, self.context, self.request,
                 adapters=self.adapters, ignore_request=ignore_request)
Example #43
0
    def setUpWidgets(self, ignore_request=False):
        """Override to find context using request data (id) if provided.
	    """
        self.adapters = {}
        context = _get_posto(self.request) or self.context
        self.widgets = form.setUpEditWidgets(
        self.form_fields, self.prefix, context, self.request,
        adapters=self.adapters, ignore_request=ignore_request
        )
        for field_name in ['nome','email','endereco', 'telefone']:
            self.widgets[field_name].displayWidth = 40
        self.widgets['uf'].displayWidth = 2
        self.widgets['cep'].displayWidth = 9

        self.widgets_hidden = """<input type="hidden"
                                        name="form.id"
                                        value="%s" />""" % context.id
Example #44
0
    def setUpWidgets(self, ignore_request=False):
        languages = get_all_languages()
        self.form_fields = filterFields(self.context, self.form_fields)

        # do not display empty form fields
        omit_names = []
        for f in self.form_fields:
            val = getattr(self.context, f.__name__)
            if val is None:
                omit_names.append(f.__name__)
        self.form_fields = self.form_fields.omit(*omit_names)
        context = self.context
        if ITranslatable.providedBy(self.context):
            lang = get_default_language()
            try:
                translation = get_field_translations(self.context, lang)
            except:
                translation = []
            if (
                not translation
                and getattr(self.context, "language", None)
                and getattr(self.context, "language", None) != lang
            ):
                supported_lang = languages.get(lang)
                if supported_lang:
                    langname = supported_lang.get("native", None)
                    if langname == None:
                        langname = supported_lang.get("name")
                    self.status = translate(
                        _(u"This content is not yet translated into" + " $language", mapping={"language": langname}),
                        domain="bungeni",
                        context=self.request,
                    )
            context = copy(removeSecurityProxy(self.context))
            for field_translation in translation:
                setattr(context, field_translation.field_name, field_translation.field_text)
        self.widgets = form.setUpEditWidgets(
            self.form_fields,
            "",
            context,
            self.request,
            adapters=self.adapters,
            for_display=True,
            ignore_request=ignore_request,
        )
Example #45
0
    def setUpWidgets(self, ignore_request=False):
        languages = get_all_languages()
        self.form_fields = filterFields(self.context, self.form_fields)

        #do not display empty form fields
        omit_names = []
        for f in self.form_fields:
            val = getattr(self.context, f.__name__)
            if val is None:
                omit_names.append(f.__name__)
        self.form_fields = self.form_fields.omit(*omit_names)
        context = self.context
        if ITranslatable.providedBy(self.context):
            lang = self.request.locale.getLocaleID()
            try:
                translation = get_translation_for(self.context, lang)
            except:
                translation = []
            if (not translation and
                getattr(self.context, "language", None) and
                getattr(self.context, "language", None) != lang
            ):
                supported_lang = languages.get(lang)
                if supported_lang:
                    langname = supported_lang.get("native", None)
                    if langname == None:
                        langname = supported_lang.get("name")
                    self.status = translate(
                        _(u"This content is not yet translated into" +\
                            " $language",
                            mapping={"language": langname}),
                        domain="bungeni",
                        context=self.request
                    )
            context = copy(removeSecurityProxy(self.context))
            for field_translation in translation:
                setattr(context, field_translation.field_name,
                        field_translation.field_text)
        self.widgets = form.setUpEditWidgets(
            self.form_fields, "" , context, self.request,
            adapters=self.adapters,
            for_display=True,
            ignore_request=ignore_request
        )
Example #46
0
    def setUpWidgets(self, ignore_request=False):
        class context:
            item_types = 'Bills'
            bills_options = 'Title'
            agenda_items_options = 'Title'
            questions_options = 'Title'
            motions_options = 'Title'
            tabled_documents_options = 'Title'
            note = None
            date = None
            doc_type = 'Order of the day'

        self.adapters = {self.IReportForm: context}
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             self.prefix,
                                             self.context,
                                             self.request,
                                             adapters=self.adapters,
                                             ignore_request=ignore_request)
Example #47
0
    def __init__(self, field, request):
        self.context = field
        self.request = request
        if self.context.initialDate:
            self.initialDate = self.context.initialDate
        else:
            self.initialDate = datetime.date.today()
        value = field.query(field.context, default=self.initialDate)
        if value is None:
            # can't be None, set given start date, which is a valid value
            value = self.initialDate

        self.name = self._prefix + field.__name__

        adapters = {}
        adapters[IDateSelectData] = DateSelectDataForDateSelectWidget(self,
            value)
        self.widgets = form.setUpEditWidgets(form.FormFields(IDateSelectData),
            self.name, value, request, adapters=adapters)
Example #48
0
    def setUpWidgets(self, ignore_request=False):
        class context:
            ids = None
            event_pid = None
            short_name = None
            start_date = None
            end_date = None
            location = None
            language = None
            venue = None
            rec_type = None
            event_length = None
            nativeeditor_status = None
            activity_type = None
            meeting_type = None
            convocation_type = None

        self.adapters = {interfaces.IDhtmlxCalendarSittingsEditForm: context}
        self.widgets = form.setUpEditWidgets(
            self.form_fields, "", self.context, self.request, adapters=self.adapters, ignore_request=ignore_request
        )
Example #49
0
    def __init__(self, field, request):
        self.context = field
        self.request = request
        if self.context.initialDate:
            self.initialDate = self.context.initialDate
        else:
            self.initialDate = datetime.date.today()
        value = field.query(field.context, default=self.initialDate)
        if value is None:
            # can't be None, set given start date, which is a valid value
            value = self.initialDate

        self.name = self._prefix + field.__name__

        adapters = {}
        adapters[IDateSelectData] = DateSelectDataForDateSelectWidget(
            self, value)
        self.widgets = form.setUpEditWidgets(form.FormFields(IDateSelectData),
                                             self.name,
                                             value,
                                             request,
                                             adapters=adapters)
Example #50
0
 def setUpWidgets(self, ignore_request=False):
     languages = get_all_languages()
     self.form_fields = filterFields(self.context, self.form_fields)
     
     #do not display empty form fields
     omit_names = []
     for f in self.form_fields:
         val = getattr(self.context, f.__name__)
         if val is None:
             omit_names.append(f.__name__)
     self.form_fields = self.form_fields.omit(*omit_names)
     
     lang = self.request.locale.getLocaleID()
     try:
         translation = get_translation_for(self.context, lang)
     except:
         translation = []
     if (not translation) and (getattr(self.context, 'language', None) and
             (getattr(self.context, 'language', None) != lang)):
         supported_lang = languages.get(lang)
         if supported_lang:
             langname = supported_lang.get('native',None)
             if langname == None:
                 langname = supported_lang.get('name')
             self.status = translate(
                 _(u'This content is not yet translated into $language', 
                     mapping={'language': langname}),
                 domain="bungeni.ui",
                 context=self.request)
     context = copy(removeSecurityProxy(self.context))
     for field_translation in translation:
         setattr(context, field_translation.field_name, 
                 field_translation.field_text)
     self.widgets = form.setUpEditWidgets(
         self.form_fields, self.prefix, context, self.request,
         adapters=self.adapters, for_display=True, ignore_request=ignore_request)
Example #51
0
 def setUpWidgets(self, ignore_request=False):
     self.widgets = form.setUpEditWidgets(self.form_fields,
                                          self.prefix,
                                          self.context,
                                          self.request,
                                          ignore_request=ignore_request)