Blame view

src/pyrosapp/apps.py 676 Bytes
64501c9d   Etienne Pallier   first full projec...
1
from django.apps import AppConfig
9f81217f   haribo   Date: 22/06/2016
2
from django.conf import settings
64501c9d   Etienne Pallier   first full projec...
3
4
5

class PyrosappConfig(AppConfig):
    name = 'pyrosapp'
9f81217f   haribo   Date: 22/06/2016
6
7
8
9
10
11
12
13
14
15
16
17

    def ready(self):
        from pyrosapp.models import Version
        AppConfig.ready(self)
        versions = settings.MODULES_VERSIONS

        for module, version in versions.items():
            same_module_versions = Version.objects.filter(module_name=module)
            if same_module_versions.count() == 0:
                Version.objects.create(module_name=module, version=version)
            elif same_module_versions.order_by("-created")[0].version != version:
                Version.objects.create(module_name=module, version=version)