70 lines
1.7 KiB
Python
70 lines
1.7 KiB
Python
# -*- coding: utf8 -*-
|
|
from pyramid_layout.layout import layout_config
|
|
from .security import groupfinder
|
|
from .views.default import (
|
|
to_euro,
|
|
to_euroz,
|
|
to_percent,
|
|
to_decimal,
|
|
to_decz,
|
|
)
|
|
|
|
@layout_config(template='templates/layouts/global_layout.pt')
|
|
class GlobalLayout(object):
|
|
# page_title = "Pagode Tinh-Do"
|
|
|
|
def __init__(self, context, request):
|
|
self.context = context
|
|
self.request = request
|
|
self.home_url = request.application_url
|
|
|
|
def to_decimal(self, x):
|
|
return to_decimal(x)
|
|
|
|
def to_euro(self, x):
|
|
return to_euro(x)
|
|
|
|
def to_euroz(self, x):
|
|
return to_euroz(x)
|
|
|
|
def to_decz(self, x):
|
|
return to_decz(x)
|
|
|
|
def to_percent(self, x):
|
|
return to_percent(x)
|
|
|
|
def date2dmy(self, ddate):
|
|
if ddate:
|
|
# si date, convertir en dd-mm-yyyy
|
|
madate = ddate.strftime('%d-%m-%Y')
|
|
else:
|
|
madate = ''
|
|
return madate
|
|
|
|
def isAnonymous(self):
|
|
user = self.request.authenticated_userid
|
|
return user is None
|
|
|
|
def isAdmin(self):
|
|
logged_in = self.request.authenticated_userid
|
|
is_admin = False
|
|
if logged_in is not None:
|
|
groups = groupfinder(logged_in, self.request)
|
|
if 'group:administrators' in groups:
|
|
is_admin = True
|
|
|
|
return is_admin
|
|
|
|
def isWebPage(self):
|
|
# test view name
|
|
if self.request.matched_route:
|
|
if self.request.matched_route.name == 'rdf_rapport':
|
|
# oui, page PDF
|
|
return False
|
|
else:
|
|
# non, page web
|
|
return True
|
|
else:
|
|
# non, page web
|
|
return True
|