Category¶
Todo
Docstrings (module, model, operations, utilities)
Models¶
-
class
indico.modules.categories.models.categories.
Category
(**kwargs)¶ Bases:
indico.core.db.sqlalchemy.searchable.SearchableTitleMixin
,indico.core.db.sqlalchemy.descriptions.DescriptionMixin
,indico.core.db.sqlalchemy.protection.ProtectionManagersMixin
,indico.core.db.sqlalchemy.attachments.AttachedItemsMixin
,sqlalchemy.orm.decl_api.Model
An Indico category.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
ATTACHMENT_FOLDER_ID_COLUMN
= 'category_id'¶
-
access_key
= None¶
-
acl_entries
¶
-
allow_no_access_contact
= True¶
-
allow_relationship_preloading
= True¶
-
can_create_events
(user)¶ Check whether the user can create events in the category.
-
chain_query
¶ Get a query object for the category chain.
The query retrieves the root category first and then all the intermediate categories up to (and including) this category.
-
children
¶
-
deep_children_query
¶ Get a query object for all subcategories.
This includes subcategories at any level of nesting.
-
default_badge_template
¶
-
default_badge_template_id
¶
-
default_event_themes
¶
-
default_render_mode
= 2¶
-
default_ticket_template
¶
-
default_ticket_template_id
¶
-
disallowed_protection_modes
= frozenset()¶
-
display_tzinfo
¶ The tzinfo of the category or the one specified by the user.
-
effective_icon_url
¶ Get the HTTP URL of the icon (possibly inherited).
-
event_creation_notification_emails
¶
-
event_creation_restricted
¶
-
event_message
¶
-
event_message_mode
¶
Get all hidden events within the given category and user.
-
classmethod
get_icon_data_cte
()¶
-
classmethod
get_protection_cte
()¶
-
get_protection_parent_cte
()¶
-
classmethod
get_root
()¶ Get the root category.
-
classmethod
get_tree_cte
(col='id')¶ Create a CTE for the category tree.
The CTE contains the following columns:
id
– the category idpath
– an array containing the path from the root to- the category itself
is_deleted
– whether the category is deleted
Parameters: col – The name of the column to use in the path or a callable receiving the category alias that must return the expression used for the ‘path’ retrieved by the CTE.
-
static
get_visible_categories_cte
(category_id)¶ Get a sqlalchemy select for the visible categories within the given category, including the category itself.
-
has_effective_icon
¶
-
has_icon
¶
-
has_logo
¶
-
icon
¶
-
icon_metadata
¶
-
icon_url
¶ Get the HTTP URL of the icon.
-
id
¶
-
inheriting_have_acl
= True¶
-
is_deleted
¶
-
is_descendant_of
(categ)¶
-
is_empty
¶
-
is_flat_view_enabled
¶
-
is_root
¶
-
locator
¶ Define a smart locator property.
This behaves pretty much like a normal read-only property and the decorated function should return a dict containing the necessary data to build a URL for the object.
This decorator should usually be applied to a method named
locator
as this name is required for get_locator to find it automatically when just passing the object.If you need more than one locator, you can define it like this:
@locator_property def locator(self): return {...} @locator.other def locator(self): return {...}
The
other
locator can then be accessed by passingobj.locator.other
to the code expecting an object with a locator.
-
logo
¶
-
logo_metadata
¶
-
logo_url
¶ Get the HTTP URL of the logo.
-
move
(target)¶ Move the category into another category.
-
notify_managers
¶
-
nth_parent
(n_categs, fail_on_overflow=True)¶ Return the nth parent of the category.
Parameters: - n_categs – the number of categories to go up
- fail_on_overflow – whether to fail if we try to go above the root category
Returns: Category object or None (only if
fail_on_overflow
is not set)
-
own_no_access_contact
¶
-
own_visibility_horizon
¶ Get the highest category this one would like to be visible from (configured visibility).
-
parent_chain_query
¶ Get a query object for the category’s parent chain.
The query retrieves the root category first and then all the intermediate categories up to (excluding) this category.
-
parent_id
¶
-
position
¶
-
possible_render_modes
= {<RenderMode.markdown: 2>}¶
-
protection_mode
¶
-
protection_parent
¶ The parent object to consult for ProtectionMode.inheriting.
-
real_visibility_horizon
¶ Get the highest category this one is actually visible from (as limited by categories above).
-
render_mode
= 2¶
-
suggestions_disabled
¶
-
timezone
¶
-
title
¶
-
tzinfo
¶
-
url
¶
-
visibility
¶
-
visibility_horizon_query
¶ Get a query object that returns the highest category this one is visible from.
-
visible_categories_query
¶ Get a query object for the visible categories within this category, including the category itself.
-
-
class
indico.modules.categories.models.categories.
EventMessageMode
¶ Bases:
indico.util.enum.RichIntEnum
An enumeration.
-
danger
= 3¶
-
disabled
= 0¶
-
info
= 1¶
-
warning
= 2¶
-
-
class
indico.modules.categories.models.principals.
CategoryPrincipal
(**kwargs)¶ Bases:
indico.core.db.sqlalchemy.principals.PrincipalPermissionsMixin
,sqlalchemy.orm.decl_api.Model
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
allow_category_roles
= True¶
-
allow_networks
= True¶
-
category_id
¶ The ID of the associated event
-
category_role
¶
-
category_role_id
¶
-
email
= None¶
-
event_role
= None¶
-
event_role_id
= None¶
-
full_access
¶
-
id
¶ The ID of the acl entry
-
ip_network_group
¶
-
ip_network_group_id
¶
-
local_group
¶
-
local_group_id
¶
-
multipass_group_name
¶
-
multipass_group_provider
¶
-
permissions
¶
-
principal_backref_name
= 'in_category_acls'¶
-
principal_for
= 'Category'¶
-
read_access
¶
-
registration_form
= None¶
-
registration_form_id
= None¶
-
type
¶
-
unique_columns
= ('category_id',)¶
-
user
¶
-
user_id
¶
-
-
class
indico.modules.categories.models.settings.
CategorySetting
(**kwargs)¶ Bases:
indico.core.settings.models.base.JSONSettingsBase
,sqlalchemy.orm.decl_api.Model
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
category
¶
-
category_id
¶
-
id
¶
-
module
¶
-
name
¶
-
value
¶
-
Operations¶
-
indico.modules.categories.operations.
create_category
(parent, data)¶
-
indico.modules.categories.operations.
delete_category
(category)¶
-
indico.modules.categories.operations.
move_category
(category, target_category)¶
-
indico.modules.categories.operations.
update_category
(category, data, skip=())¶
Utilities¶
-
indico.modules.categories.util.
get_attachment_count
(category_id=None)¶ Get the number of attachments in events in a category.
Parameters: category_id – The category ID to get statistics for. Attachments from subcategories are also included. Returns: The number of attachments
-
indico.modules.categories.util.
get_category_stats
(category_id=None)¶ Get category statistics.
This function is mainly a helper so we can get and cache all values at once and keep a last-update timestamp.
Parameters: category_id – The category ID to get statistics for. Subcategories are also included.
-
indico.modules.categories.util.
get_contribs_by_year
(category_id=None)¶ Get the number of contributions for each year.
Parameters: category_id – The category ID to get statistics for. Contributions from subcategories are also included. Returns: A dictionary mapping years to contribution counts.
-
indico.modules.categories.util.
get_events_by_year
(category_id=None)¶ Get the number of events for each year.
Parameters: category_id – The category ID to get statistics for. Events from subcategories are also included. Returns: A dictionary mapping years to event counts.
-
indico.modules.categories.util.
get_image_data
(image_type, category)¶
-
indico.modules.categories.util.
get_min_year
(category_id=None)¶ Get the min year.
Parameters: category_id – The category ID to get statistics for. Returns: The year.
-
indico.modules.categories.util.
get_upcoming_events
()¶ Get the global list of upcoming events.
-
indico.modules.categories.util.
get_visibility_options
(category_or_event, allow_invisible=True)¶ Return the visibility options available for the category or event.
-
indico.modules.categories.util.
serialize_category_role
(role, legacy=True)¶ Serialize role to JSON-like object.
-
indico.modules.categories.serialize.
serialize_categories_ical
(category_ids, user, event_filter=True, event_filter_fn=None, update_query=None)¶ Export the events in a category to iCal.
Parameters: - category_ids – Category IDs to export
- user – The user who needs to be able to access the events
- event_filter – A SQLalchemy criterion to restrict which events will be returned. Usually something involving the start/end date of the event.
- event_filter_fn – A callable that determines which events to include (after querying)
- update_query – A callable that can update the query used to retrieve the events. Must return the updated query object.
-
indico.modules.categories.serialize.
serialize_category
(category, with_favorite=False, with_path=False, parent_path=None, child_path=None)¶
-
indico.modules.categories.serialize.
serialize_category_atom
(category, url, user, event_filter)¶ Export the events in a category to Atom.
Parameters: - category – The category to export
- url – The URL of the feed
- user – The user who needs to be able to access the events
- event_filter – A SQLalchemy criterion to restrict which events will be returned. Usually something involving the start/end date of the event.
-
indico.modules.categories.serialize.
serialize_category_chain
(category, include_children=False, include_parents=False)¶
Settings¶
-
class
indico.modules.categories.settings.
CategorySettingsProxy
(module, defaults=None, strict=True, acls=None, converters=None)¶ Bases:
indico.core.settings.proxy.SettingsProxyBase
Proxy class to access category-specific settings for a certain module.
-
delete
(category, *names)¶ Delete settings.
Parameters: - category – Category (or its ID)
- names – One or more names of settings to delete
-
delete_all
(category)¶ Delete all settings.
Parameters: category – Category (or its ID)
-
get
(category, name, default=<object object>)¶ Retrieve the value of a single setting.
Parameters: - category – Category (or its ID)
- name – Setting name
- default – Default value in case the setting does not exist
Returns: The settings’s value or the default value
-
get_all
(category, no_defaults=False)¶ Retrieve all settings.
Parameters: - category – Category (or its ID)
- no_defaults – Only return existing settings and ignore defaults.
Returns: Dict containing the settings
-
query
¶ Return a query object filtering by the proxy’s module.
-
set
(category, name, value)¶ Set a single setting.
Parameters: - category – Category (or its ID)
- name – Setting name
- value – Setting value; must be JSON-serializable
-
set_multi
(category, items)¶ Set multiple settings at once.
Parameters: - category – Category (or its ID)
- items – Dict containing the new settings
-