Files
mayan-edms/mayan/apps/user_management/models.py
Roberto Rosario f65f363361 Refactor user management app
Add keyword arguments.

Update view resolutions and URL parameters to the '_id' form.

Remove code from create and edit subclasses and user
the super class error checking.

Cache the view object instead of using .get_object()
every time.

Movernize tests.

Update views to comply with MERCs 5 and 6.

Split UserTestMixin into mixins for Groups and Users tests.

Add super delete and detail tests.

Remove redundant superuser filtering from views.

Add transactions to views that also commit events.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
2019-01-29 13:35:10 -04:00

35 lines
1.0 KiB
Python

from __future__ import unicode_literals
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from .managers import UserOptionsManager
class UserOptions(models.Model):
"""
This model stores administrative configurations for an user accounts.
At the moment it stores a boolean flag to restrict an user's
ability to change their password.
"""
user = models.OneToOneField(
on_delete=models.CASCADE, related_name='user_options',
to=settings.AUTH_USER_MODEL, unique=True, verbose_name=_('User')
)
block_password_change = models.BooleanField(
default=False, verbose_name=_(
'Forbid this user from changing their password.'
)
)
objects = UserOptionsManager()
class Meta:
verbose_name = _('User settings')
verbose_name_plural = _('Users settings')
def natural_key(self):
return self.user.natural_key()
natural_key.dependencies = [settings.AUTH_USER_MODEL]