On 14/12/2018 5:28 PM, maunish dave wrote:
My project contains two user one for managers and other for employees any suggestions?

Django contrib.auth already has groups and I use them for deciding what they can see vertically. Horizontally I use the ordinary relational mewchanisms.

Here is part of my utils.py for groups ... where 'name' is the group name ...

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
def is_author(user, name='author'):
    return is_member(user, name)

def is_authority(user, name='authority'):
    return is_member(user, name)

def is_consumer(user, name='consumer'):
    return is_member(user, name)

def is_editor(user, name='editor'):
    return is_member(user, name)

def is_manager(user, name='manager'):
    return is_member(user, name)

def is_useredit(user, name='useredit'):
    return is_member(user, name)
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
def is_member(user, name):
    return user.is_superuser or user.groups.filter(name=name).exists()
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALpJ3uJ%2BOu-tiv2beHU06ZN-6PhWDAqsivDvgvKZ_RUSXDFtUQ%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CALpJ3uJ%2BOu-tiv2beHU06ZN-6PhWDAqsivDvgvKZ_RUSXDFtUQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4833c678-655b-7fe3-5c63-0c6398857380%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to