Change how we protect certain person, employee records
This commit is contained in:
parent
746db72046
commit
24cc4b4272
|
@ -164,15 +164,21 @@ class EmployeesView(MasterView):
|
||||||
if employee.status == self.enum.EMPLOYEE_STATUS_FORMER:
|
if employee.status == self.enum.EMPLOYEE_STATUS_FORMER:
|
||||||
return 'warning'
|
return 'warning'
|
||||||
|
|
||||||
|
def is_employee_protected(self, employee):
|
||||||
|
for user in employee.person.users:
|
||||||
|
if self.user_is_protected(user):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def editable_instance(self, employee):
|
def editable_instance(self, employee):
|
||||||
if self.rattail_config.demo():
|
if self.request.is_root:
|
||||||
return not bool(employee.user and employee.user.username == 'chuck')
|
return True
|
||||||
return True
|
return not self.is_employee_protected(employee)
|
||||||
|
|
||||||
def deletable_instance(self, employee):
|
def deletable_instance(self, employee):
|
||||||
if self.rattail_config.demo():
|
if self.request.is_root:
|
||||||
return not bool(employee.user and employee.user.username == 'chuck')
|
return True
|
||||||
return True
|
return not self.is_employee_protected(employee)
|
||||||
|
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
super(EmployeesView, self).configure_form(f)
|
super(EmployeesView, self).configure_form(f)
|
||||||
|
|
|
@ -145,15 +145,21 @@ class PeopleView(MasterView):
|
||||||
return instance.person
|
return instance.person
|
||||||
raise HTTPNotFound
|
raise HTTPNotFound
|
||||||
|
|
||||||
|
def is_person_protected(self, person):
|
||||||
|
for user in person.users:
|
||||||
|
if self.user_is_protected(user):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def editable_instance(self, person):
|
def editable_instance(self, person):
|
||||||
if self.rattail_config.demo():
|
if self.request.is_root:
|
||||||
return not bool(person.user and person.user.username == 'chuck')
|
return True
|
||||||
return True
|
return not self.is_person_protected(person)
|
||||||
|
|
||||||
def deletable_instance(self, person):
|
def deletable_instance(self, person):
|
||||||
if self.rattail_config.demo():
|
if self.request.is_root:
|
||||||
return not bool(person.user and person.user.username == 'chuck')
|
return True
|
||||||
return True
|
return not self.is_person_protected(person)
|
||||||
|
|
||||||
def delete_instance(self, person):
|
def delete_instance(self, person):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue