Portal Models

inyoka.portal.models

Models for the portal.

copyright:
  1. 2007-2024 by the Inyoka Team, see AUTHORS for more details.

license:

BSD, see LICENSE for more details.

class inyoka.portal.models.Linkmap(*args, **kwargs)

Provides an mapping for the interwikilinks from token to urls.

CACHE_KEY_CSS = 'portal:linkmap:css-filname'
CACHE_KEY_MAP = 'portal:linkmap'
exception DoesNotExist
exception MultipleObjectsReturned
_meta = <Options for Linkmap>
icon

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <inyoka.portal.models.LinkmapManager object>
token

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

token_validator = <django.core.validators.RegexValidator object>
url

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class inyoka.portal.models.LinkmapManager(*args, **kwargs)
flush_cache()

Removes all cache entries for the Linkmap model. This should be called, if entries of Linkmap were edited.

generate_css()

Generates for each token with icon in Linkmap a piece of css. Latter will display the icon near an interwiki link.

The css is saved at settings.INYOKA_INTERWIKI_CSS_PATH. Furthermore, a gzip-compressed version with the same content will be saved at the same place with a ‘.gz’ postfix.

A md5-hashsum is used to ensure that browser caches are flushed, if the content of the file changed.

Returns the basename of the current css file.

get_css_basename()

Returns the current basename (which includes a changing hash) of the current linkmap css. It will also trigger the creation of the css on startup or after a change to the linkmap (as the cache key should be deleted).

This method is mainly intended the be used for the template context.

get_linkmap()

Return a token-to-url-mapping as dictionary for our interwiki links.

class inyoka.portal.models.PrivateMessage(*args, **kwargs)

Private messages allow users to communicate with each other privately. This model represent one of these messages.

exception DoesNotExist
exception MultipleObjectsReturned
_meta = <Options for PrivateMessage>
author

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

property author_avatar
author_id
get_absolute_url(action='show')
get_next_by_pub_date(*, field=<django.db.models.fields.DateTimeField: pub_date>, is_next=True, **kwargs)
get_previous_by_pub_date(*, field=<django.db.models.fields.DateTimeField: pub_date>, is_next=False, **kwargs)
get_privatemessageentry_order()
static get_text_rendered(text, context=None)

Renders a specific text with the configuration of this field.

This is needed to render text that is not in the database (for example the preview).

The argument context has to be a RenderContext object or a dictonary containing additional keywordarguments to generate the RenderContext object.

This method is bound to the django models as staticmethod, so it can also be called from the Model and not only from the instance.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_text_in_cache()
objects = <django.db.models.manager.Manager object>
privatemessageentry_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

pub_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property recipients
remove_text_from_cache()
send(recipients)
set_privatemessageentry_order(id_list, using=None)
subject

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

text

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property text_rendered

Renders the content of the field.

class inyoka.portal.models.PrivateMessageEntry(*args, **kwargs)

A personal entry for each person who is affected by the private message. This entry can be moved between folders and stores the read status flag.

exception DoesNotExist
exception MultipleObjectsReturned
_meta = <Options for PrivateMessageEntry>
_order

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

archive()
delete()
classmethod delete_list(user_id, ids)
folder

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property folder_name
get_absolute_url(action='view')
get_folder_display(*, field=<django.db.models.fields.SmallIntegerField: folder>)
get_next_in_order(*, is_next=True)
get_previous_in_order(*, is_next=False)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property in_archive
property is_own_message
message

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

message_id
objects = <django.db.models.manager.Manager object>
read

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

restore()
user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_id
class inyoka.portal.models.StaticFile(id, identifier, file, is_ikhaya_icon)
exception DoesNotExist
exception MultipleObjectsReturned
_meta = <Options for StaticFile>
article_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

category_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

delete()
file

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
get_absolute_url(action='show')
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

identifier

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_ikhaya_icon

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class inyoka.portal.models.StaticPage(*args, **kwargs)

Stores static pages (imprint, license, etc.)

exception DoesNotExist
exception MultipleObjectsReturned
_meta = <Options for StaticPage>
content

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property content_rendered

Renders the content of the field.

get_absolute_url(action='show')
static get_content_rendered(text, context=None)

Renders a specific text with the configuration of this field.

This is needed to render text that is not in the database (for example the preview).

The argument context has to be a RenderContext object or a dictonary containing additional keywordarguments to generate the RenderContext object.

This method is bound to the django models as staticmethod, so it can also be called from the Model and not only from the instance.

is_content_in_cache()
key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
remove_content_from_cache()
title

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class inyoka.portal.models.Storage(id, key, value)
exception DoesNotExist
exception MultipleObjectsReturned
_meta = <Options for Storage>
static get_value_rendered(text, context=None)

Renders a specific text with the configuration of this field.

This is needed to render text that is not in the database (for example the preview).

The argument context has to be a RenderContext object or a dictonary containing additional keywordarguments to generate the RenderContext object.

This method is bound to the django models as staticmethod, so it can also be called from the Model and not only from the instance.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_value_in_cache()
key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
remove_value_from_cache()
value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property value_rendered

Renders the content of the field.

class inyoka.portal.models.Subscription(id, user, notified, ubuntu_version, content_type, object_id)
exception DoesNotExist
exception MultipleObjectsReturned
_meta = <Options for Subscription>
can_read(forum_id=None)
content_object

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

content_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_type_id
classmethod create_auto_subscription(user, topic)

Subscribes a user to the topic if the user has autosubscription enabled. Has no effect, if the user has the ‘autosubscribe’ setting off or is subscribed already.

Parameters

userUser

The user to subscribe.

topicTopic

The topic to subscribe the user to.

Returns

None.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_accessible_for_user
notified

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

object_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <inyoka.portal.models.SubscriptionManager object>
ubuntu_version

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_id
class inyoka.portal.models.SubscriptionManager(*args, **kwargs)

Manager class for the Subscription model.

_get_filter(user, object, ctype_query)
classmethod delete_list(user_id, ids)
get_for_user(user, object, ctype_query=None)
classmethod mark_read_list(user_id, ids)
user_subscribed(user, object, ctype_query=None, clear_notified=False)

Return True or False whether the user has subscribed or not