# Path: kraut_sharing/models.py
# class TAXII_Remote_Server(models.Model):
#     creation_time = models.DateTimeField(auto_now_add=True)
#     name = models.CharField(max_length=255, help_text="""Name/Identifier""")
#     host = models.CharField(max_length=255, help_text="""Hostname or IP address""")
#     port = models.IntegerField(help_text="""Remote port""", default=80)
#     protocol = models.CharField(max_length=5, help_text="""Protocol to use""", default="http")
#     path = models.CharField(max_length=255, help_text="""Path to service""")
#     version = models.CharField(max_length=5, help_text="""TAXII version to use""", default="1.1")
#     auth_type = models.IntegerField(default=0, help_text="""Authentication to use""")
#     last_discovery = models.DateTimeField(blank=True, null=True)
#     # TODO: fields for authentication (foreign key)
#     # TODO: proxy configuration
# 
#     def get_url(self):
#         return "%s://%s:%i%s" % (self.protocol, self.host, self.port, self.path)
# 
#     def __unicode__(self):
#         return u"%s (%s://%s:%i%s)" % (self.name, self.protocol, self.host, self.port, self.path)
# 
#     class Meta:
#         unique_together = (("name", "host", "port", "protocol", "path"),)
# 
# class TAXII_Remote_Collection(models.Model):
#     creation_time = models.DateTimeField(auto_now_add=True)
#     last_modified = models.DateTimeField(auto_now=True)
#     name = models.CharField(max_length=255, help_text="""name of the collection""", unique=True)
#     begin_timestamp = models.DateTimeField(blank=True, null=True)
#     end_timestamp = models.DateTimeField(blank=True, null=True)
#     server = models.ForeignKey("TAXII_Remote_Server", on_delete=models.CASCADE)
#     subscribed = models.BooleanField(default=False)
#     collection_type = models.CharField(max_length=255, default="DATA-FEED")
#     poll_period = models.IntegerField(default=24, help_text="""poll period in hours (e.g. 24 = every 24 hours)""")
# 
#     def __unicode__(self):
#         return u"%s" % (self.name)


from django import forms
from django.forms import ModelForm, widgets
from kraut_sharing.models import TAXII_Remote_Server, TAXII_Remote_Collection
        ('8', 'every 8 hours'),
        ('24', 'every 24 hours'),
    )
    poll = forms.ChoiceField(label='Poll periodically', widget=forms.Select(attrs={'class': 'form-control', 'id': 'polling'}), choices=poll_choices)

class AddServerForm(ModelForm):
    class Meta:
        model = TAXII_Remote_Server
        fields = ['name', 'host', 'path', 'port', 'protocol', 'version']
        widgets = {
            'name': widgets.TextInput(attrs={'id': 'post_server_name', 'class': 'form-control', 'placeholder': ''}),
            'host': widgets.TextInput(attrs={'id': 'post_server_host', 'class': 'form-control', 'placeholder': ''}),
            'port': widgets.NumberInput(attrs={'id': 'post_server_port', 'class': 'form-control', 'placeholder': '', 'readonly': True, 'required': True}),
            'path': widgets.TextInput(attrs={'id': 'post_server_path', 'class': 'form-control', 'placeholder': ''}),
            'version': widgets.TextInput(attrs={'id': 'post_server_version', 'class': 'form-control', 'placeholder': '', 'readonly': True, 'required': True}),
            'protocol': widgets.TextInput(attrs={'id': 'post_server_protocol', 'class': 'form-control', 'placeholder': '', 'readonly': True, 'required': True}),
        }

class AddCollectionForm(ModelForm):
    class Meta:
        model = TAXII_Remote_Collection
        fields = ['name', 'begin_timestamp', 'poll_period']
        widgets = {
            'name': widgets.TextInput(attrs={'id': 'post_collection_name', 'class': 'form-control', 'placeholder': ''}),
            'begin_timestamp': widgets.DateTimeInput(attrs={'id': 'post_begin_time', 'class': 'form-control', 'placeholder': ''}),
            'poll_period': widgets.NumberInput(attrs={'id': 'post_poll_period', 'class': 'form-control', 'placeholder': ''}),
        }

class EditCollectionForm(ModelForm):
    class Meta:

# Path: kraut_sharing/models.py
# class TAXII_Remote_Server(models.Model):
#     creation_time = models.DateTimeField(auto_now_add=True)
#     name = models.CharField(max_length=255, help_text="""Name/Identifier""")
#     host = models.CharField(max_length=255, help_text="""Hostname or IP address""")
#     port = models.IntegerField(help_text="""Remote port""", default=80)
#     protocol = models.CharField(max_length=5, help_text="""Protocol to use""", default="http")
#     path = models.CharField(max_length=255, help_text="""Path to service""")
#     version = models.CharField(max_length=5, help_text="""TAXII version to use""", default="1.1")
#     auth_type = models.IntegerField(default=0, help_text="""Authentication to use""")
#     last_discovery = models.DateTimeField(blank=True, null=True)
#     # TODO: fields for authentication (foreign key)
#     # TODO: proxy configuration
# 
#     def get_url(self):
#         return "%s://%s:%i%s" % (self.protocol, self.host, self.port, self.path)
# 
#     def __unicode__(self):
#         return u"%s (%s://%s:%i%s)" % (self.name, self.protocol, self.host, self.port, self.path)
# 
#     class Meta:
#         unique_together = (("name", "host", "port", "protocol", "path"),)
# 
# class TAXII_Remote_Collection(models.Model):
#     creation_time = models.DateTimeField(auto_now_add=True)
#     last_modified = models.DateTimeField(auto_now=True)
#     name = models.CharField(max_length=255, help_text="""name of the collection""", unique=True)
#     begin_timestamp = models.DateTimeField(blank=True, null=True)
#     end_timestamp = models.DateTimeField(blank=True, null=True)
#     server = models.ForeignKey("TAXII_Remote_Server", on_delete=models.CASCADE)
#     subscribed = models.BooleanField(default=False)
#     collection_type = models.CharField(max_length=255, default="DATA-FEED")
#     poll_period = models.IntegerField(default=24, help_text="""poll period in hours (e.g. 24 = every 24 hours)""")
# 
#     def __unicode__(self):
#         return u"%s" % (self.name)


# Path: kraut_sharing/forms.py
from django import forms
from django.forms import ModelForm, widgets
from kraut_sharing.models import TAXII_Remote_Server, TAXII_Remote_Collection

        ('8', 'every 8 hours'),
        ('24', 'every 24 hours'),
    )
    poll = forms.ChoiceField(label='Poll periodically', widget=forms.Select(attrs={'class': 'form-control', 'id': 'polling'}), choices=poll_choices)

class AddServerForm(ModelForm):
    class Meta:
        model = TAXII_Remote_Server
        fields = ['name', 'host', 'path', 'port', 'protocol', 'version']
        widgets = {
            'name': widgets.TextInput(attrs={'id': 'post_server_name', 'class': 'form-control', 'placeholder': ''}),
            'host': widgets.TextInput(attrs={'id': 'post_server_host', 'class': 'form-control', 'placeholder': ''}),
            'port': widgets.NumberInput(attrs={'id': 'post_server_port', 'class': 'form-control', 'placeholder': '', 'readonly': True, 'required': True}),
            'path': widgets.TextInput(attrs={'id': 'post_server_path', 'class': 'form-control', 'placeholder': ''}),
            'version': widgets.TextInput(attrs={'id': 'post_server_version', 'class': 'form-control', 'placeholder': '', 'readonly': True, 'required': True}),
            'protocol': widgets.TextInput(attrs={'id': 'post_server_protocol', 'class': 'form-control', 'placeholder': '', 'readonly': True, 'required': True}),
        }

class AddCollectionForm(ModelForm):
    class Meta:
        model = TAXII_Remote_Collection
        fields = ['name', 'begin_timestamp', 'poll_period']
        widgets = {
            'name': widgets.TextInput(attrs={'id': 'post_collection_name', 'class': 'form-control', 'placeholder': ''}),
            'begin_timestamp': widgets.DateTimeInput(attrs={'id': 'post_begin_time', 'class': 'form-control', 'placeholder': ''}),
            'poll_period': widgets.NumberInput(attrs={'id': 'post_poll_period', 'class': 'form-control', 'placeholder': ''}),
        }

class EditCollectionForm(ModelForm):
    class Meta:

        model = TAXII_Remote_Collection