Prevent edit/delete for Chuck Norris user/person

This commit is contained in:
Lance Edgar 2016-12-07 22:07:12 -06:00
parent 220c6184aa
commit 7fe335a56d
3 changed files with 51 additions and 4 deletions

View file

@ -18,14 +18,13 @@ def bogus_error(request):
def includeme(config):
# TODO: merge these views into core/common
config.add_route('home', '/')
config.add_view(base.home, route_name='home', renderer='/home.mako')
config.add_route('bogus_error', '/bogus-error')
config.add_view(bogus_error, route_name='bogus_error',
permission='admin')
# TODO: merge above views into common
# core views
config.include('rattail_demo.web.views.common')
config.include('tailbone.views.auth')
@ -36,14 +35,14 @@ def includeme(config):
config.include('tailbone.views.departments')
config.include('tailbone.views.employees')
config.include('tailbone.views.families')
config.include('tailbone.views.people')
config.include('rattail_demo.web.views.people')
config.include('tailbone.views.products')
config.include('tailbone.views.reportcodes')
config.include('tailbone.views.roles')
config.include('tailbone.views.settings')
config.include('tailbone.views.stores')
config.include('tailbone.views.subdepartments')
config.include('tailbone.views.users')
config.include('rattail_demo.web.views.users')
config.include('tailbone.views.vendors')
# batch views

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
Person views
"""
from __future__ import unicode_literals, absolute_import
from tailbone.views import people as base
class PeopleView(base.PeopleView):
"""
Prevent edit/delete for Chuck Norris
"""
def editable_instance(self, person):
return person.uuid != '30d1fe06bcf411e6a7c23ca9f40bc550'
def deletable_instance(self, person):
return person.uuid != '30d1fe06bcf411e6a7c23ca9f40bc550'
def includeme(config):
PeopleView.defaults(config)

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
User views
"""
from __future__ import unicode_literals, absolute_import
from tailbone.views import users as base
class UsersView(base.UsersView):
"""
Prevent edit/delete for 'chuck'
"""
def editable_instance(self, user):
return user.uuid != '28eeee92bcf411e6a7c23ca9f40bc550'
def deletable_instance(self, user):
return user.uuid != '28eeee92bcf411e6a7c23ca9f40bc550'
def includeme(config):
UsersView.defaults(config)