# -*- coding: utf-8 -*-
'''
Created on Mar 22, 2013

@author: tc
'''

from django.core.management.base import BaseCommand, CommandError
from ldt.ldt_utils.models import Content
from taggit.models import Tag


class Command(BaseCommand):

    def handle(self, *args, **options):
        print("Going to remove opera contents, media and projects")
        
        l = list(Content.objects.filter(tags__name__in=["content_opera"]))
        
        for c in l:
            p = c.front_project
            c.front_project = None
            p.delete()
            c.media_obj.delete()
        
        print("Going to remove opera tags")
        Tag.objects.filter(name__startswith="opera_").delete()
            
        
        # This is the end
        print("This is the end")
        
        