# Path: promises_instances/models.py
# class DDAHCategory(Category):
#     instance = models.ForeignKey(DDAHInstance, related_name='categories', null=True, blank=True)
#     order = models.PositiveIntegerField(default=0, blank=False, null=False)
# 
#     class Meta:
#         ordering = ('order', )
# 
# class DDAHPromise(Promise):
#     instance = models.ForeignKey(DDAHInstance, related_name='promises', null=True, blank=True)
# 
#     def save(self, *args, **kwargs):
#         if self.category is not None:
#             self.instance = self.category.instance
#         return super(DDAHPromise, self).save()


from promises.csv_loader import CsvProcessor
from promises_instances.models import DDAHCategory, DDAHPromise

class DDAHCSVProcessor(CsvProcessor):
    def __init__(self, file_, instance, **kwargs):
        self.instance = instance

# Path: promises_instances/models.py
# class DDAHCategory(Category):
#     instance = models.ForeignKey(DDAHInstance, related_name='categories', null=True, blank=True)
#     order = models.PositiveIntegerField(default=0, blank=False, null=False)
# 
#     class Meta:
#         ordering = ('order', )
# 
# class DDAHPromise(Promise):
#     instance = models.ForeignKey(DDAHInstance, related_name='promises', null=True, blank=True)
# 
#     def save(self, *args, **kwargs):
#         if self.category is not None:
#             self.instance = self.category.instance
#         return super(DDAHPromise, self).save()


# Path: promises_instances/csv_loader.py
from promises.csv_loader import CsvProcessor
from promises_instances.models import DDAHCategory, DDAHPromise


class DDAHCSVProcessor(CsvProcessor):
    def __init__(self, file_, instance, **kwargs):
        self.instance = instance

        cat_qs = DDAHCategory.objects.filter(instance=self.instance)