Statistics
| Branch: | Tag: | Revision:

root / snf-branding / synnefo_branding / utils.py @ a2110608

History | View | Annotate | Download (732 Bytes)

1
from synnefo_branding import settings
2
from django.template.loader import render_to_string as django_render_to_string
3

    
4
def get_branding_dict(prepend=None):
5
        dct = {}
6
        for key in dir(settings):
7
                if key == key.upper():
8
                        newkey = key.lower()
9
                        if prepend:
10
                                newkey = '%s_%s' % (prepend, newkey)
11
                        dct[newkey.upper()] = getattr(settings, key)
12
        return dct
13

    
14
def brand_message(msg, **extra_args):
15
        params = get_branding_dict()
16
        params.update(extra_args)
17
        return msg % params
18

    
19
def render_to_string(template_name, dictionary=None, context_instance=None):
20
        if not dictionary:
21
                dictionary = {}
22
        newdict = get_branding_dict("BRANDING")
23
        newdict.update(dictionary)
24
        return django_render_to_string(template_name, newdict, context_instance)