# Path: sfm/ui/utils.py
# def collection_path(collection, sfm_data_dir=None):
#     return collection_path_by_id(collection.collection_set.collection_set_id, collection.collection_id,
#                                  sfm_data_dir=sfm_data_dir)
# 
# def collection_set_path(collection_set, sfm_data_dir=None):
#     return collection_set_path_by_id(collection_set.collection_set_id, sfm_data_dir=sfm_data_dir)


from django.contrib.auth.models import AbstractUser, Group
from django.db import models
from django.utils import timezone
from jsonfield import JSONField
from simple_history.models import HistoricalRecords
from django.conf import settings
from django.db.models import F, Func, Value
from .utils import collection_path as get_collection_path, collection_set_path as get_collection_set_path
import django.db.models.options as options
import uuid
import datetime
import logging
import json
import os
import shutil
    def warcs_count(self):
        """
        Returns total number of WARC files harvested for this collection set.
        """
        return Harvest.objects.filter(collection__collection_set=self).aggregate(count=models.Sum("warcs_count"))[
                   "count"] or 0

    def warcs_bytes(self):
        """
        Returns total number of WARC bytes harvested for this collection set.
        """
        return Harvest.objects.filter(collection__collection_set=self).aggregate(total=models.Sum("warcs_bytes"))[
            "total"]

    def get_collection_set(self):
        return self

    def is_active(self):
        """
        Returns True is has any active collections
        """
        return Collection.objects.filter(collection_set=self).filter(is_active=True).exists()


def delete_collection_set_receiver(sender, **kwargs):
    """
    A post_delete receiver that is triggered when Collection Set model objects are deleted.
    """
    collection_set = kwargs["instance"]


# Path: sfm/ui/utils.py
# def collection_path(collection, sfm_data_dir=None):
#     return collection_path_by_id(collection.collection_set.collection_set_id, collection.collection_id,
#                                  sfm_data_dir=sfm_data_dir)
# 
# def collection_set_path(collection_set, sfm_data_dir=None):
#     return collection_set_path_by_id(collection_set.collection_set_id, sfm_data_dir=sfm_data_dir)


# Path: sfm/ui/models.py
from django.contrib.auth.models import AbstractUser, Group
from django.db import models
from django.utils import timezone
from jsonfield import JSONField
from simple_history.models import HistoricalRecords
from django.conf import settings
from django.db.models import F, Func, Value
from .utils import collection_path as get_collection_path, collection_set_path as get_collection_set_path
import django.db.models.options as options
import uuid
import datetime
import logging
import json
import os
import shutil

    def warcs_count(self):
        """
        Returns total number of WARC files harvested for this collection set.
        """
        return Harvest.objects.filter(collection__collection_set=self).aggregate(count=models.Sum("warcs_count"))[
                   "count"] or 0

    def warcs_bytes(self):
        """
        Returns total number of WARC bytes harvested for this collection set.
        """
        return Harvest.objects.filter(collection__collection_set=self).aggregate(total=models.Sum("warcs_bytes"))[
            "total"]

    def get_collection_set(self):
        return self

    def is_active(self):
        """
        Returns True is has any active collections
        """
        return Collection.objects.filter(collection_set=self).filter(is_active=True).exists()


def delete_collection_set_receiver(sender, **kwargs):
    """
    A post_delete receiver that is triggered when Collection Set model objects are deleted.
    """
    collection_set = kwargs["instance"]


    collection_set_path = get_collection_set_path(collection_set)