fobi package

Subpackages

Submodules

fobi.admin module

fobi.app module

fobi.app.app_name(path, reduce_depth_by=1)[source]

Returns another path by reducing the depth by one.

Parameters:
  • path (str) – Absolute app path (from project root).
  • reduce_depth_by (int) –
Return str:
fobi.app.app_config(path, config_app_path='apps.Config')[source]
Parameters:
  • path (str) – Absolute app path (from project root).
  • config_app_path (str) – Relative config path (from app root)
Return str:

fobi.base module

All uids are supposed to be pythonic function names (see PEP http://www.python.org/dev/peps/pep-0008/#function-names).

class fobi.base.BaseDataStorage[source]

Bases: object

Base storage data.

class fobi.base.FormElementPluginDataStorage[source]

Bases: fobi.base.BaseDataStorage

Storage for FormField data.

class fobi.base.FormHandlerPluginDataStorage[source]

Bases: fobi.base.BaseDataStorage

Storage for FormField data.

class fobi.base.BasePluginForm[source]

Bases: object

Not a form actually. Defined for magic only.

Property iterable plugin_data_fields:
 

Fields to get when calling the get_plugin_data method. These field will be JSON serialized. All other fields, even if they are part of the form, won’t be. Make sure all fields are serializable. If some of them aren’t, override the save_plugin_data method and make them serializable there. See fobi.contrib.plugins.form_elements.fields.select.forms as a good example.

Example:
>>> plugin_data_fields = (
>>>    ('name', ''),
>>>    ('active': False)
>>> )
get_plugin_data(request=None, json_format=True)[source]

Data that would be saved in the plugin_data field of the fobi.models.FormElementEntry or ``fobi.models.FormHandlerEntry`.` subclassed model.

Parameters:request (django.http.HttpRequest) –
plugin_data_fields = None
save_plugin_data(request=None)[source]

Dummy, but necessary.

validate_plugin_data(form_element_entries, request=None)[source]
Parameters:
  • form_element_entries (iterable) – Iterable of fobi.models.FormElementEntry.
  • request (django.http.HttpRequest) –
Return bool:
class fobi.base.BasePlugin(user=None)[source]

Bases: object

Base form field from which every form field should inherit.

Properties:
  • uid (string): Plugin uid (obligatory). Example value: ‘dummy’,

    ‘wysiwyg’, ‘news’.

  • name (string): Plugin name (obligatory). Example value:

    ‘Dummy plugin’, ‘WYSIWYG’, ‘Latest news’.

  • description (string): Plugin decription (optional). Example

    value: ‘Dummy plugin used just for testing’.

  • help_text (string): Plugin help text (optional). This text would

    be shown in fobi.views.add_form_plugin_entry and fobi.views.edit_form_plugin_entry views.

  • form: Plugin form (optional). A subclass of django.forms.Form.

    Should be given in case plugin is configurable.

  • add_form_template (str) (optional): Add form template (optional).

    If given, overrides the

    fobi.views.add_form_handler_entry default template.

  • edit_form_template (string): Edit form template (optional). If

    given, overrides the fobi.views.edit_form_handler_entry default template.

  • html_classes (list): List of extra HTML classes for the plugin.

  • group (string): Plugin are grouped under the specified group.

    Override in your plugin if necessary.

add_form_template = None
clone_plugin_data(entry)[source]

Used when copying entries. If any objects or files are created by plugin, they should be cloned.

Parameters:fobi.models.AbstractPluginEntry – Instance of fobi.models.AbstractPluginEntry.
Return string:JSON dumped string of the cloned plugin data. The returned value would be inserted as is into the fobi.models.AbstractPluginEntry.plugin_data field.
delete_plugin_data()[source]

Used in fobi.views.delete_form_entry and fobi.views.delete_form_handler_entry. Fired automatically, when fobi.models.FormEntry object is about to be deleted. Make use of it if your plugin creates database records or files that are not monitored externally but by dash only.

description = None
edit_form_template = None
form = None
get_cloned_plugin_data(update={})[source]

Get the cloned plugin data and returns it in a JSON dumped format.

Parameters:update (dict) –
Return string:JSON dumped string of the cloned plugin data.
Example:
In the get_cloned_plugin_data method of your plugin, do as
follows:
>>> def clone_plugin_data(self, dashboard_entry):
>>>     cloned_image = clone_file(self.data.image, relative_path=True)
>>>     return self.get_cloned_plugin_data(update={'image': cloned_image})
get_form()[source]

Get the plugin form class. Override this method in your subclassed fobi.base.BasePlugin class when you need your plugin setup to vary depending on the placeholder, workspace, user or request given. By default returns the value of the form attribute defined in your plugin.

Return django.forms.Form|django.forms.ModelForm:
 Subclass of django.forms.Form or django.forms.ModelForm.
get_initialised_create_form(data=None, files=None)[source]

Used fobi.views.add_form_element_entry and fobi.views.add_form_handler_entry view to gets initialised form for object to be created.

get_initialised_create_form_or_404(data=None, files=None)[source]

Same as get_initialised_create_form but raises django.http.Http404 on errors.

get_initialised_edit_form(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)[source]

Used in fobi.views.edit_form_element_entry and fobi.views.edit_form_handler_entry views.

get_initialised_edit_form_or_404(data=None, files=None, auto_id='id_%s', prefix=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=':', empty_permitted=False)[source]

Same as get_initialised_edit_form but raises django.http.Http404 on errors.

get_instance()[source]
get_plugin_form_data()[source]

Fed as initial argument to the plugin form when initialising the instance for adding or editing the plugin. Override in your plugin class if you need customisations.

get_updated_plugin_data(update={})[source]

Get the plugin data and returns it in a JSON dumped format.

Parameters:update (dict) –
Return string:JSON dumped string of the cloned plugin data.
get_widget(request=None, as_instance=False)[source]

Gets the plugin widget.

Parameters:
  • request (django.http.HttpRequest) –
  • as_instance (bool) –
Return mixed:

Subclass of fobi.base.BasePluginWidget or instance of subclassed fobi.base.BasePluginWidget object.

group = 'General'
help_text = None
html_class[source]

A massive work on positioning the plugin and having it to be displayed in a given width is done here. We should be getting the plugin widget for the plugin given and based on its’ properties (static!) as well as on plugin position (which we have from model), we can show the plugin with the exact class.

html_classes = []
html_id[source]
load_plugin_data(plugin_data)[source]

Loads the plugin data saved in fobi.models.FormElementEntry or fobi.models.FormHandlerEntry. Plugin data is saved in JSON string.

Parameters:plugin_data (string) – JSON string with plugin data.
media_css = []
media_js = []
name = None
plugin_data_repr()[source]

Human readable representation of plugin data. A very basic way would be just:

>>> return self.data.__dict__
Return string:
post_processor()[source]

Redefine in your subclassed plugin when necessary.

Post process plugin data here (before rendering). This methid is being called after the data has been loaded into the plugin.

Note, that request (django.http.HttpRequest) is available (self.request).

pre_processor()[source]

Redefine in your subclassed plugin when necessary.

Pre process plugin data (before rendering). This method is being called before the data has been loaded into the plugin.

Note, that request (django.http.HttpRequest) is available ( self.request).

process(plugin_data=None, fetch_related_data=False)[source]

Init plugin with data.

process_plugin_data(fetch_related_data=False)[source]

Processes the plugin data.

render(request=None)[source]

Renders the plugin HTML.

Parameters:request (django.http.HttpRequest) –
Return string:
storage = None
uid = None
update_plugin_data(entry)[source]

Used in fobi.management.commands.fobi_update_plugin_data.

Some plugins would contain data fetched from various sources (models, remote data). Since form entries are by definition loaded extremely much, you are advised to store as much data as possible in plugin_data field of fobi.models.FormElementEntry or fobi.models.FormHandlerEntry. Some externally fetched data becomes invalid after some time and needs updating. For that purpose, in case if your plugin needs that, redefine this method in your plugin. If you need your data to be periodically updated, add a cron-job which would run fobi_update_plugin_data management command (see fobi.management.commands.fobi_update_plugin_data module).

Parameters:or fobi.models.FormHandlerEntry (fobi.models.FormElementEntry) – Instance of fobi.models.FormeHandlerEntry.
Return dict:Should return a dictionary containing data of fields to be updated.
widget = None
class fobi.base.FormElementPlugin(user=None)[source]

Bases: fobi.base.BasePlugin

Base form element plugin.

Property fobi.base.FormElementPluginDataStorage storage:
 
Property bool has_value:
 If set to False, ignored (removed) from the POST when processing the form.
get_form_field_instances()[source]

Gets the instances of form fields, that plugin contains.

Parameters:
  • form_element_entry (fobi.models.FormElementEntry) – Instance.
  • origin (string) –
  • kwargs_update_func (callable) –
  • return_func (callable) –
Return list:

List of Django form field instances.

Example:
>>> from django.forms.fields import CharField, IntegerField, TextField
>>> [CharField(max_length=100), IntegerField(), TextField()]
get_origin_kwargs_update_func_results(kwargs_update_func, form_element_entry, origin, extra={})[source]

If kwargs_update_func is given, is callable and returns results without failures, return the result. Otherwise - return None.

get_origin_return_func_results(return_func, form_element_entry, origin)[source]

If return_func is given, is callable and returns results without failures, return the result. Otherwise - return None.

has_value = False
storage

alias of FormElementPluginDataStorage

submit_plugin_form_data(form_entry, request, form)[source]

Submit plugin form data. Called on form submittion (when user actually posts the data to assembed form).

Parameters:
  • form_entry (fobi.models.FormEntry) – Instance of fobi.models.FormEntry.
  • request (django.http.HttpRequest) –
  • form (django.forms.Form) –
class fobi.base.FormHandlerPlugin(user=None)[source]

Bases: fobi.base.BasePlugin

Form handler plugin.

custom_actions(form_entry, request=None)[source]

Override this method in your form handler if you want to specify custom actions. Note, that expected return value of this method is an iterable with a triple, where the first item is the URL of the action and the second item is the action title and the third item is the icon class of the action.

Example:
>>>  return (
>>>      ('/add-to-favorites/',
>>>       'Add to favourites',
>>>       'glyphicon glyphicon-favourties'),
>>>  )
get_custom_actions(form_entry, request=None)[source]

Internal method to for obtaining the get_custom_actions.

run(form_entry, request, form)[source]

Custom code should be implemented here.

Parameters:
  • form_entry (fobi.models.FormEntry) – Instance of fobi.models.FormEntry.
  • request (django.http.HttpRequest) –
  • form (django.forms.Form) –
storage

alias of FormHandlerPluginDataStorage

class fobi.base.FormCallback[source]

Bases: object

Base form callback.

callback(form_entry, request, form)[source]

Custom callback code should be implemented here.

Parameters:
  • form_entry (fobi.models.FormEntry) – Instance of fobi.models.FormEntry.
  • request (django.http.HttpRequest) –
  • form (django.forms.Form) –
stage = None
class fobi.base.BaseRegistry[source]

Bases: object

Registry of dash plugins. It’s essential, that class registered has the uid property.

If fail_on_missing_plugin is set to True, an appropriate exception (plugin_not_found_exception_cls) is raised in cases if plugin cound’t be found in the registry.

Property mixed type:
 
Property bool fail_on_missing_plugin:
 
Property fobi.exceptions.DoesNotExist plugin_not_found_exception_cls:
 
Property str plugin_not_found_error_message:
 
fail_on_missing_plugin = False
get(uid, default=None)[source]

Gets the given entry from the registry.

Parameters:uid (string) –

:return mixed.

plugin_not_found_error_message = "Can't find plugin with uid `{0}` in `{1}` registry."
plugin_not_found_exception_cls

alias of DoesNotExist

register(cls, force=False)[source]

Registers the plugin in the registry.

:param mixed.

type = None
unregister(cls)[source]
class fobi.base.FormElementPluginRegistry[source]

Bases: fobi.base.BaseRegistry

Form element plugins registry.

fail_on_missing_plugin = True
plugin_not_found_exception_cls

alias of FormElementPluginDoesNotExist

type = (<class 'fobi.base.FormElementPlugin'>, <class 'fobi.base.FormFieldPlugin'>)
class fobi.base.FormHandlerPluginRegistry[source]

Bases: fobi.base.BaseRegistry

Form handler plugins registry.

fail_on_missing_plugin = True
plugin_not_found_exception_cls

alias of FormHandlerPluginDoesNotExist

type

alias of FormHandlerPlugin

class fobi.base.FormCallbackRegistry[source]

Bases: object

Registry of callbacks. Holds callbacks for stages listed in the fobi.constants.CALLBACK_STAGES.

get_callbacks(stage=None)[source]

Get callbacks for the stage given.

Parameters:stage (string) –
Return list:
register(cls)[source]

Registers the plugin in the registry.

:param mixed.

uidfy(cls)[source]

Makes a UID string from the class given.

Return string:
class fobi.base.ClassProperty[source]

Bases: property

fobi.base.classproperty

alias of ClassProperty

fobi.base.get_registered_plugins(registry)[source]

Gets a list of registered plugins in a form if tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
fobi.base.get_registered_plugin_uids(registry, flattern=True)[source]

Gets a list of registered plugin uids as a list . If not yet autodiscovered, autodiscovers them.

Return list:
fobi.base.get_registered_form_element_plugins()[source]

Gets a list of registered plugins in a form if tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
fobi.base.get_registered_form_element_plugin_uids(flattern=True)[source]

Gets a list of registered plugins in a form if tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
fobi.base.validate_form_element_plugin_uid(plugin_uid)[source]

Validates the plugin uid.

Parameters:plugin_uid (string) –
Return bool:
fobi.base.get_registered_form_handler_plugins()[source]

Gets a list of registered plugins in a form of tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
fobi.base.get_registered_form_handler_plugin_uids(flattern=True)[source]

Gets a list of registered plugins in a form of tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
fobi.base.validate_form_handler_plugin_uid(plugin_uid)[source]

Validates the plugin uid.

Parameters:plugin_uid (string) –
Return bool:
fobi.base.get_registered_form_callbacks(stage=None)[source]

Gets registered form callbacks for the stage given.

fobi.base.fire_form_callbacks(form_entry, request, form, stage=None)[source]

Fires callbacks.

Parameters:
  • form_entry (fobi.models.FormEntry) –
  • request (django.http.HttpRequest) –
  • form (django.forms.Form) –
  • stage (string) –
Return django.forms.Form form:
 
fobi.base.run_form_handlers(form_entry, request, form)[source]

Runs form handlers.

Parameters:
  • form_entry (fobi.models.FormEntry) –
  • request (django.http.HttpRequest) –
  • form (django.forms.Form) –
fobi.base.ensure_autodiscover()[source]

Ensures that plugins are autodiscovered.

fobi.base.collect_plugin_media(form_element_entries, request=None)[source]

Collects the plugin media for form element entries given.

Parameters:
  • form_element_entries (iterable) – Iterable of fobi.models.FormElementEntry instances.
  • request (django.http.HttpRequest) –
Return dict:

Returns a dict containing the ‘js’ and ‘css’ keys. Correspondent values of those keys are lists containing paths to the CSS and JS media files.

fobi.base.get_registered_themes()[source]

Gets a list of registered themes in form of tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
fobi.base.get_registered_theme_uids(flattern=True)[source]

Gets a list of registered themes in a form of tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
fobi.base.validate_theme_uid(plugin_uid)[source]

Validates the theme uid.

Parameters:plugin_uid (string) –
Return bool:
class fobi.base.BaseFormFieldPluginForm[source]

Bases: fobi.base.BasePluginForm

Base form for form field plugins.

help_text = <django.forms.fields.CharField object at 0x7fe6d13e2750>
label = <django.forms.fields.CharField object at 0x7fe6d13e2690>
name = <django.forms.fields.CharField object at 0x7fe6d13e2550>
plugin_data_fields = [('name', ''), ('label', ''), ('help_text', ''), ('required', False)]
required = <django.forms.fields.BooleanField object at 0x7fe6d13e2790>
validate_plugin_data(form_element_entries, request=None)[source]
Parameters:
  • form_element_entries (iterable) – Iterable of fobi.models.FormElementEntry.
  • request (django.http.HttpRequest) –
Return bool:
class fobi.base.FormFieldPlugin(user=None)[source]

Bases: fobi.base.FormElementPlugin

Form field plugin.

has_value = True
class fobi.base.FormElementPluginWidgetRegistry[source]

Bases: fobi.base.BasePluginWidgetRegistry

Registry of form element plugins.

type

alias of FormElementPluginWidget

class fobi.base.FormHandlerPluginWidgetRegistry[source]

Bases: fobi.base.BasePluginWidgetRegistry

Registry of form handler plugins.

type

alias of FormHandlerPluginWidget

class fobi.base.FormElementPluginWidget(plugin)[source]

Bases: fobi.base.BasePluginWidget

Form element plugin widget.

class fobi.base.FormHandlerPluginWidget(plugin)[source]

Bases: fobi.base.BasePluginWidget

Form handler plugin widget.

fobi.base.assemble_form_field_widget_class(base_class, plugin)[source]

Finish this or remove.

#TODO

fobi.compat module

fobi.conf module

fobi.conf.get_setting(setting, override=None)[source]

Get a setting from fobi conf module, falling back to the default.

If override is not None, it will be used instead of the setting.

Parameters:
  • setting – String with setting name
  • override – Value to use when no setting is available. Defaults to None.
Returns:

Setting value.

fobi.constants module

fobi.context_processors module

fobi.context_processors.theme(request)[source]

Gets active theme.

Parameters:request (django.http.HttpRequest) –
Return fobi.base.BaseTheme:
 Instance of fobi.base.BaseTheme.

fobi.data_structures module

class fobi.data_structures.SortableDict(data=None)[source]

Bases: dict

A dictionary that keeps its keys in the order in which they’re inserted. Very similar to (and partly based on) SortedDict of the Django, but has several additional methods implemented, such as: insert_before_key and insert_after_key.

clear()[source]
copy()[source]

Returns a copy of this object.

insert(index, key, value)[source]

Inserts the key, value pair before the item with the given index.

insert_after_key(target_key, key, value, fail_silently=True)[source]

Inserts the {key: value} after the target_key.

Parameters:
  • target_key (immutable) –
  • key (immutable) –
  • value (mutable) –
  • fail_silently (boolean) –
  • offset (int) –
Return bool:
insert_before_key(target_key, key, value, fail_silently=True, offset=0)[source]

Inserts the {key: value} before the target_key.

Parameters:
  • target_key (immutable) –
  • key (immutable) –
  • value (mutable) –
  • fail_silently (boolean) –
  • offset (int) –
Return bool:
items()[source]
iteritems()
iterkeys()
itervalues()
keys()[source]
move_after_key(source_key, target_key, fail_silently=True)[source]

Moves the {key: value} after the given source_key.

Parameters:
  • source_key (immutable) –
  • target_key (immutable) –
  • fail_silently (boolean) –
Return bool:
move_before_key(source_key, target_key, fail_silently=True, offset=0)[source]

Moves the {key: value} before the given source_key.

Parameters:
  • source_key (immutable) –
  • target_key (immutable) –
  • fail_silently (boolean) –
  • offset (int) –
Return bool:
pop(k, *args)[source]
popitem()[source]
setdefault(key, default)[source]
update(dict_)[source]
value_for_index(index)[source]

Returns the value of the item at the given zero-based index.

values()[source]

fobi.decorators module

fobi.decorators.permissions_required(perms, satisfy='all', login_url=None, raise_exception=False)[source]

Checks for the permissions given based on the strategy chosen.

Parameters:
  • perms (iterable) –
  • satisfy (string) – Allowed values are “all” and “any”.
  • login_url (string) –
  • raise_exception (bool) – If set to True, the PermissionDenied exception is raised on failures.
Return bool:
Example:
>>> @login_required
>>> @permissions_required(satisfy='any', perms=[
>>>     'fobi.add_formentry',
>>>     'fobi.change_formentry',
>>>     'fobi.delete_formentry',
>>>     'fobi.add_formelemententry',
>>>     'fobi.change_formelemententry',
>>>     'fobi.delete_formelemententry',
>>> ])
>>> def edit_dashboard(request):
>>>     # your code
fobi.decorators.all_permissions_required(perms, login_url=None, raise_exception=False)[source]
Example:
>>> @login_required
>>> @all_permissions_required([
>>>     'fobi.add_formentry',
>>>     'fobi.change_formentry',
>>>     'fobi.delete_formentry',
>>>     'fobi.add_formelemententry',
>>>     'fobi.change_formelemententry',
>>>     'fobi.delete_formelemententry',
>>> ])
>>> def edit_dashboard(request):
>>>     # your code
fobi.decorators.any_permission_required(perms, login_url=None, raise_exception=False)[source]
Example:
>>> @login_required
>>> @any_permission_required([
>>>     'fobi.add_formentry',
>>>     'fobi.change_formentry',
>>>     'fobi.delete_formentry',
>>>     'fobi.add_formelemententry',
>>>     'fobi.change_formelemententry',
>>>     'fobi.delete_formelemententry',
>>> ])
>>> def edit_dashboard(request):
>>>     # your code

fobi.defaults module

fobi.discover module

fobi.discover.autodiscover()[source]

Autodiscovers files that should be found by fobi.

fobi.dynamic module

fobi.dynamic.assemble_form_class(form_entry, base_class=<class 'django.forms.forms.BaseForm'>, request=None, origin=None, origin_kwargs_update_func=None, origin_return_func=None, form_element_entries=None)[source]

Assembles a form class by given entry.

Parameters:
  • form_entry
  • base_class
  • request (django.http.HttpRequest) –
  • origin (string) –
  • origin_kwargs_update_func (callable) –
  • origin_return_func (callable) –
  • form_element_entries (iterable) – If given, used instead of form_entry.formelemententry_set.all (no additional database hit).

fobi.exceptions module

exception fobi.exceptions.BaseException[source]

Bases: exceptions.Exception

Base exception.

exception fobi.exceptions.ImproperlyConfigured[source]

Bases: fobi.exceptions.BaseException

Exception raised when developer didn’t configure/write the code properly.

exception fobi.exceptions.InvalidRegistryItemType[source]

Bases: exceptions.ValueError, fobi.exceptions.BaseException

Raised when an attempt is made to register an item in the registry which does not have a proper type.

exception fobi.exceptions.DoesNotExist[source]

Bases: fobi.exceptions.BaseException

Raised when something does not exist.

exception fobi.exceptions.ThemeDoesNotExist[source]

Bases: fobi.exceptions.DoesNotExist

Raised when no theme with given uid can be found.

exception fobi.exceptions.PluginDoesNotExist[source]

Bases: fobi.exceptions.DoesNotExist

Raised when no plugin with given uid can be found.

exception fobi.exceptions.FormElementPluginDoesNotExist[source]

Bases: fobi.exceptions.PluginDoesNotExist

Raised when no form element plugin with given uid can be found.

exception fobi.exceptions.FormHandlerPluginDoesNotExist[source]

Bases: fobi.exceptions.PluginDoesNotExist

Raised when no form handler plugin with given uid can be found.

exception fobi.exceptions.NoDefaultThemeSet[source]

Bases: fobi.exceptions.ImproperlyConfigured

Raised when no active theme is chosen.

fobi.fields module

class fobi.fields.NoneField(required=True, widget=None, label=None, initial=None, help_text=u'', error_messages=None, show_hidden_initial=False, validators=, []localize=False)[source]

Bases: django.forms.fields.Field

To be used with content elements like text or images, that need to be present, for instance, in between form input elements.

bound_data(data, initial)[source]

Return the value that should be shown for this field on render of a bound form, given the submitted POST data for the field and the initial data, if any.

For most fields, this will simply be data; FileFields need to handle it a bit differently.

widget

alias of NoneWidget

fobi.form_importers module

class fobi.form_importers.BaseFormImporter(form_properties, form_data)[source]

Bases: object

Base importer.

description = None
extract_field_properties(field_data)[source]
field_properties_mapping = None
field_type_prop_name = None
fields_mapping = None
get_form_data()[source]
import_data()[source]

Imports data.

name = None
position_prop_name = None
uid = None
class fobi.form_importers.FormImporterPluginRegistry[source]

Bases: fobi.base.BaseRegistry

Form importer plugins registry.

type

alias of BaseFormImporter

fobi.forms module

fobi.helpers module

fobi.helpers.do_slugify(s)
fobi.helpers.lists_overlap(sub, main)[source]
fobi.helpers.iterable_to_dict(items, key_attr_name)[source]

Converts iterable of certain objects to dict.

Parameters:
  • items (iterable) –
  • key_attr_name (string) – Attribute to use as a dictionary key.
Return dict:
fobi.helpers.map_field_name_to_label(form)[source]

Takes a form and creates label to field name map.

Parameters:
  • form (django.forms.Form) – Instance of django.forms.Form.
  • keys_to_remove (list) –
Return dict:
fobi.helpers.clean_dict(source, keys=, []values=[])[source]

Removes given keys and values from dictionary.

Parameters:
  • source (dict) –
  • keys (iterable) –
  • values (iterable) –
Return dict:
fobi.helpers.two_dicts_to_string(headers, data, html_element='p')[source]

Takes two dictionaries, assuming one contains a mapping keys to titles and another keys to data. Joins as string and returns wrapped into HTML “p” tag.

fobi.helpers.ensure_unique_filename(destination)[source]

Makes sure filenames are never overwritten.

Parameters:destination (string) –
Return string:
fobi.helpers.handle_uploaded_file(upload_dir, image_file)[source]
Parameters:image_file (django.core.files.uploadedfile.InMemoryUploadedFile) –
Return string:Path to the image (relative).
fobi.helpers.delete_file(image_file)[source]

Delete file from disc.

fobi.helpers.clone_file(upload_dir, source_filename, relative_path=True)[source]

Clones the file.

Parameters:source_filename (string) – Source filename.
Return string:Filename of the cloned file.
fobi.helpers.get_registered_models(ignore=[])[source]

Gets registered models as list.

Parameters:ignore (iterable) – Ignore the following content types (should be in app_label.model format (example auth.User).
Return list:
fobi.helpers.admin_change_url(app_label, module_name, object_id, extra_path='', url_title=None)[source]

Gets an admin change URL for the object given.

Parameters:
  • app_label (str) –
  • module_name (str) –
  • object_id (int) –
  • extra_path (str) –
  • url_title (str) – If given, an HTML a tag is returned with url_title as the tag title. If left to None just the URL string is returned.
Return str:
fobi.helpers.uniquify_sequence(sequence)[source]

Makes sure items in the given sequence are unique, having the original order preserved.

Parameters:sequence (iterable) –
Return list:
fobi.helpers.safe_text(text)[source]

Safe text (encode).

Return str:
fobi.helpers.combine_dicts(headers, data)[source]

Takes two dictionaries, assuming one contains a mapping keys to titles and another keys to data. Joins as string and returns a result dict.

fobi.models module

fobi.settings module

  • RESTRICT_PLUGIN_ACCESS (bool): If set to True, (Django) permission system for fobi plugins is enabled.
  • FORM_ELEMENT_PLUGINS_MODULE_NAME (str): Name of the module to placed in the (external) apps in which the fobi form element plugin code should be implemented and registered.
  • FORM_HANDLER_PLUGINS_MODULE_NAME (str): Name of the module to placed in the (external) apps in which the fobi form handler plugin code should be implemented and registered.
  • FORM_CALLBACKS_MODULE_NAME (str): Name of the module to placed in the (external) apps in which the fobi form callback code should be implemented and registered.
  • FORM_HANDLER_PLUGINS_EXECUTION_ORDER (tuple): Order in which the form handler plugins are to be executed.
  • DEBUG

fobi.test module

fobi.utils module

fobi.views module

fobi.widgets module

class fobi.widgets.NoneWidget(attrs=None)[source]

Bases: django.forms.widgets.Widget

To be used with content elements.

media
render(name, value, attrs=None)[source]
class fobi.widgets.BooleanRadioSelect(*args, **kwargs)[source]

Bases: django.forms.widgets.RadioSelect

Boolean radio select for Django.

Example:
>>> class DummyForm(forms.Form):
>>>     agree = forms.BooleanField(label=_("Agree?"), required=False, widget=BooleanRadioSelect)
media

Module contents