2.2. Content¶
- class lfc.models.Portal(*args, **kwargs)¶
A portal is the root of all content objects. Stores global images and some general data about the site.
Attributes:
- title:
- The title is displayed within the title tab of the site.
- standard:
- The object that is displayed if one browses to the root of the portal.
- from_email
- The e-mail address that is used as sender of outgoing mails.
- notification_emails
- These e-mail address get all notification mails. For instance all messages which are sent via the contact form to the portal.
- allow_comments
- Turns comments on/off generally.
- images
- The images which are associated with the portal. These images are considered global and can be used within any text editor field.
- files
- The files which are associated with the portal. These files are considered global and can be used within any text editor field.
- are_comments_allowed()¶
- Returns whether comments are allowed globally or not.
- get_children(request=None, *args, **kwargs)¶
- Returns the children of the portal. If the request is passed the permissions of the current user is taken into account. Additionally other valid filters can be passed, e.g. slug = “page-1”.
- get_notification_emails()¶
- Returns the notification e-mail addresses as list.
- get_parent_for_portlets()¶
- Fullfills the contract of django-portlets. Returns just None as there is no parent for portlets.
- get_template()¶
- Returns the current template of the portal.
- class lfc.models.BaseContent(*args, **kwargs)¶
Base content object. From this class all content types should inherit. It should never be instantiated.
Attributes:
- content_type
- The content type of the specific content object.
- title
- The title of the object. By default this displayed on top of very object within the title tag of the HTML page (together with the portal’s title).
- display_title
- Set to false to hide the title within the HTML of the object. This can be helpful to provide a custom title within the text field of an object.
- slug
- The part of URL within the parent object. By default the absolute URL of an object is created by all involved content objects.
- description:
- The description of an object. This is used within the overview template and search results.
- position:
- The ordinal number of the object within the parent object. This is used to order the child objects of an object.
- language
- The language of the object’s content is in.
- canonical
- The base object of the object if the object is a translation another object.
- tags
- The tags of the object. Can be used to select certain objects or display a tag cloud.
- parent
- The parent object of an object. If set to None the object is a top object.
- template
- The current selected template of the object.
- standard
- The current selected standard object of the object. This can be selected out of the children of the object. If there is one, this is displayed instead of the object itself.
- exclude_from_navigation
- If set to True, the object is not displayed within the navigation (top tabs and navigation tree).
- exclude_from_search
- If set to True, the object is not displayed within search results.
- creator
- The user which has created this object.
- creation_date
- The date the object has been created.
- modification_date
- The date the object has been modified at last.
- publication_date
- The date the object has been published. TODO: implement this.
- start_date
- if given the object is only public when the start date is reached.
- end_date
- if given the object is only public when the end date is not reached yet.
- meta_keywords
- The meta keywords of the object. This is displayed within the meta keywords tag of the rendered HTML.
- meta_description
- The meta description of the object. This is displayed within the meta description tag of the rendered HTML.
- images
- The images of the object.
- files
- The files of the object.
- allow_comments
- If set to true, the visitor of the object can leave a comment. If set to default the allow_comments state of the parent object is overtaken.
- searchable_text
- The content which is searched for this object. This attribute should not get directly. Rather the get_searchable_text method should be used.
- are_comments_allowed()¶
- Returns true if comments for this instance are allowed. Takes also the setup of parent objects into account (if the instance’ comments setup is set to “default”).
- form(**kwargs)¶
- Returns the add/edit form for the object. This method has to be overwritten and implemented by sub classes.
- get_ancestors()¶
- Returns all ancestors of a content object.
- get_ancestors_reverse()¶
- Returns all ancestors of the page in reverse order.
- get_canonical(request)¶
- Returns the canonical object of this instance. If the instance is the canonical object it returns itself. Takes care of the current user’s permission (therefore it needs the request).
- get_content_object()¶
- Returns the specific content object of the instance. This method can be called if one has a BaseContent and want the specific content type e.g. Page.
- get_descendants(request=None, result=None)¶
- Returns all descendants of the content object. If the request is passed the permissions of the current user is taken into account.
- get_image()¶
- Returns the first image of a content object. If there is none it returns None.
- get_meta_keywords()¶
- Returns the meta keywords of the instance. Replaces some placeholders with the according content.
- get_meta_description()¶
- Returns the meta description of the instance. Replaces some placeholders with the according content.
- get_searchable_text()¶
- Returns the searchable text of this content type. By default it takes the title the description of the instance into account. Sub classes can overwrite this method in order to add specific data.
- get_template()¶
- Returns the current selected template of the object.
- get_title()¶
- Returns the title of the object. Takes display_title into account.
- get_translation(request, language)¶
- Returns connected translation for requested language. Returns None if the requested language doesn’t exist.
- has_language(request, language)¶
- Returns true if there is a translation of the instance in the requested language. It returns also true if the instance itself is within the requested language or if there is a connected instance with neutral language.
- is_canonical()¶
- Returns true if the language of the page is the default language.
- is_translation()¶
- Returns true if the instance is a translation of another instance.
- get_parent_for_portlets()¶
- Returns the parent from which portlets should be inherited portlets. The implementation of this method is a requirement from django-portlets.