Bit nicer source flow.
[redakcja.git] / src / sources / models.py
index 0b55c89..165cb67 100644 (file)
@@ -38,6 +38,10 @@ class Source(models.Model):
     def get_ocr_directory(self):
         return f'sources/ocr/{self.pk}/'
 
+    def has_upload_files(self):
+        d = os.path.join(settings.MEDIA_ROOT, self.get_upload_directory())
+        return os.path.isdir(d) and os.listdir(d)
+    
     def get_view_files(self):
         d = self.get_view_directory()
         return [
@@ -47,6 +51,10 @@ class Source(models.Model):
             ))
         ]
 
+    def has_view_files(self):
+        d = os.path.join(settings.MEDIA_ROOT, self.get_view_directory())
+        return os.path.isdir(d) and os.listdir(d)
+    
     def get_ocr_files(self):
         d = os.path.join(settings.MEDIA_ROOT, self.get_ocr_directory())
         return [
@@ -54,6 +62,10 @@ class Source(models.Model):
             for name in sorted(os.listdir(d))
         ]
 
+    def has_ocr_files(self):
+        d = os.path.join(settings.MEDIA_ROOT, self.get_ocr_directory())
+        return os.path.isdir(d) and os.listdir(d)
+
     def process(self):
         updir = os.path.join(
             settings.MEDIA_ROOT,