-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
445 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import markdown | ||
import django | ||
|
||
from django.forms.fields import Field | ||
from django.utils.text import mark_safe | ||
|
||
from formfactory import widgets | ||
|
||
|
||
class ParagraphField(Field): | ||
widget = widgets.ParagraphWidget | ||
def __init__(self, paragraph, *args, **kwargs): | ||
super(ParagraphField, self).__init__(*args, **kwargs) | ||
|
||
# Always empty out label for a paragraph field. | ||
self.label = "" | ||
|
||
# No matter what is set, this field should never be required. | ||
self.required = False | ||
self.widget.is_required = False | ||
|
||
# Pass the paragraph text to the widget without needing to override | ||
# widget __init__. Process markdown here, its up to custom fields to | ||
# worry about what they are trying to do, not factory.py | ||
data = { | ||
"base_attrs": self.widget.attrs, | ||
"extra_attrs": {"paragraph": markdown.markdown(paragraph)} | ||
} | ||
attrs = self.widget.build_attrs(**data) | ||
self.widget.attrs = attrs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.5 on 2017-09-08 11:58 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import simplemde.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('formfactory', '0012_auto_20170703_1030'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='formfield', | ||
name='paragraph', | ||
field=simplemde.fields.SimpleMDEField(blank=True, help_text=b'Markdown for the formfactory ParagraphField and ParagraphWidget', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='action', | ||
name='action', | ||
field=models.CharField(choices=[(b'formfactory.actions.file_upload', b'formfactory.actions.file_upload'), (b'formfactory.actions.login', b'formfactory.actions.login'), (b'formfactory.actions.send_email', b'formfactory.actions.send_email'), (b'formfactory.actions.store_data', b'formfactory.actions.store_data')], max_length=128), | ||
), | ||
migrations.AlterField( | ||
model_name='customerrormessage', | ||
name='key', | ||
field=models.CharField(choices=[(b'empty', b'empty'), (b'incomplete', b'incomplete'), (b'invalid', b'invalid'), (b'invalid_choice', b'invalid_choice'), (b'invalid_image', b'invalid_image'), (b'invalid_list', b'invalid_list'), (b'invalid_date', b'invalid_date'), (b'invalid_time', b'invalid_time'), (b'invalid_pk_value', b'invalid_pk_value'), (b'list', b'list'), (b'max_decimal_places', b'max_decimal_places'), (b'max_digits', b'max_digits'), (b'max_length', b'max_length'), (b'max_value', b'max_value'), (b'max_whole_digits', b'max_whole_digits'), (b'min_length', b'min_length'), (b'min_value', b'min_value'), (b'missing', b'missing'), (b'required', b'required')], max_length=128), | ||
), | ||
migrations.AlterField( | ||
model_name='formfield', | ||
name='choices', | ||
field=models.ManyToManyField(blank=True, to='formfactory.FieldChoice'), | ||
), | ||
migrations.AlterField( | ||
model_name='formfield', | ||
name='field_type', | ||
field=models.CharField(choices=[(b'BooleanField', b'BooleanField'), (b'CharField', b'CharField'), (b'ChoiceField', b'ChoiceField'), (b'DateField', b'DateField'), (b'DateTimeField', b'DateTimeField'), (b'DecimalField', b'DecimalField'), (b'EmailField', b'EmailField'), (b'FileField', b'FileField'), (b'FloatField', b'FloatField'), (b'GenericIPAddressField', b'GenericIPAddressField'), (b'IntegerField', b'IntegerField'), (b'MultipleChoiceField', b'MultipleChoiceField'), (b'SlugField', b'SlugField'), (b'SplitDateTimeField', b'SplitDateTimeField'), (b'TimeField', b'TimeField'), (b'URLField', b'URLField'), (b'UUIDField', b'UUIDField'), (b'ParagraphField', b'formfactory.fields.ParagraphField')], max_length=128), | ||
), | ||
migrations.AlterField( | ||
model_name='formfield', | ||
name='widget', | ||
field=models.CharField(blank=True, choices=[(b'CheckboxInput', b'CheckboxInput'), (b'CheckboxSelectMultiple', b'CheckboxSelectMultiple'), (b'DateInput', b'DateInput'), (b'DateTimeInput', b'DateTimeInput'), (b'EmailInput', b'EmailInput'), (b'FileInput', b'FileInput'), (b'HiddenInput', b'HiddenInput'), (b'NullBooleanSelect', b'NullBooleanSelect'), (b'NumberInput', b'NumberInput'), (b'PasswordInput', b'PasswordInput'), (b'RadioSelect', b'RadioSelect'), (b'Select', b'Select'), (b'SelectMultiple', b'SelectMultiple'), (b'Textarea', b'Textarea'), (b'TextInput', b'TextInput'), (b'TimeInput', b'TimeInput'), (b'URLInput', b'URLInput'), (b'ParagraphWidget', b'formfactory.widgets.ParagraphWidget')], help_text='Leave blank if you prefer to use the default widget.', max_length=128, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.5 on 2017-09-08 13:54 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
import simplemde.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('formfactory', '0013_auto_20170908_1158'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='formfield', | ||
name='paragraph', | ||
field=simplemde.fields.SimpleMDEField(blank=True, help_text=b'Markdown for the formfactory ParagraphField and ParagraphWidget combination.', null=True), | ||
), | ||
] |
Oops, something went wrong.