initial upload
This commit is contained in:
67
monaem/layout.py
Normal file
67
monaem/layout.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# -*- coding: utf8 -*-
|
||||
from pyramid_layout.layout import layout_config
|
||||
from .security import groupfinder
|
||||
from datetime import *
|
||||
|
||||
from .views.default import (
|
||||
to_euro,
|
||||
to_euroz,
|
||||
to_percent,
|
||||
toSemaine,
|
||||
)
|
||||
from .models.inscriptions import (
|
||||
nextWorkingDay,
|
||||
)
|
||||
|
||||
@layout_config(template='monaem:templates/layouts/global_layout.pt')
|
||||
class GlobalLayout(object):
|
||||
page_title = "Mon espace MARIETTON"
|
||||
|
||||
def __init__(self, context, request):
|
||||
self.context = context
|
||||
self.request = request
|
||||
self.home_url = request.application_url
|
||||
|
||||
def to_euro(self, x):
|
||||
return to_euro(x)
|
||||
|
||||
def to_euroz(self, x):
|
||||
return to_euroz(x)
|
||||
|
||||
def to_percent(self, x):
|
||||
return to_percent(x)
|
||||
|
||||
def get_nextPayment(self, dossier):
|
||||
return get_nextPayment(dossier)
|
||||
|
||||
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 datesCode(self, dateCode):
|
||||
# calculer les 3 jours du stage de code commençant par dateCode
|
||||
lib = dateCode.strftime('%a %d') + ', '
|
||||
if dateCode.weekday() == 5 :
|
||||
# stage code le samedi, incrément = 7 jours
|
||||
incr = 7
|
||||
else:
|
||||
# stage code en semaine
|
||||
incr = 1
|
||||
dc = dateCode + timedelta(days = incr) # incrément = 1 jour
|
||||
dateCode = nextWorkingDay(dc) # saute 1 jour si jour férié
|
||||
lib = lib + dateCode.strftime('%a %d') + ' et '
|
||||
dc = dateCode + timedelta(days = incr) # incrément = 1 jour
|
||||
dateCode = nextWorkingDay(dc) # saute 1 jour si jour férié
|
||||
lib = lib + dateCode.strftime('%a %d %b %Y')
|
||||
|
||||
return toSemaine(lib)
|
||||
Reference in New Issue
Block a user