# Path: events/models.py
# class Event(models.Model):
#     created_by = models.ForeignKey(User, on_delete=models.CASCADE)
#     name = models.CharField(max_length=300)
#     start_date = models.DateField(blank=True)
#     end_date = models.DateField(blank=True)
#     description = models.TextField(blank=True)
#     venue = models.CharField(max_length=300, blank=True)
# 
#     trainer_bio = models.TextField(blank=True)
#     no_of_participants = models.IntegerField(blank=True, default=0)
#     level = models.CharField(choices=LEVEL_CHOICES, max_length=100)
#     prerequisite = models.TextField(blank=True)
# 
#     travel = models.TextField(blank=True)
#     accommodation = models.TextField(blank=True)
#     expense = models.FloatField(blank=True, default=0)
#     lab_requirements = models.TextField(blank=True)
#     icts_support = models.TextField(blank=True)
# 
#     permissions = models.TextField(blank=True)
#     date_added = models.DateField(auto_now_add=True)
# 
#     is_approved = models.BooleanField(default=False)
#     is_published = models.BooleanField(default=False)
# 
#     def __str__(self):
#         return self.name
# 
# class EventImage(models.Model):
#     event = models.ForeignKey(Event, on_delete=models.CASCADE)
#     image = models.ImageField(upload_to='events/images/')
# 
#     def __str__(self):
#         return self.event.name


from django import forms
from events.models import Event, EventImage
                           widget=forms.TextInput(attrs={'placeholder': "Name"}))
    start_date = forms.DateTimeField(label="Enter start date and time",
                                    widget=forms.DateTimeInput())
    end_date = forms.DateTimeField(label="Enter end date and time",
                                  widget=forms.DateTimeInput())
    description = forms.CharField(label="Description", help_text="Description",
                                 widget=forms.Textarea(attrs={'placeholder': "Description"}))
    venue = forms.CharField(label="Venue", help_text="Venue",
                            widget=forms.TextInput(attrs={'placeholder': 'Venue'}))
    trainer_bio = forms.CharField(label="Trainer bio", help_text="Enter trainer bio")
    no_of_participants = forms.IntegerField(label="No of participants", help_text="Enter no of participants")
    level = forms.ChoiceField(choices=LEVEL_CHOICES, label="Level")
    prerequisite = forms.CharField(label="Prerequisite")
    travel = forms.CharField(label="Travel info", help_text="Enter travel data")
    accommodation = forms.CharField(label="Accomodation")
    expense = forms.FloatField(label="Expenses")
    lab_requirements = forms.CharField(label='Lab Requirements')
    icts_support = forms.CharField(label="ICTS support")

    def __init__(self, *args, **kwargs):
        super(EventCreateForm, self).__init__(*args, **kwargs)
        for field in iter(self.fields):
            self.fields[field].widget.attrs.update({'class': 'form-control'})
    class Meta:
        model = Event
        fields = ['name', 'start_date', 'end_date', 'description', 'venue', 'trainer_bio', 'no_of_participants',
                  'level', 'prerequisite', 'travel', 'accommodation', 'expense', 'lab_requirements', 'icts_support']


class EventImageForm(forms.ModelForm):

# Path: events/models.py
# class Event(models.Model):
#     created_by = models.ForeignKey(User, on_delete=models.CASCADE)
#     name = models.CharField(max_length=300)
#     start_date = models.DateField(blank=True)
#     end_date = models.DateField(blank=True)
#     description = models.TextField(blank=True)
#     venue = models.CharField(max_length=300, blank=True)
# 
#     trainer_bio = models.TextField(blank=True)
#     no_of_participants = models.IntegerField(blank=True, default=0)
#     level = models.CharField(choices=LEVEL_CHOICES, max_length=100)
#     prerequisite = models.TextField(blank=True)
# 
#     travel = models.TextField(blank=True)
#     accommodation = models.TextField(blank=True)
#     expense = models.FloatField(blank=True, default=0)
#     lab_requirements = models.TextField(blank=True)
#     icts_support = models.TextField(blank=True)
# 
#     permissions = models.TextField(blank=True)
#     date_added = models.DateField(auto_now_add=True)
# 
#     is_approved = models.BooleanField(default=False)
#     is_published = models.BooleanField(default=False)
# 
#     def __str__(self):
#         return self.name
# 
# class EventImage(models.Model):
#     event = models.ForeignKey(Event, on_delete=models.CASCADE)
#     image = models.ImageField(upload_to='events/images/')
# 
#     def __str__(self):
#         return self.event.name


# Path: events/forms.py
from django import forms
from events.models import Event, EventImage

                           widget=forms.TextInput(attrs={'placeholder': "Name"}))
    start_date = forms.DateTimeField(label="Enter start date and time",
                                    widget=forms.DateTimeInput())
    end_date = forms.DateTimeField(label="Enter end date and time",
                                  widget=forms.DateTimeInput())
    description = forms.CharField(label="Description", help_text="Description",
                                 widget=forms.Textarea(attrs={'placeholder': "Description"}))
    venue = forms.CharField(label="Venue", help_text="Venue",
                            widget=forms.TextInput(attrs={'placeholder': 'Venue'}))
    trainer_bio = forms.CharField(label="Trainer bio", help_text="Enter trainer bio")
    no_of_participants = forms.IntegerField(label="No of participants", help_text="Enter no of participants")
    level = forms.ChoiceField(choices=LEVEL_CHOICES, label="Level")
    prerequisite = forms.CharField(label="Prerequisite")
    travel = forms.CharField(label="Travel info", help_text="Enter travel data")
    accommodation = forms.CharField(label="Accomodation")
    expense = forms.FloatField(label="Expenses")
    lab_requirements = forms.CharField(label='Lab Requirements')
    icts_support = forms.CharField(label="ICTS support")

    def __init__(self, *args, **kwargs):
        super(EventCreateForm, self).__init__(*args, **kwargs)
        for field in iter(self.fields):
            self.fields[field].widget.attrs.update({'class': 'form-control'})
    class Meta:
        model = Event
        fields = ['name', 'start_date', 'end_date', 'description', 'venue', 'trainer_bio', 'no_of_participants',
                  'level', 'prerequisite', 'travel', 'accommodation', 'expense', 'lab_requirements', 'icts_support']


class EventImageForm(forms.ModelForm):

    event = forms.ModelChoiceField(queryset=Event.objects.all(), label='Event', help_text='Select event')