I need help. I need to grant permission on the value of the table to some functions. First I explain my model below.
class Permission(models.Model):
"""docstring for Permission"""
user = models.ForeignKey(User)
control_reactor = models.IntegerField(default=0)
find_reactor = models.IntegerField(default=0)
view_reactor = models.IntegerField(default=0)
I expect the table below.
id control_reactor view_reactor find_reactor user_id
1 1 1 1 2
2 0 1 0 1
Here, suppose whose user_id = 2registered on the site. and you need to set the resolution for below views.py.
views.py:
def home(request):
""" This function for home screen . """
return render(request, 'plant/home.html', {'count': 1})
def view_reactor(request):
""" This function for to get serch screen. """
return render(request, 'plant/view_reactor.html',
{'count': 1})
Here I need to use the decorator function i.e-@permission_required and @login_required. Suppose that you are user_id=2logged in, then he will check all permissions in the database, for example control_reactor=1,view_reactor=1,find_reactor=1, and everything will check the function home, and for the function view_reactorhe will check view_reactor=1or not. and the same process for user_id=1. Please help me.