Fields¶
Implementation of Field and subclasses. They are used in the templates.template.fields attribute.
Each one is responsible handling a part of data-procesing in the card-generation process. This allows easy
customization of templates.Template.
-
class
acg.fields.CheckChipOptionsField[source]¶ Bases:
acg.fields.OptionsFieldPick multiple options using
custom_widgets.selection_widgets.CheckChips.
-
class
acg.fields.CookBook[source]¶ Save recipes for construction of Classes with default values.
-
cook(self, name, **kwargs)¶ Generate object from recipe.
default_kwargs in recipe can be overridden by kwargs.
-
get_recipe_names(self)¶ Return list of all registered recipes.
-
get_recipes(self)¶ Return
recipes.
-
register(self, recipe_name, info=None, **kwargs)¶ Add recipe to
recipes.
Return dict in a form as used in
custom_widgets.CustomSpeedDial.button_dicts.
-
-
class
acg.fields.DisplayTextField[source]¶ Bases:
acg.fields.FieldOnly displays text.
-
class
acg.fields.DualLongTextField[source]¶ Bases:
acg.fields.TranslationMixin,acg.fields.OptionsFieldPick a single options using
custom_widgets.selection_widgets.CardCarousel.Useful for longer text, i.e. examples or explanations.
Inheritance from
TranslationMixinguarantees that translations are available.
-
class
acg.fields.Field[source]¶ Base-class for fields.
Accesses the data in
template.data, can perform actions on the obtained data and/or display it in a widget to allow user input to change it.-
get_content(self)[source]¶ If
widgetis set, usekv_bidictto extract.Calls
post_process()on the data before returning it.
-
update(self)[source]¶ Apply
pre_process()andupdate_widget_data().
-
-
class
acg.fields.ImgField[source]¶ Bases:
acg.fields.OptionsField,acg.fields.MediaFieldLet user choose between multiple images.
-
construct_widget(self)[source]¶ Bind
on_error()to child’son_errorevent.
-
-
class
acg.fields.MediaField[source]¶ Bases:
acg.fields.FieldHandles download of a single media-file and content of corresponding field.
The field should only contain the a single url.
-
class
acg.fields.OptionsField[source]¶ Bases:
acg.fields.FieldBase-class for a field with multiple options to choose from.
-
get_content(self)[source]¶ If
widgetis set, gets content from widget usingkv_bidict.If
selection_callbackis set, get content from call.Else simply get the first option as default.
-
update_widget_data(self)[source]¶ Update widget (if present) with data from
get_data().
-
-
class
acg.fields.TextInputField[source]¶ Bases:
acg.fields.FieldDisplays text and lets user edit it.
If callback is set, it will be called
on_text_validate, i.e. when the user presses enter while field is in focus.Useful to bind to
templates.Template.search()or templates.Template.update_from_single_parser.
-
class
acg.fields.TransChipOptionsField[source]¶ Bases:
acg.fields.TranslationMixin,acg.fields.OptionsFieldPick a single options using
custom_widgets.selection_widgets.MyTransChips.Inheritance from
TranslationMixinguarantees that translations are available.
-
class
acg.fields.TranslationMixin[source]¶ Mixin-Class that adds missing translations to the
target_fieldof thetemplate.datadict.
-
acg.fields.compress_img_bytes(bytes_image, width=512)[source]¶ Compress image given as bytes (e.g. as content of
requests.Response).