easymode.admin.utils
Fields to be used in models.
-
class easymode.admin.models.fields.FlashUrlField(*args, **kwargs)
A field that is an url in flash.
A valid flash url must be one of:
- an absolute url, eg. http://example.com/
- a relative url, eg. /main/chapter
- a flash url with a hash eg. #/main/chapter
-
class easymode.admin.models.fields.RelativeFilePathField(base, relative_path, match=None, recursive=False, required=True, widget=None, label=None, initial=None, help_text=None, path='', *args, **kwargs)
A FilePathField which stores paths as relative paths.
Parameters: |
- base – The base path, this base path will NOT be in the database (eg. settings.PROJECT_DIR).
- relative_path – The relative part of the path, which will be in the database, together with the filename.
|
-
class easymode.admin.models.fields.XmlField(*args, **kwargs)
Used to store XML.
When using easymode.tree.xml(), all data is escaped and
html tags are turned into entities. Using this field will make
sure the escaping is skipped, so xml is rendered unmodified.
-
class easymode.admin.models.fields.SafeTextField(*args, **kwargs)
Removes all cariage returns from the input.
This class should be used instead of django.db.models.TextField, if you
want to use easymode’s gettext facilities. It will strip all cariage returns from
the input. Cariage returns are an error when included in gettext message id’s. It
also allows you to specify the number of rows and columns of the textarea.
Parameters: |
- rows – The number of rows of the textarea.
- cols – The number of columns of the textarea.
|
-
class easymode.admin.models.fields.SafeHTMLField(*args, **kwargs)
A html field with the following properties:
- Escapes cariage returns
- Will render as html, without escaping < and >
- Validates that html and will log errors when invalid html
is discovered, instead of crash.
- Allows the max_length attribute, the max_length is then computed,
without counting markup. Also html entities are converted to normal
characters before measuring the length as well.
- accepts tinymce configuration options.
usage:
html = SafeHTMLField(_('some rich text'), max_length=200, width=300, height=100, buttons="link,unlink,code")
Parameters: |
- max_length – The maximum length of the text, after stripping markup and
converting html entities to normal characters.
- width – The width of the html editor in the admin
- height – The height of the html editor in the admin
- buttons – Configuration for the
theme_advanced_buttons1.
The default is “bullist,numlist,|,undo,redo,|,link,unlink,|,code,|,cleanup,removeformat”.
|