Project

General

Profile

« Previous | Next » 

Revision 602ecd07

Added by Frédéric Péters over 9 years ago

settings: add per-service settings, for non-default behaviours

Closes #5457

View differences:

calebasse/settings.py
295 295
# display events only for current service
296 296
CURRENT_SERVICE_EVENTS_ONLY = True
297 297

  
298
# dictionary to define non-default behaviours for some services
299
SERVICE_SETTINGS = {}
300

  
298 301
#CSV_ENCODING = 'cp1252' #For windows : windows-1252/Winlatin1
299 302
#CSVPROFILE = {\
300 303
#    'delimiter' : ';',
calebasse/utils.py
1 1
from django.contrib.auth.models import Group
2
from django.conf import settings
2 3

  
3 4
from datetime import timedelta, datetime
4 5

  
6
from .middleware.request import get_request
7

  
5 8
__EPOCH = datetime(day=5,month=1,year=1970)
6 9

  
7 10
def __date_to_datetime(date):
......
75 78
        return (97 - (nir % 97))
76 79
    except:
77 80
        return None
81

  
82
def get_service_setting(setting_name, default_value=None):
83
    from .cbv import HOME_SERVICE_COOKIE
84
    request = get_request()
85
    if not request:
86
        return None
87
    service = request.COOKIES.get(HOME_SERVICE_COOKIE)
88
    if not service:
89
        return None
90
    if not hasattr(settings, 'SERVICE_SETTINGS'):
91
        return None
92
    return settings.SERVICE_SETTINGS.get(service, {}).get(setting_name) or default_value

Also available in: Unified diff