def update_themes(sender, **kwargs): instance = kwargs['instance'] try: shutil.rmtree(os.path.join(settings.THEMES_DIR, instance.name)) except OSError: pass set_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()
def delete_themes(sender, **kwargs): instance = kwargs['instance'] try: shutil.rmtree(os.path.join(settings.THEMES_DIR, instance.name)) except OSError: pass set_themes()
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()