# 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', )


from django.forms import ModelForm
from promises_instances.models import DDAHCategory


class CategoryCreateForm(ModelForm):
    def __init__(self, *args, **kwargs):
        self.ddah_instance = kwargs.pop('instance')
        super(CategoryCreateForm, self).__init__(*args, **kwargs)

    def save(self, commit=True):
        category = super(CategoryCreateForm, self).save(commit=False)
        category.instance = self.ddah_instance
        if commit:
            category.save()
        return category

    class Meta:

# 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', )


# Path: promises_forms/forms.py
from django.forms import ModelForm
from promises_instances.models import DDAHCategory



class CategoryCreateForm(ModelForm):
    def __init__(self, *args, **kwargs):
        self.ddah_instance = kwargs.pop('instance')
        super(CategoryCreateForm, self).__init__(*args, **kwargs)

    def save(self, commit=True):
        category = super(CategoryCreateForm, self).save(commit=False)
        category.instance = self.ddah_instance
        if commit:
            category.save()
        return category

    class Meta:

        model = DDAHCategory