Beispiel #1
0
class PageForm(forms.Form):
    '''Inline Editing Page form'''
    url = forms.CharField(initial='/')
    title = forms.CharField(label='Page title', required=False)
    link = forms.CharField(help_text='Text to display in links',
                           required=False)
    in_navigation = forms.IntegerField(
                        initial=0,
                        required=False,
                        label='position',
                        help_text="An integer greater or equal 0 used for "\
                                  " link ordering in menus. If zero the page "\
                                  "won't appear in naviagtions")
    layout = forms.ChoiceField(choices=get_layout_templates,
                               label='Page layout')
    inner_template = forms.ChoiceField(label='content grid',
                                       choices=grid_choices)
    grid_system = forms.ChoiceField(choices=grid_systems)
    soft_root = forms.BooleanField()
    doctype = forms.ChoiceField(choices=html_choices, initial=htmldefaultdoc)

    def clean_url(self, value):
        if self.mapper:
            try:
                page = self.mapper.get(url=value)
            except self.mapper.DoesNotExist:
                page = None
            if page and self.instance != page:
                raise forms.ValidationError('A page with url "{0}"\
 is already available'.format(value))
        else:
            raise forms.ValidationError('No page model defined.')
        return value
Beispiel #2
0
class ModelLinksForm(forms.Form):
    size = forms.ChoiceField(choices=(('', 'standard'), (classes.button_large,
                                                         'large'),
                                      (classes.button_small, 'small')),
                             required=False)
    for_instance = forms.BooleanField()
    layout = forms.ChoiceField(choices=(('group left', 'group left'),
                                        ('group right', 'group right'),
                                        ('horizontal', 'horizontal'),
                                        ('vertical', 'vertical')))
    for_instance = forms.BooleanField()
    exclude = forms.CharField(max_length=600, required=False)
    include = forms.CharField(max_length=600, required=False)
Beispiel #3
0
class ModelItemListForm(ForModelForm):
    max_display = forms.IntegerField(initial=10,
                                     widget=html.TextInput(cn='span1'))
    text_search = forms.CharField(required=False)
    filter = forms.CharField(required=False)
    exclude = forms.CharField(required=False)
    order_by = forms.ChoiceField(required=False,
                                 widget=html.Select(cn='model-fields'),
                                 choices=FieldChoices())
    descending = forms.BooleanField(initial=False)
    headers = forms.ChoiceField(required=False,
                                widget=html.Select(cn='model-fields'),
                                choices=FieldChoices(multiple=True))
    table_footer = forms.BooleanField(initial=False, label='footer')
    display_if_empty = forms.BooleanField(initial=False)
Beispiel #4
0
class SimpleForm(forms.Form):
    name = forms.CharField(max_length=64)
    age = forms.IntegerField(default=lambda b: randint(10, 100))
    profession = forms.ChoiceField(choices=((1, 'student'),
                                            (2, 'professional'), (3,
                                                                  'artist')),
                                   required=False)
Beispiel #5
0
class EditContentForm(forms.Form):
    '''Form used to edit and add Content'''
    title = forms.CharField()
    body = forms.CharField(widget=html.TextArea(cn=classes.taboverride,
                                                rows=30),
                           required=False)
    javascript = forms.CharField(widget=html.TextArea(cn=classes.taboverride,
                                                      rows=30),
                                 required=False)
    markup = forms.ChoiceField(choices=lambda bf: tuple(markups.choices()),
                               initial=lambda form: markups.default(),
                               required=False)
Beispiel #6
0
class CashTradeForm(ManualTradeForm):
    currency = forms.ChoiceField(choices=geo.currency_tuples())

    layout = FormLayout(
        Fieldset('currency',
                 'fund',
                 'open_date',
                 'quantity',
                 css_class=inlineLabels))

    class Meta:
        fields = ['fund', 'open_date', 'quantity']

    def save(self, commit=True):
        if commit:
            dataid = Cash.objects.create(curncy=self.cleaned_data['currency'])
            self.instance.dataid = dataid
        return super(CashTradeForm, self).save(commit=commit)
Beispiel #7
0
def search_form(name='SearchForm',
                placeholder='search',
                input_name=None,
                submit=None,
                cn=None,
                choices=None,
                label='search text',
                deafult_style=uni.nolabel,
                on_submit=None,
                required=False,
                **kwargs):
    '''Create a new :class:`djpcms.forms.HtmlForm` for searching.

:parameter name: name of the :class:`Form`
:parameter placeholder: text for the ``placeholder`` input attribute.
:parameter submit: submit text. If not provided, the form will submit on enter
    key-stroke.
:parameter cn: additional class names for the input element in the form.
'''
    submit = submit or ()
    input_name = input_name or forms.SEARCH_STRING
    widget = html.TextInput(placeholder=placeholder, cn=cn)
    if not submit:
        widget.addData('options', {'submit': True})
        layout = uni.FormLayout(default_style=deafult_style)
    else:
        submit = ((submit, 'search'), )
        layout = uni.FormLayout(uni.Inlineset(input_name, uni.SUBMITS),
                                default_style=deafult_style)
    if choices:
        field = forms.ChoiceField(attrname=input_name,
                                  label=label,
                                  required=required,
                                  choices=choices,
                                  widget=widget)
    else:
        field = forms.CharField(attrname=input_name,
                                label=label,
                                required=required,
                                widget=widget)
    form_cls = forms.MakeForm(name, (field, ), on_submit=on_submit)

    return forms.HtmlForm(form_cls, inputs=submit, layout=layout, **kwargs)
Beispiel #8
0
class ContentBlockForm(forms.Form):
    '''Form for editing a content block within a page.'''
    url = forms.HiddenField(required=False)
    title = forms.CharField(required=False)
    plugin_name = PluginChoice(label='Plugin', choices=plugins.plugingenerator)
    container_type = forms.ChoiceField(
        label='Container',
        widget=html.Select(cn='ajax'),
        choices=plugins.wrappergenerator,
        help_text='A HTML element which wraps the plugin\
 before it is rendered in the page.')
    for_not_authenticated = forms.BooleanField(default=False)

    def on_submit(self, commit):
        data = self.cleaned_data
        pt = data.pop('plugin_name')
        instance = self.instance
        instance.plugin_name = pt.name if pt else ''
        if 'container_type' in data:
            instance.container_type = data['container_type']
Beispiel #9
0
class navigationForm(forms.Form):
    levels = forms.ChoiceField(choices = ((1,1),(2,2)))
    layout = forms.ChoiceField(choices = (('v','vertical'),
                                          ('o','orizontal')))
Beispiel #10
0
class ForModelForm(forms.Form):
    for_model = forms.ChoiceField(
        required=False,
        choices=ModelChoice(empty_label='Select a model'),
        widget=html.Select(cn=classes.model))
Beispiel #11
0
class ContentForm(forms.Form):
    content = forms.ChoiceField(choices=forms.ChoiceFieldOptions(\
                                    query=get_content_choices))
Beispiel #12
0
class FormModelForm(ForModelForm):
    method = forms.ChoiceField(choices=(('get', 'get'), ('post', 'post')),
                               initial='get')
    ajax = forms.BooleanField(initial=False)
Beispiel #13
0
class EcoForm(forms.Form):
    height = forms.IntegerField()
    service_url = forms.CharField(required=False)
    method = forms.ChoiceField(choices=(('get', 'get'), ('post', 'post')),
                               default='get')
Beispiel #14
0
class CloudForm(ForModelForm):
    steps = forms.IntegerField(initial=4)
    min_count = forms.IntegerField(initial=0)
    type = forms.ChoiceField(choices=((LOGARITHMIC, "LOGARITHMIC"),
                                      (LINEAR, "LINEAR")),
                             initial=LOGARITHMIC)