Permissions to view staff details per manager and per office

7 views
Skip to first unread message

Tommy

unread,
May 10, 2015, 9:28:22 AM5/10/15
to django...@googlegroups.com
Hi,

I am having difficulty getting my thoughts around my problem.

Given users (managerial, different levels) and depots/regional offices.

line_mangers should only see list of staff assigned to line_mangers group.

middle_managers should only see list of staff assigned from '1 to n' line_managers.

senior_manages should only see  list of staff assigned from '1 to n'  middle_managers in senior_manages depot/regional office.

executive_managers should see an overview of staff assigned to depots/regional offices.

I am looking at django-authority but it is unclear to me if this will work.

Q1. is what I seek row_object permissions, I am unsure of the terminology, I cannot get a understanding that I could explain to my grandmother. 

Q2. is it possible to have in my views.py a def that says something like
      if logged_in_user == manager_level and  is_assigned_office == office_n then view_only_staff_details == work_group and  region_office


models.py

class Employee(models.Model):
    first_name = models.CharField(max_length=75)
    surname = models.CharField(max_length=75)
    mname           = models.CharField(max_length=75, blank=True, null=True)

    def fullname(self):
        return '%s %s' % (self.first_name, self.surname)
    fullname = property(fullname)        

    def get_current_region(self):
eds = self.employeedynamic_set.filter(is_current=True)
if len(eds) > 1:
   return "Error more than one current depot for %s." % (self)
else:
   return eds[0].depot.region.name

class EmployeeDynamic(models.Model):
    employee = models.ForeignKey(Employee)    
    address = models.ForeignKey(Address)
    region         = models.ForeignKey(Region)
    depot         = models.ForeignKey(Depot)
    is_current = models.BooleanField()

I have sorted authenticated login by using django-userena 

Tommy.

Reply all
Reply to author
Forward
0 new messages