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)
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)
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)
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)
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
class TemplateForm(forms.Form): title = forms.CharField() body = forms.TextField(text_edit=json.dumps({'mode': 'html'}))
class NewTokenForm(forms.Form): """Form to create tokens for the current user""" description = forms.TextField(maxlength=256)
class BlogForm(forms.Form): title = forms.CharField() author = forms.CharField() body = forms.TextField()
class AuthorizeForm(LoginForm): expiry = forms.DateTimeField(required=False) user_agent = forms.TextField(required=False) ip_address = forms.CharField(required=False)
class NewTokenForm(forms.Form): """Create a new Authorization ``Token`` for the authenticated ``User``. """ description = forms.TextField(minlength=2, maxlength=256)