]> git.parisson.com Git - teleforma.git/commitdiff
add cleanup
authoryomguy <yomguy@parisson.com>
Thu, 19 Jul 2012 11:50:05 +0000 (13:50 +0200)
committeryomguy <yomguy@parisson.com>
Thu, 19 Jul 2012 11:50:05 +0000 (13:50 +0200)
teleforma/management/commands/teleforma-import-conferences.py

index 6ff5e54956b42a95ceccfa57e29f63f5facf010f..1025092c361ccf47023c0b36b0c52ae2b6059280 100644 (file)
@@ -35,6 +35,15 @@ class Command(BaseCommand):
     hdlr.setFormatter(formatter)
     logger.addHandler(hdlr)
 
+
+    def cleanup(self):
+        medias = Media.objects.all()
+        for media in medias:
+            media.delete()
+        items = MediaItem.objects.all()
+        for item in items:
+            item.delete()
+
     def handle(self, *args, **options):
         organization_name = args[0]
         organization = Organization.objects.get(name=organization_name)
@@ -43,14 +52,8 @@ class Command(BaseCommand):
         all_conferences = Conference.objects.all()
         i = 1
 
-        #FIXME:
-#        medias = Media.objects.all()
-#        for media in medias:
-#            media.delete()
-#        items = MediaItem.objects.all()
-#        for item in items:
-#            item.delete()
-
+       self.cleanup()
+               
         for root, dirs, files in os.walk(self.media_dir):
             for filename in files:
                 name = os.path.splitext(filename)[0]
@@ -75,8 +78,8 @@ class Command(BaseCommand):
                     exist = False
                     medias = conference.media.all()
                     for media in medias:
-                        print media.item.file
                         if media.item.file == path:
+                            print path
                             exist = True
                             break