Portal User
inyoka.portal.user
Our own user model used for implementing our own permission system and our own administration center.
- copyright:
2007-2024 by the Inyoka Team, see AUTHORS for more details.
- license:
BSD, see LICENSE for more details.
- class inyoka.portal.user.User(*args, **kwargs)
User model that contains all information about a user.
- exception DoesNotExist
- exception MultipleObjectsReturned
- STATUS_ACTIVE = 1
- STATUS_BANNED = 2
- STATUS_CHOICES = ((0, 'not yet activated'), (1, 'active'), (2, 'banned'), (3, 'deleted himself'))
- STATUS_DELETED = 3
- STATUS_INACTIVE = 0
- USERNAME_FIELD = 'username'
Assign the username field
- _meta = <Options for User>
- _readstatus
- 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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- avatar
Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.
- property avatar_url
- backend = 'inyoka.portal.auth.InyokaAuthBackend'
- banned_until
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- blog_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- comment_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- date_joined
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- email
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- email_user(subject, message, from_email=None)
Sends an e-mail to this User.
- entry_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- event_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- forum_read_status
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- forum_set
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- get_absolute_url(action='show', *args, **query)
- get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
- get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
- static get_signature_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.
- get_status_display(*, field=<django.db.models.fields.IntegerField: status>)
- gpgkey
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property gravatar_url
- groups
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- property has_avatar
- has_content()
Returns True if the user has any content, else False.
- has_perm(perm, obj=None)
Heavy cached version of has_perm() to save many DB Queries.
Stores cached Permissions inside our redis cache under /acl/<user.id> as JSON blob.
- has_perms(perm_list, obj=None)
Simplified version of has_perms() to load permissions from perm_list in our has_perm() cache.
Returns True if all permissions match, else False.
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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- icon
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property icon_url
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property is_active
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- property is_anonymous
Always return False. This is a way of comparing User objects to anonymous users.
- property is_authenticated
Always return True. This is a way to tell if the user has been authenticated in templates.
- property is_banned
- property is_deleted
- property is_inactive
- is_signature_in_cache()
- is_superuser
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property is_team_member
- jabber
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property jabber_url
- last_login
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- launchpad
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property launchpad_url
- location
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- member_title
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.user.UserManager object>
- owned_suggestion_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- password
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- pollvote_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- property post_count
- post_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- privatemessage_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- 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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- remove_signature_from_cache()
- rename(new_name, send_mail=True)
Rename method that checks for collision and if there is non, renames the users and if required sends a notification (default). Will raise a ValueError(‘invalid username’) exception if user name is invalid.
Returns True if the user is renamed or if the users current username is already new_name.
Returns False if a user with the new_name already exists.
- property rendered_userpage
- report_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- save(*args, **kwargs)
Save method that cleanups the cache after saving the model.
- settings
- signature
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property signature_rendered
Renders the content of the field.
- status
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- subscription_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- suggestion_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- topics
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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- unban()
Check if a user is banned, either permanent or temporary and remove the ban if possible.
Returns True if user is not banned or could be unbanned, or False otherwise.
- user_permissions
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- username
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- userobjectpermission_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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- userpage
Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurant
is aReverseOneToOneDescriptor
instance.
- website
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- wiki_revisions
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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- exception inyoka.portal.user.UserBanned
Simple exception that is raised while log-in to give the user a somewhat detailed exception.
- class inyoka.portal.user.UserManager(*args, **kwargs)
- create_user(username, email, password=None)
- get_anonymous_user()
- get_by_username_or_email(name)
Get a user by its username or email address
- get_system_user()
This returns the system user that is controlled by inyoka itself. It is the sender for welcome notices, it updates the antispam list and is the owner for log entries in the wiki triggered by inyoka itself.
- register_user(username, email, password, send_mail=True)
Create a new inactive user and send him an activation e-mail.
- Parameters:
- username
The username for the new user.
The user’s email. (It’s also where the activation mail will be sent to.)
- password
The user’s password.
- send_mail
Whether to send an activation mail or not. If False the user will be saved as active.
- class inyoka.portal.user.UserPage(id, user, content)
- exception DoesNotExist
- exception MultipleObjectsReturned
- _meta = <Options for UserPage>
- 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.
- 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.
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_content_in_cache()
- objects = <django.db.models.manager.Manager object>
- remove_content_from_cache()
- user
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.place
is aForwardOneToOneDescriptor
instance.
- user_id
- inyoka.portal.user.deactivate_user(user)
This deactivates a user and removes all personal information. To avoid abuse, an email is sent that allows reactivation of the account within the next month.
- inyoka.portal.user.reactivate_user(id, email, status)
- inyoka.portal.user.reset_email(id, email)
- inyoka.portal.user.send_activation_mail(user)
send an activation mail
- inyoka.portal.user.send_new_email_confirmation(user, email)
Send the user an email where he can confirm his new email address
- inyoka.portal.user.set_new_email(id, email)
Save the new email address the user has confirmed, and send an email to his old address where he can reset it to protect against abuse.
- inyoka.portal.user.update_user_flags(sender, request, user, **kwargs)
- inyoka.portal.user.upload_to_avatar(instance, filename)