mybuddy/babybuddy/apps.py

28 lines
768 B
Python
Raw Normal View History

2017-12-26 13:53:38 +00:00
# -*- coding: utf-8 -*-
import os
from django.apps import AppConfig
from django.conf import settings
from django.db.models.signals import post_migrate
2017-12-26 13:53:38 +00:00
from babybuddy import VERSION
def create_read_only_group(sender, **kwargs):
from django.contrib.auth.models import Group
Group.objects.get_or_create(name=settings.BABY_BUDDY["READ_ONLY_GROUP_NAME"])
2017-12-26 13:53:38 +00:00
class BabyBuddyConfig(AppConfig):
2022-02-10 00:00:30 +00:00
name = "babybuddy"
verbose_name = "Baby Buddy"
2017-12-26 13:53:38 +00:00
version = VERSION
version_string = VERSION
def ready(self):
2022-02-10 00:00:30 +00:00
if os.path.isfile(".git/refs/heads/master"):
commit = open(".git/refs/heads/master").read()
self.version_string += " ({})".format(commit[0:7])
post_migrate.connect(create_read_only_group, sender=self)