Chief Django

How I Landed My Chief on a Separate View Rule in Django

In my project, when requesting the showinfo page, the user gets information about their work by default. This is convenient for direct work on the helpdesk. When user opening the page – he always see those tasks that he have completed or should perform.
But my boss, working with the reporting system, realized that it was more convenient for him to see the information of all users. But my account and his are in the same privileged group “manager”.
To land his account on the “all” tab, I had to cheat a little.

@login_required
def showinfo(request, user_id=1407):
    """Show all entries"""
#Checking if user is Chief - changing position argument of function for show ALL tab
    if request.user.id == 2 and user_id == 1407:
        user_id='all'

I check if the user is my chief and check if there is an argument for the function (1407 is the default in this case). If both conditions are confirmed, then I declare the necessary variables to display data about all users.

See also  How to separate menu between ordinary and privileged users in Django
Author: admin

1 thought on “How I Landed My Chief on a Separate View Rule in Django

Leave a Reply

Your email address will not be published. Required fields are marked *