Example #1
0
class ContactForm(forms.Form):
    """
    The base contact form class from which all contact form classes
    should inherit.
    """
    name = forms.CharField(max_length=100, label='Your name')
    email = forms.EmailField(max_length=200, label='Your email address')
    body = forms.TextField(label='Your message', rows=10)
Example #2
0
class TextForm(forms.Form):
    title = forms.CharField()
    slug = forms.CharField(required=False,
                           max_length=SLUG_LENGTH)
    author = forms.CharField(required=False)
    body = forms.TextField(text_edit=json.dumps({'mode': 'markdown'}))
    tags = forms.CharField(required=False)
    published = forms.DateTimeField(required=False)
Example #3
0
class PermissionForm(forms.Form):
    model = 'permission'
    id = forms.HiddenField(required=False)
    name = forms.CharField()
    description = forms.TextField()
    policy = forms.JsonField(text_edit=json.dumps({'mode': 'json'}))

    def clean(self):
        policy = self.cleaned_data['policy']
        self.cleaned_data['policy'] = validate_policy(policy)
Example #4
0
class PermissionForm(forms.Form):
    model = 'permissions'
    name = forms.CharField()
    description = forms.TextField(required=False, rows=2)
    policy = forms.JsonField(lux_ace=json.dumps({'mode': 'json'}))

    def clean(self):
        if 'policy' in self.cleaned_data:
            policy = self.cleaned_data['policy']
            self.cleaned_data['policy'] = validate_policy(policy)
Example #5
0
class PageForm(forms.Form):
    path = forms.CharField(required=False)
    title = forms.CharField()
    description = forms.TextField(required=False)
    template = odm.RelationshipField(template_model, label='template')
    published = forms.BooleanField(required=False)
    layout = forms.JsonField(text_edit=json.dumps({'mode': 'json'}))

    def clean_layout(self, value):
        if not isinstance(value, dict):
            raise forms.ValidationError('Layout must be a dictionary')
        layout = {}
        if 'components' in value:
            components = value['components']
            if not isinstance(components, list):
                raise forms.ValidationError('componets must be a list')
            layout['components'] = components
        if 'rows' in value:
            rows = value['rows']
            if not isinstance(rows, list):
                raise forms.ValidationError('rows must be a list')
            layout['rows'] = rows
        return layout
Example #6
0
class TemplateForm(forms.Form):
    title = forms.CharField()
    body = forms.TextField(text_edit=json.dumps({'mode': 'html'}))
Example #7
0
class NewTokenForm(forms.Form):
    """Form to create tokens for the current user"""
    description = forms.TextField(maxlength=256)
Example #8
0
class BlogForm(forms.Form):
    title = forms.CharField()
    author = forms.CharField()
    body = forms.TextField()
Example #9
0
class AuthorizeForm(LoginForm):
    expiry = forms.DateTimeField(required=False)
    user_agent = forms.TextField(required=False)
    ip_address = forms.CharField(required=False)
Example #10
0
class NewTokenForm(forms.Form):
    """Create a new Authorization ``Token`` for the authenticated ``User``.
    """
    description = forms.TextField(minlength=2, maxlength=256)