repos
/ timestrap-django master

timestrap-django

mirror archived upstream

Time tracking you can host anywhere, built on Django. Full export support in multiple formats and easily extensible.

djangodockerhandcodedpythonself-hostedtime-trackingtimetracker

639 B · 24 lines · Python Raw History
 1from django.conf import settings
 2
 3from .middleware.site import current_request
 4from .models import Conf, Site
 5
 6
 7def current_site_id():
 8    """
 9    Return the ID of the current Site by checking for a Site in the current
10    request and falling back on the default ID in Django settings.
11    """
12    request = current_request()
13    site = getattr(request, "site", None)
14    if site:
15        site_id = getattr(site, "id", None)
16    else:
17        site_id = settings.SITE_ID
18    return site_id
19
20
21def get_site_setting(name):
22    site_conf = Conf.objects.get(site=Site.objects.get(id=current_site_id()))
23    return getattr(site_conf, name, None)