コード例 #1
0
ファイル: models.py プロジェクト: kod3r/django-cms-themes
def update_themes(sender, **kwargs):
    instance = kwargs['instance']
    try:
        shutil.rmtree(os.path.join(settings.THEMES_DIR, instance.name))
    except OSError: 
        pass
    set_themes()
コード例 #2
0
ファイル: models.py プロジェクト: kod3r/django-cms-themes
def extract_theme(sender, **kwargs):
    instance = kwargs['instance']
    if not instance.id:
        f = tarfile.open(fileobj=instance.theme_file, mode='r:gz')
        instance.name = f.getnames()[-1]
        f.extractall(settings.THEMES_DIR)
    set_themes()
コード例 #3
0
def delete_themes(sender, **kwargs):
    instance = kwargs['instance']
    try:
        shutil.rmtree(os.path.join(settings.THEMES_DIR, instance.name))
    except OSError:
        pass
    set_themes()
コード例 #4
0
def theme_site_m2m_changes(sender, **kwargs):
    instance = kwargs['instance']
    action = kwargs['action']
    if action in ("post_add", "post_remove", "post_clear"):
        if type(instance) is Theme:
            for site in instance.sites.all():
                for theme in site.theme_set.all():
                    if theme.id != instance.id:
                        site.theme_set.remove(theme)
        set_themes()
コード例 #5
0
def theme_site_m2m_changes(sender, **kwargs):
    instance = kwargs['instance']
    action = kwargs['action']
    if action in ("post_add", "post_remove", "post_clear"):
        if type(instance) is Theme:
            for site in instance.sites.all():
                for theme in site.theme_set.all():
                    if theme.id != instance.id:
                        site.theme_set.remove(theme)        
        set_themes()