2016-07-10 16:29:40 +00:00
|
|
|
from machines.models import Interface, Machine
|
2016-07-20 10:18:37 +00:00
|
|
|
from .settings import SITE_NAME
|
2016-07-10 02:14:47 +00:00
|
|
|
|
|
|
|
def context_user(request):
|
|
|
|
user = request.user
|
2016-07-10 16:29:40 +00:00
|
|
|
if user.is_authenticated():
|
2016-12-18 22:25:21 +00:00
|
|
|
interfaces = user.user_interfaces()
|
2016-07-10 16:29:40 +00:00
|
|
|
else:
|
|
|
|
interfaces = None
|
2016-07-10 02:14:47 +00:00
|
|
|
is_cableur = user.has_perms(('cableur',))
|
|
|
|
is_bureau = user.has_perms(('bureau',))
|
|
|
|
is_bofh = user.has_perms(('bofh',))
|
|
|
|
is_trez = user.has_perms(('trésorier',))
|
|
|
|
is_infra = user.has_perms(('infra',))
|
|
|
|
return {
|
|
|
|
'request_user': user,
|
|
|
|
'is_cableur': is_cableur,
|
|
|
|
'is_bureau': is_bureau,
|
|
|
|
'is_bofh': is_bofh,
|
|
|
|
'is_trez': is_trez,
|
|
|
|
'is_infra': is_infra,
|
2016-07-10 16:29:40 +00:00
|
|
|
'interfaces': interfaces,
|
2016-07-20 10:18:37 +00:00
|
|
|
'site_name': SITE_NAME,
|
2016-07-10 02:14:47 +00:00
|
|
|
}
|