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>
27 lines
721 B
Python
27 lines
721 B
Python
from __future__ import unicode_literals
|
|
|
|
from django.apps import apps
|
|
from django.contrib.auth import get_user_model
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
def get_user_label_text(context):
|
|
if not context['request'].user.is_authenticated:
|
|
return _('Anonymous')
|
|
else:
|
|
return context['request'].user.get_full_name() or context['request'].user
|
|
|
|
|
|
def lookup_get_groups():
|
|
Group = apps.get_model(app_label='auth', model_name='Group')
|
|
return ','.join([group.name for group in Group.objects.all()])
|
|
|
|
|
|
def lookup_get_users():
|
|
return ','.join(
|
|
[
|
|
user.get_full_name() or user.username
|
|
for user in get_user_model().objects.all()
|
|
]
|
|
)
|