Ejemplo n.º 1
0
class EditForm(base.EditForm):
    """Portlet edit form.

    This is registered with configure.zcml. The form_fields variable tells
    zope.formlib which fields to display.
    """
    form_fields = form.Fields(IRichPortlet)
    form_fields['text'].custom_widget = WYSIWYGWidget
    form_fields['target_title_image'].custom_widget = UberSelectionWidget

    label = _(u"Edit Rich Portlet")
    description = _(u"This portlet ...")
Ejemplo n.º 2
0
class EmergencyNotificationConfigurationForm(ControlPanelForm):

    form_fields = form.Fields(ISimpleEmergencySchema)
    form_fields['emergency_message'].custom_widget = WYSIWYGWidget

    description = _(
        u"This is where you can configure Emergency Notification settings.")
    form_name = _(u"UW Oshkosh Emergency Notification Configuration")

    def _on_save(self, data=None):
        super(EmergencyNotificationConfigurationForm, self)._on_save(data)
        notify(SimpleEmergencyModifiedEvent(self.context, self.request))
Ejemplo n.º 3
0
class AddForm(base.AddForm):
    form_fields = form.Fields(IUltimasNoticias)
    form_fields['noticias'].custom_widget = UberSelectionWidget
    form_fields['eventos'].custom_widget = UberSelectionWidget
    label = _(u"Adicionar o Portlet de Noticias e Eventos")
    description = _(u"")

    def create(self, data):
        return Assignment(
            noticias=data.get('noticias', ''),
            eventos=data.get('eventos', ''),
        )
Ejemplo n.º 4
0
    def setUpEntriesWidgets(self):
        """Prepare translation import entries widgets to be rendered."""
        fields = form.Fields()
        for entry in self.batchnav.currentBatch():
            fields += self.createEntryStatusField(entry)

        if len(fields) > 0:
            self.form_fields += fields

            self.widgets += form.setUpWidgets(
                fields, self.prefix, self.context, self.request,
                data=self.initial_values, ignore_request=False)
Ejemplo n.º 5
0
class EditForm(base.EditForm):
    """Portlet edit form.

    This is registered with configure.zcml. The form_fields variable tells
    zope.formlib which fields to display.
    """

    form_fields = form.Fields(IRollingQuotesPortlet)
    form_fields['folder'].custom_widget = UberSelectionWidget

    label = _(u"Rolling Quotes Portlet")
    description = _(u"This portlet displays a random Quote")
Ejemplo n.º 6
0
class AddForm(base.AddForm):
    """Portlet add form.

    This is registered in configure.zcml. The form_fields variable tells
    zope.formlib which fields to display. The create() method actually
    constructs the assignment that is being added.
    """
    form_fields = form.Fields(IDiscussionPortlet)
    form_fields['discussionFolder'].custom_widget = UberSelectionWidget

    def create(self, data):
        return Assignment(**data)
Ejemplo n.º 7
0
class ItemScheduleReorderForm(PageForm):
    """Form to reorder a scheduling within a list of schedulings."""
    class IReorderForm(interface.Interface):
        mode = schema.Choice(('up', 'down'),
                             title=_(u"Direction"),
                             required=True)
        field = schema.Choice(('planned_order', 'real_order'),
                              title=_(u"AM"),
                              required=True)

    form_fields = form.Fields(IReorderForm)

    @form.action(_(u"Move"))
    def handle_move(self, action, data):
        """Move scheduling.

        This logic handles both reordering within the container and
        maintenance of category assignments.

        If we move up:

        - Next item inherits any assigned category
        - This item gets its category cleared

        If we move down:

        - We inherit category of the following item
        - Next item gets its category cleared 

        """
        field = data['field']
        mode = data['mode']
        container = copy.copy(removeSecurityProxy(self.context.__parent__))
        name = self.context.__name__
        schedulings = container.batch(order_by=field, limit=None)
        ordering = [scheduling.__name__ for scheduling in schedulings]
        for i in range(0, len(ordering)):
            setattr(container[ordering[i]], field, i + 1)

        index = ordering.index(name)

        if mode == 'up' and index > 0:
            # if this item has a category assigned, and there's an
            # item after it, swap categories with it
            if index < len(ordering) - 1:
                next = container[ordering[index + 1]]
            prev = container[ordering[index - 1]]
            order = getattr(self.context, field)
            setattr(self.context, field, getattr(prev, field))
            setattr(prev, field, order)

        if mode == 'down' and index < len(ordering) - 1:
            next = container[ordering[index + 1]]
Ejemplo n.º 8
0
class EditForm(base.EditForm):
    """Portlet edit form.

    This is registered with configure.zcml. The form_fields variable tells
    zope.formlib which fields to display.
    """

    form_fields = form.Fields(IDocumentFallbackPortlet)
    form_fields['target_document'].custom_widget = UberSelectionWidget

    label = _(u"Edit Document Fallback Portlet")
    description = _(u"This portlet displays the contents of a document.")
Ejemplo n.º 9
0
class AddForm(base.AddForm):
    """
    """
    form_fields = form.Fields(ICategoriesPortlet)

    def create(self, data):
        """
        """
        return Assignment(
            expand_all=data.get("expand_all", False),
            show_quantity=data.get("show_quantity", False),
        )
Ejemplo n.º 10
0
def setUpFields(domain_model, mode):
    """
    setup form fields for add/edit/view/search modes, with custom widgets
    enabled from model descriptor. this expects the domain model and mode
    passed in and will return a form.Fields instance
    """
    domain_model = removeSecurityProxy(domain_model)
    #import time
    #t = time.time()
    table_schema = bungeni.alchemist.utils.get_derived_table_schema(domain_model)
    descriptor_model = bungeni.alchemist.utils.get_descriptor(table_schema)
    
    search_mode = mode == "search"
    
    if not descriptor_model:
        if search_mode:
            form_fields = form.Fields(*setUpSearchFields(table_schema))
        else:
            form_fields = form.Fields(table_schema)
        return form_fields
    
    fields = []
    columns = getattr(descriptor_model, "%s_columns" % mode)
    
    for field_info in columns:
        if not field_info.name in table_schema:
            #print "bad field", field_info.name, table_schema.__name__
            continue
        custom_widget = getattr(field_info, "%s_widget" % mode)
        if search_mode:
            fields.append(form.Field(
                    setUpSearchField(table_schema[field_info.name]),
                    custom_widget=custom_widget))
        else:
            fields.append(form.Field(
                    table_schema[field_info.name],
                    custom_widget=custom_widget))
    form_fields = form.Fields(*fields)
    #print "field setup cost", time.time()-t    
    return form_fields
Ejemplo n.º 11
0
class PreferAddress(AddressForm):
    form_fields = form.Fields(IPreferAddress, render_context=False)

    def __init__(self, profile, request):
        super(PreferAddress, self).__init__(profile, request)
        self.label = 'Prefer an email address'

    @form.action(label='Prefer',
                 name='prefer',
                 prefix='',
                 failure='handle_failure')
    def handle_prefer(self, action, data):
        '''Prefer an email address

:param action: The button that was clicked.
:param dict data: The form data.'''
        e = data['email'].lower()
        if (e not in self.emailUser):
            m = '{0} ({1}) lacks the address <{2}>'
            msg = m.format(self.userInfo.name, self.userInfo.id, data['email'])
            raise AddressMissing(msg)
        elif (e in self.emailUser.preferred):
            msg = 'The address <{0}> is already preferred'.format(
                data['email'])
            raise AddressPreferred(msg)
        elif (e in self.emailUser.unverified):
            msg = 'The address <{0}> is unverified'.format(data['email'])
            raise AddressUnverified(msg)

        msg = self.prefer(data['email'])

        r = {
            'status': 0,
            'message': msg,
            'email': email_info(self.siteInfo, self.userInfo),
        }
        retval = to_json(r)
        return retval

    def prefer(self, address):
        if not address:
            raise ValueError('Address is required')

        self.emailUser.set_delivery(address)
        addr = markup_address(address)
        msg = _(
            'prefer-message',
            'You have set the email address ${address} as <b>preferred</b>. You will recieve email '
            'from your groups at this address by default.',
            mapping={'address': addr})
        retval = translate(msg)
        return retval
Ejemplo n.º 12
0
class AddForm(base.AddForm):
    form_fields = form.Fields(INavigationPortlet)
    form_fields['root'].custom_widget = UberSelectionWidget
    label = _(u"Add Navigation Portlet")
    description = _(u"This portlet displays a navigation tree.")

    def create(self, data):
        return Assignment(name=data.get('name', ""),
                          root=data.get('root', ""),
                          currentFolderOnly=data.get('currentFolderOnly', False),
                          includeTop=data.get('includeTop', False),
                          topLevel=data.get('topLevel', 0),
                          bottomLevel=data.get('bottomLevel', 0))
Ejemplo n.º 13
0
class AddForm(base.AddForm):
    """
    """
    form_fields = form.Fields(INewsletterSubscriberPortlet)

    def create(self, data):
        """
        """
        return Assignment(
            portlet_title = data.get("portlet_title", ""),
            portlet_description = data.get("portlet_description", ""),
            newsletter = data.get("newsletter", ""),
        )
Ejemplo n.º 14
0
class EditForm(base.EditForm):
    """Portlet edit form.

    This is registered with configure.zcml. The form_fields variable tells
    zope.formlib which fields to display.
    """
    form_fields = form.Fields(ICollectionBySubject)
    form_fields['target_collection'].custom_widget = UberSelectionWidget

    label = _(u"Add Collection by subject Portlet")
    description = _(
        u"This portlet display a listing of items from a Collection "
        "that are grouped by selected subject.")
Ejemplo n.º 15
0
class AddForm(base.AddForm):

#    XXX: z3cform
#    fields = field.Fields(IEappiInternationalMap)

    form_fields = form.Fields(IEappiInternationalMap)
    form_fields['target_collection'].custom_widget = UberSelectionWidget

    label = _(u"Add Eappi International Map")
    description = _(u"")

    def create(self, data):
        return Assignment(**data)
Ejemplo n.º 16
0
class AddForm(base.AddForm):
    form_fields = form.Fields(IRelatedItemPortlet)
    label = u"Add Related Item portlet"
    description = u'This portlet displays the body of a single item from the site that is considered "related" to the current page.'

    form_fields['which_fields_relate'].custom_widget = PHMultiCheckBoxWidget
    form_fields[
        'which_content_types'].custom_widget = MultiCheckBoxThreeColumnWidget

    def create(self, data):
        assignment = Assignment()
        form.applyChanges(assignment, self.form_fields, data)
        return assignment
Ejemplo n.º 17
0
class AddForm(base.AddForm):

    form_fields = form.Fields(ILatestNITFPortlet)
    form_fields = form_fields.omit('target_collection')

    label = _(u"Add latest NITF Portlet")
    description = _(
        u"This portlet display a list of latest NITF from a "
        u"Collection. It will select between different collections "
        u"based on the current context.")

    def create(self, data):
        return Assignment(**data)
    def createEntryStatusField(self, entry):
        """Create a field with a vocabulary with entry's import status.

        :return: A form.Fields instance containing the status field.
        """
        name = 'status_%d' % entry.id
        self._initial_values[name] = entry.status.name
        return form.Fields(Choice(__name__=name,
                                  source=EntryImportStatusVocabularyFactory(
                                      entry, self.user),
                                  title=_('Select import status')),
                           custom_widget=self.custom_widgets['status'],
                           render_context=self.render_context)
Ejemplo n.º 19
0
class EditForm(base.EditForm):
    form_fields = form.Fields(IRegionMapPortlet)
    label = _(u"Edit Region Map Portlet")
    description = _(u"Portlet showing the region map")

    form_fields['africa'].custom_widget = UberSelectionWidget
    form_fields['north_america'].custom_widget = UberSelectionWidget
    form_fields['south_america'].custom_widget = UberSelectionWidget
    form_fields['pacific'].custom_widget = UberSelectionWidget
    form_fields['caribbean'].custom_widget = UberSelectionWidget
    form_fields['asia'].custom_widget = UberSelectionWidget
    form_fields['europe'].custom_widget = UberSelectionWidget
    form_fields['middle_east'].custom_widget = UberSelectionWidget
Ejemplo n.º 20
0
class AddForm(base.AddForm):
    """Portlet add form.

    This is registered in configure.zcml. The form_fields variable tells
    zope.formlib which fields to display. The create() method actually
    constructs the assignment that is being added.
    """
    form_fields = form.Fields(IMyLibrary)

    def create(self, data):
        assignment = Assignment()
        form.applyChanges(assignment, self.form_fields, data)
        return assignment
Ejemplo n.º 21
0
 def createProductField(self):
     """Create a Choice field to select one of the project group's
     products."""
     return form.Fields(Choice(
         __name__='product',
         vocabulary='ProjectProducts',
         title=_('Project'),
         description=_(
             '${context} is a group of projects, which specific '
             'project do you have a question about?',
             mapping=dict(context=self.context.title)),
         required=True),
                        render_context=self.render_context)
class AddForm(base.AddForm):
    """Portlet add form.

    This is registered in configure.zcml. The form_fields variable tells
    zope.formlib which fields to display. The create() method actually
    constructs the assignment that is being added.
    """
    form_fields = form.Fields(IContentPortlet)
    form_fields['content'].custom_widget = UberSelectionWidget
    form_fields['item_display'].custom_widget = MultiCheckBoxVocabularyWidget

    def create(self, data):
        return Assignment(**data)
Ejemplo n.º 23
0
class AddForm(base.AddForm):
    """Portlet add form.

    This is registered in configure.zcml. The form_fields variable tells
    zope.formlib which fields to display. The create() method actually
    constructs the assignment that is being added.
    """

    form_fields = form.Fields(IPracticalSolutionsPortlet)
    form_fields['subject'].custom_widget = MultiCheckBoxWidgetFactory

    def create(self, data):
        return Assignment(**data)
Ejemplo n.º 24
0
class EditForm(base.EditForm):
    """Portlet edit form.

    This is registered with configure.zcml. The form_fields variable tells
    zope.formlib which fields to display.
    """
    form_fields = form.Fields(IGroupPortlet)
    form_fields['group'].custom_widget = GroupTextWidget

    label = _(u"title_edit_group_portlet", default=u"Edit group portlet")

    def setUpWidgets(self, ignore_request=False):
        super(EditForm, self).setUpWidgets(ignore_request=ignore_request)
Ejemplo n.º 25
0
class EditForm(base.EditForm):
    """Portlet edit form.

    This is registered with configure.zcml. The form_fields variable tells
    zope.formlib which fields to display.
    """
    form_fields = form.Fields(IFlashPortlet)
    form_fields['target_collection'].custom_widget = UberSelectionWidget
    form_fields['target_flash'].custom_widget = UberSelectionWidget

    label = _a(u"Edit Collection Portlet")
    description = _a(
        u"This portlet display a listing of items from a Collection.")
 def form_fields(self):
     schema = get_extended_schema(self.request, self.context.renderer)
     fields = form.Fields(schema)
     fields['target_collection'].custom_widget = UberSelectionWidget
     fields['renderer'].custom_widget = RendererSelectWidget
     custom_widgets = get_custom_widgets(
         self.request,
         self.context.renderer)
     for field, widget in custom_widgets.items():
         fields[field].custom_widget = widget
     if getattr(self, 'adapters', None) is not None:
         self.adapters[schema] = ExtendedDataAdapter(self.context)
     return fields
Ejemplo n.º 27
0
class BioSQLDatabaseAddForm(AddFormBase):
    """Add form """
    form_fields = form.Fields(IBioSQLDatabase)
    label = _(u"Add BioSQLDatabase")
    form_name = _(u"Edit BioSQLDatabase")
    def create(self, data):
        root = self.context.getBioSQLRoot()
        dbserver = root.getDBServer()
        biodb = dbserver.new_database(data['id'], description=data.get("description", None))
        dbserver.commit()
        object = root[data['id']]
        # TODO: test catalog object
        return object
Ejemplo n.º 28
0
    def form_fields(self):
        #defaultFields = super(RegisterForm, self).form_fields
        defaultFields = BaseRegistrationForm(self, self.context).form_fields
        defaultFields += form.Fields(ExtendRegistrationForm)
        defaultFields['captcha'].custom_widget = CaptchaWidget
        schema = getUtility(IUserDataSchemaProvider).getSchema()

        #registrationfields = getUtility(
        #    IUserDataSchemaProvider
        #).getRegistrationFields()
        #return (defaultFields.omit('password', 'password_ctl', 'mail_me') +
        #        form.Fields(schema).select(*registrationfields))
        return defaultFields.omit('password', 'password_ctl', 'mail_me')
Ejemplo n.º 29
0
class AddForm(base.AddForm):
    form_fields = form.Fields(ICoursesPortlet)
    label = _(u'Add Course portlet')
    description = _(u'This portlet displays my courses.')

    # This method must be implemented to actually construct the object.
    # The 'data' parameter is a dictionary, containing the values entered
    # by the user.

    def create(self, data):
        assignment = Assignment()
        form.applyChanges(assignment, self.form_fields, data)
        return assignment
class EditForm(base.EditForm):
    """Portlet edit form.

    This is registered with configure.zcml. The form_fields variable tells
    zope.formlib which fields to display.
    """
    form_fields = form.Fields(IPersonLeadImageCollectionPortlet)
    form_fields['target_collection'].custom_widget = UberSelectionWidget

    label = _(u"Edit PersonLeadImage Collection Portlet")
    description = _(
        u"This portlet displays a listing of people from a collection with various metadata."
    )