# Path: kraut_incident/models.py
# class Incident(models.Model):
#     """Describe a security incident
#     """
#     incident_number = models.IntegerField(unique=True, default=random_incident_number)
#     title = models.CharField(max_length=255, default="Unnamed Incident")
#     description = models.TextField(null=True, blank=True)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     last_modified = models.DateTimeField(auto_now=True)
#     status = models.ForeignKey(Incident_Status, on_delete=models.CASCADE)
#     category = models.ForeignKey(Incident_Category, on_delete=models.CASCADE)
#     affected_assets = models.ManyToManyField(Asset, blank=True)
#     tasks = models.ManyToManyField(Task, blank=True)
#     incident_handler = models.ManyToManyField(Handler, blank=True, related_name="incident_handler")
#     contacts = models.ManyToManyField(Contact, blank=True, related_name="contacts")
#     severity_choices = (
#                 ('h', 'High'),
#                 ('m', 'Medium'),
#                 ('l', 'Low'),
#             )
#     severity = models.CharField(max_length=2, choices=severity_choices, default='m')
# 
#     def __unicode__(self):
#         return u"%s" % (self.title)
# 
# class Contact(models.Model):
#     """Describe a contact person
#     """
#     firstname = models.CharField(max_length=255)
#     lastname = models.CharField(max_length=255)
#     phone = models.CharField(max_length=255, blank=True)
#     email = models.EmailField(max_length=255)
#     description = models.TextField(null=True, blank=True)
# 
#     class Meta:
#         unique_together = (("firstname", "lastname", "email"),)
# 
# class Handler(models.Model):
#     """Describe an incident handler person
#     """
#     firstname = models.CharField(max_length=255)
#     lastname = models.CharField(max_length=255)
#     phone = models.CharField(max_length=255, blank=True)
#     email = models.EmailField(max_length=255)
#     description = models.TextField(null=True, blank=True)
# 
#     class Meta:
#         unique_together = (("firstname", "lastname", "email"),)
# 
# class IncidentComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     incident_reference = models.ForeignKey(Incident, on_delete=models.CASCADE)


from django.forms import ModelForm, widgets
from kraut_incident.models import Incident, Contact, Handler, IncidentComment
        fields = ["firstname", "lastname", "phone", "email", "description"]
        widgets = {
            'firstname': widgets.TextInput(attrs={'id': 'post_contact_firstname', 'class': 'form-control', 'placeholder': ''}),
            'lastname': widgets.TextInput(attrs={'id': 'post_contact_lastname', 'class': 'form-control', 'placeholder': ''}),
            'phone': widgets.TextInput(attrs={'id': 'post_contact_phone', 'class': 'form-control', 'placeholder': ''}),
            'email': widgets.EmailInput(attrs={'id': 'post_contact_email', 'class': 'form-control', 'placeholder': ''}),
            'description': widgets.Textarea(attrs={'id': 'post_contact_description', 'class': 'form-control', 'placeholder': 'What is this contact responsible for ...'}),
        }


class IncidentForm(ModelForm):
    class Meta:
        model = Incident
        fields = ['incident_number', 'title', 'description', 'status', 'category', 'severity']
        widgets = {
            'incident_number': widgets.NumberInput(attrs={'class': 'form-control', 'readonly': True, 'required': True}),
            'title': widgets.TextInput(attrs={'class': 'form-control', 'placeholder': 'Provide a name for the incident or investigation', 'required': True}),
            'description': widgets.Textarea(attrs={'class': 'form-control', 'placeholder': 'What and when did it happened ...'}),
            'status': widgets.Select(attrs={'class': 'form-control'}),
            'category': widgets.Select(attrs={'class': 'form-control'}),
            'severity': widgets.Select(attrs={'class': 'form-control'}),
        }

class IncidentCommentForm(ModelForm):
    class Meta:
        model = IncidentComment
        fields = ['ctext']

    def __init__(self, *args, **kwargs):
        super(IncidentCommentForm, self).__init__(*args, **kwargs)

# Path: kraut_incident/models.py
# class Incident(models.Model):
#     """Describe a security incident
#     """
#     incident_number = models.IntegerField(unique=True, default=random_incident_number)
#     title = models.CharField(max_length=255, default="Unnamed Incident")
#     description = models.TextField(null=True, blank=True)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     last_modified = models.DateTimeField(auto_now=True)
#     status = models.ForeignKey(Incident_Status, on_delete=models.CASCADE)
#     category = models.ForeignKey(Incident_Category, on_delete=models.CASCADE)
#     affected_assets = models.ManyToManyField(Asset, blank=True)
#     tasks = models.ManyToManyField(Task, blank=True)
#     incident_handler = models.ManyToManyField(Handler, blank=True, related_name="incident_handler")
#     contacts = models.ManyToManyField(Contact, blank=True, related_name="contacts")
#     severity_choices = (
#                 ('h', 'High'),
#                 ('m', 'Medium'),
#                 ('l', 'Low'),
#             )
#     severity = models.CharField(max_length=2, choices=severity_choices, default='m')
# 
#     def __unicode__(self):
#         return u"%s" % (self.title)
# 
# class Contact(models.Model):
#     """Describe a contact person
#     """
#     firstname = models.CharField(max_length=255)
#     lastname = models.CharField(max_length=255)
#     phone = models.CharField(max_length=255, blank=True)
#     email = models.EmailField(max_length=255)
#     description = models.TextField(null=True, blank=True)
# 
#     class Meta:
#         unique_together = (("firstname", "lastname", "email"),)
# 
# class Handler(models.Model):
#     """Describe an incident handler person
#     """
#     firstname = models.CharField(max_length=255)
#     lastname = models.CharField(max_length=255)
#     phone = models.CharField(max_length=255, blank=True)
#     email = models.EmailField(max_length=255)
#     description = models.TextField(null=True, blank=True)
# 
#     class Meta:
#         unique_together = (("firstname", "lastname", "email"),)
# 
# class IncidentComment(models.Model):
#     ctext = models.TextField()
#     author = models.ForeignKey(User, on_delete=models.CASCADE)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     incident_reference = models.ForeignKey(Incident, on_delete=models.CASCADE)


# Path: kraut_incident/forms.py
from django.forms import ModelForm, widgets
from kraut_incident.models import Incident, Contact, Handler, IncidentComment

        fields = ["firstname", "lastname", "phone", "email", "description"]
        widgets = {
            'firstname': widgets.TextInput(attrs={'id': 'post_contact_firstname', 'class': 'form-control', 'placeholder': ''}),
            'lastname': widgets.TextInput(attrs={'id': 'post_contact_lastname', 'class': 'form-control', 'placeholder': ''}),
            'phone': widgets.TextInput(attrs={'id': 'post_contact_phone', 'class': 'form-control', 'placeholder': ''}),
            'email': widgets.EmailInput(attrs={'id': 'post_contact_email', 'class': 'form-control', 'placeholder': ''}),
            'description': widgets.Textarea(attrs={'id': 'post_contact_description', 'class': 'form-control', 'placeholder': 'What is this contact responsible for ...'}),
        }


class IncidentForm(ModelForm):
    class Meta:
        model = Incident
        fields = ['incident_number', 'title', 'description', 'status', 'category', 'severity']
        widgets = {
            'incident_number': widgets.NumberInput(attrs={'class': 'form-control', 'readonly': True, 'required': True}),
            'title': widgets.TextInput(attrs={'class': 'form-control', 'placeholder': 'Provide a name for the incident or investigation', 'required': True}),
            'description': widgets.Textarea(attrs={'class': 'form-control', 'placeholder': 'What and when did it happened ...'}),
            'status': widgets.Select(attrs={'class': 'form-control'}),
            'category': widgets.Select(attrs={'class': 'form-control'}),
            'severity': widgets.Select(attrs={'class': 'form-control'}),
        }

class IncidentCommentForm(ModelForm):
    class Meta:
        model = IncidentComment
        fields = ['ctext']

    def __init__(self, *args, **kwargs):
        super(IncidentCommentForm, self).__init__(*args, **kwargs)

        self.fields['ctext'].widget.attrs.update({'class' : 'form-control', 'id': 'incidentComment'})