46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from zope import component
|
|
from plone.registry.interfaces import IRegistry
|
|
from interfaces import ITabellioSettings
|
|
|
|
|
|
def get_dossiers_path():
|
|
return component.getUtility(IRegistry).forInterface(ITabellioSettings, False).dossiersPath
|
|
|
|
def get_documents_path():
|
|
return component.getUtility(IRegistry).forInterface(ITabellioSettings, False).documentsPath
|
|
|
|
def get_deputies_path():
|
|
return component.getUtility(IRegistry).forInterface(ITabellioSettings, False).deputiesPath
|
|
|
|
def get_sessions():
|
|
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
|
sessions = settings.sessions
|
|
if not sessions:
|
|
return []
|
|
terms = [x.split(':')[1].strip() for x in sessions.splitlines() if x]
|
|
return terms
|
|
|
|
def get_legisl_and_sessions():
|
|
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
|
sessions = settings.sessions
|
|
if not sessions:
|
|
return []
|
|
terms = []
|
|
current_legisl = None
|
|
for term in sessions.splitlines():
|
|
legisl, session = term.strip().split(':')
|
|
if legisl != current_legisl:
|
|
terms.append(legisl)
|
|
current_legisl = legisl
|
|
terms.append('-- %s' % session)
|
|
return terms
|
|
|
|
def get_list_of_sessions(legisl_or_session):
|
|
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
|
if not legisl_or_session.startswith('--'):
|
|
return [x.split(':')[1].strip() for x in settings.sessions.splitlines() if x.split(':')[0] == legisl_or_session]
|
|
else:
|
|
return [legisl_or_session[3:]]
|