class ChangePasswordForm(PasswordForm): old_password = forms.PasswordField() layout = forms.Layout(forms.Fieldset('old_password', 'password', 'password_repeat'), forms.Submit('Update password', classes='btn btn-primary'), showLabels=False)
class PasswordForm(forms.Form): password = forms.PasswordField(required=True, minlength=6, maxlength=128) password_repeat = forms.PasswordField(label='confirm password', data_check_repeat='password') layout = forms.Layout(forms.Fieldset('password', 'password_repeat'), forms.Submit('Reset password', classes='btn btn-primary'), showLabels=False)
class LoginForm(forms.Form): '''The Standard login form''' error_message = 'Incorrect username or password' username = forms.CharField(required=True, minlength=6, maxlength=30) password = forms.PasswordField(required=True, minlength=6, maxlength=128) layout = forms.Layout(forms.Fieldset(all=True), forms.Submit('Login', classes='btn btn-primary btn-block', disabled="form.$invalid"), showLabels=False)
class CreateUserForm(PasswordForm): username = forms.CharField(required=True, minlength=6, maxlength=30) email = forms.EmailField(required=True) layout = forms.Layout(forms.Fieldset('username', 'email', 'password', 'password_repeat'), forms.Submit('Sign up', classes='btn btn-primary btn-block', disabled="form.$invalid"), showLabels=False, directive='user-form')
class ContentForm(forms.Form): content_type = forms.CharField() title = forms.CharField(required=True) slug = forms.HiddenField(required=False) layout = forms.Layout(forms.Fieldset('title', show_label=False), forms.Fieldset('body', show_label=False)) def value_from_instance(self, instance, name, value): if name == 'body': return instance.data.get('body', '') else: return getattr(instance, name, value) def clean(self): data = self.cleaned_data slug = data.get('slug') if not slug: self.cleaned_data['slug'] = slugify(data['title'].lower()) data['data'] = {'body': data.pop('body', '')}
class BlogAdmin(CRUDAdmin): icon = 'fa fa-book' form = forms.Layout(BlogForm)
class EmailForm(forms.Form): email = forms.EmailField(label='Enter your email address') layout = forms.Layout(forms.Fieldset(all=True), forms.Submit('Submit', classes='btn btn-primary'), showLabels=False)
def on_loaded(self, app): app.forms['blog'] = forms.Layout(BlogForm)