# Path: kraut_parser/models.py
# class Package(models.Model):
#     name = models.CharField(max_length=255)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     last_modified = models.DateTimeField(auto_now=True)
#     description = models.TextField(null=True, blank=True)
#     short_description = models.CharField(max_length=255, null=True, blank=True)
#     namespace = models.ManyToManyField('Namespace', blank=True)
#     version = models.CharField(max_length=255)
#     package_id = models.CharField(max_length=255)
#     source = models.CharField(max_length=255)
#     produced_time = models.DateTimeField(null=True, blank=True)
#     threat_actors = models.ManyToManyField('ThreatActor', blank=True)
#     campaigns = models.ManyToManyField('Campaign', blank=True)
#     indicators = models.ManyToManyField('Indicator', blank=True)
#     observables = models.ManyToManyField('Observable', blank=True)
#     ttps = models.ManyToManyField('TTP', blank=True)
# 
#     def __unicode__(self):
#         return u"%s" % (self.name)
# 
# class ThreatActor(models.Model):
#     name = models.CharField(max_length=255)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     last_modified = models.DateTimeField(auto_now=True)
#     description = models.TextField(null=True, blank=True)
#     short_description = models.CharField(max_length=255, null=True, blank=True)
#     namespace = models.ManyToManyField('Namespace', blank=True)
#     campaigns = models.ManyToManyField(Campaign, blank=True)
#     associated_threat_actors = models.ManyToManyField('self', blank=True)
#     threat_actor_id = models.CharField(max_length=255)
#     observed_ttps = models.ManyToManyField(TTP, through='ObservedTTP', symmetrical=False, related_name='ttp_observed_at_ta', blank=True)
# 
#     def add_observed_ttp(self, ttp, relationship):
#         obs_ttp, obs_ttp_created = ObservedTTP.objects.get_or_create(
#             ta=self,
#             ttp=ttp,
#             relationship=relationship
#         )
#         return obs_ttp
# 
#     def __unicode__(self):
#         return u"%s" % (self.name)
# 
# Path: kraut_intel/models.py
# class PackageComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     package_reference = models.ForeignKey(Package, on_delete=models.CASCADE)
# 
# class ThreatActorComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     actor_reference = models.ForeignKey(ThreatActor, on_delete=models.CASCADE)
# 
# class CampaignComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     campaign_reference = models.ForeignKey(Campaign, on_delete=models.CASCADE)
# 
# class TTPComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     ttp_reference = models.ForeignKey(TTP, on_delete=models.CASCADE)
# 
# class IndicatorComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     indicator_reference = models.ForeignKey(Indicator, on_delete=models.CASCADE)
# 
# class ObservableComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     observable_reference = models.ForeignKey(Observable, on_delete=models.CASCADE)


from django.forms import ModelForm
from kraut_parser.models import Package, ThreatActor
from kraut_intel.models import PackageComment, ThreatActorComment, CampaignComment, TTPComment, IndicatorComment, ObservableComment
    def __init__(self, *args, **kwargs):
        super(CampaignCommentForm, self).__init__(*args, **kwargs)
        self.fields['ctext'].widget.attrs.update({'class' : 'form-control', 'id': 'packageComment'})

################### TTP #####################

class TTPCommentForm(ModelForm):
    class Meta:
        model = TTPComment
        fields = ['ctext']

    def __init__(self, *args, **kwargs):
        super(TTPCommentForm, self).__init__(*args, **kwargs)
        self.fields['ctext'].widget.attrs.update({'class' : 'form-control', 'id': 'packageComment'})

################### INDICATOR #####################

class IndicatorCommentForm(ModelForm):
    class Meta:
        model = IndicatorComment
        fields = ['ctext']

    def __init__(self, *args, **kwargs):
        super(IndicatorCommentForm, self).__init__(*args, **kwargs)
        self.fields['ctext'].widget.attrs.update({'class' : 'form-control', 'id': 'packageComment'})

################### OBSERVABLE #####################

class ObservableCommentForm(ModelForm):
    class Meta:

# Path: kraut_parser/models.py
# class Package(models.Model):
#     name = models.CharField(max_length=255)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     last_modified = models.DateTimeField(auto_now=True)
#     description = models.TextField(null=True, blank=True)
#     short_description = models.CharField(max_length=255, null=True, blank=True)
#     namespace = models.ManyToManyField('Namespace', blank=True)
#     version = models.CharField(max_length=255)
#     package_id = models.CharField(max_length=255)
#     source = models.CharField(max_length=255)
#     produced_time = models.DateTimeField(null=True, blank=True)
#     threat_actors = models.ManyToManyField('ThreatActor', blank=True)
#     campaigns = models.ManyToManyField('Campaign', blank=True)
#     indicators = models.ManyToManyField('Indicator', blank=True)
#     observables = models.ManyToManyField('Observable', blank=True)
#     ttps = models.ManyToManyField('TTP', blank=True)
# 
#     def __unicode__(self):
#         return u"%s" % (self.name)
# 
# class ThreatActor(models.Model):
#     name = models.CharField(max_length=255)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     last_modified = models.DateTimeField(auto_now=True)
#     description = models.TextField(null=True, blank=True)
#     short_description = models.CharField(max_length=255, null=True, blank=True)
#     namespace = models.ManyToManyField('Namespace', blank=True)
#     campaigns = models.ManyToManyField(Campaign, blank=True)
#     associated_threat_actors = models.ManyToManyField('self', blank=True)
#     threat_actor_id = models.CharField(max_length=255)
#     observed_ttps = models.ManyToManyField(TTP, through='ObservedTTP', symmetrical=False, related_name='ttp_observed_at_ta', blank=True)
# 
#     def add_observed_ttp(self, ttp, relationship):
#         obs_ttp, obs_ttp_created = ObservedTTP.objects.get_or_create(
#             ta=self,
#             ttp=ttp,
#             relationship=relationship
#         )
#         return obs_ttp
# 
#     def __unicode__(self):
#         return u"%s" % (self.name)
# 
# Path: kraut_intel/models.py
# class PackageComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     package_reference = models.ForeignKey(Package, on_delete=models.CASCADE)
# 
# class ThreatActorComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     actor_reference = models.ForeignKey(ThreatActor, on_delete=models.CASCADE)
# 
# class CampaignComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     campaign_reference = models.ForeignKey(Campaign, on_delete=models.CASCADE)
# 
# class TTPComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     ttp_reference = models.ForeignKey(TTP, on_delete=models.CASCADE)
# 
# class IndicatorComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     indicator_reference = models.ForeignKey(Indicator, on_delete=models.CASCADE)
# 
# class ObservableComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     observable_reference = models.ForeignKey(Observable, on_delete=models.CASCADE)


# Path: kraut_intel/forms.py
from django.forms import ModelForm
from kraut_parser.models import Package, ThreatActor
from kraut_intel.models import PackageComment, ThreatActorComment, CampaignComment, TTPComment, IndicatorComment, ObservableComment

    def __init__(self, *args, **kwargs):
        super(CampaignCommentForm, self).__init__(*args, **kwargs)
        self.fields['ctext'].widget.attrs.update({'class' : 'form-control', 'id': 'packageComment'})

################### TTP #####################

class TTPCommentForm(ModelForm):
    class Meta:
        model = TTPComment
        fields = ['ctext']

    def __init__(self, *args, **kwargs):
        super(TTPCommentForm, self).__init__(*args, **kwargs)
        self.fields['ctext'].widget.attrs.update({'class' : 'form-control', 'id': 'packageComment'})

################### INDICATOR #####################

class IndicatorCommentForm(ModelForm):
    class Meta:
        model = IndicatorComment
        fields = ['ctext']

    def __init__(self, *args, **kwargs):
        super(IndicatorCommentForm, self).__init__(*args, **kwargs)
        self.fields['ctext'].widget.attrs.update({'class' : 'form-control', 'id': 'packageComment'})

################### OBSERVABLE #####################

class ObservableCommentForm(ModelForm):
    class Meta:

        model = ObservableComment