# Path: fossevents/events/models.py
# class Event(TimeStampedUUIDModel):
#     """ Model to capture all details about the event.
#     """
#     name = models.CharField(blank=False, null=False, max_length=100, verbose_name=_("name"),)
#     description = MarkdownField(blank=False, null=False, verbose_name=_("description"))
#     start_date = models.DateTimeField(blank=False, verbose_name=_("start date"))
#     end_date = models.DateTimeField(blank=True, verbose_name=_("end date"))
#     homepage = models.URLField(blank=True, verbose_name=_("homepage"))
#     is_published = models.BooleanField(blank=False, null=False, default=False, verbose_name=_("is published"))
# 
#     auth_token = models.CharField(blank=True, null=False, max_length=50)
#     owner_email = models.EmailField(
#         blank=False, null=False, max_length=256, verbose_name=_("owner's email address"),
#         help_text=_("An email with the edit link for this event would be sent to this address. \
#             Please provide a vaild address here."))
# 
#     class Meta:
#         verbose_name = _("event")
#         verbose_name_plural = _("events")
#         ordering = ('-start_date', )
# 
#     def __str__(self):
#         return self.name
# 
#     def get_absolute_url(self):
#         return reverse('event-detail', kwargs={'slug': self.slug, 'pk': self.id.hex})
# 
#     def get_edit_url(self):
#         return reverse('events:update', kwargs={'slug': self.slug, 'pk': self.id.hex, 'token': self.auth_token})
# 
#     @property
#     def slug(self):
#         return slugify(self.name)
# 
#     # TODO: return date in localize timezone
#     def date(self):
#         return get_date_diff_display(self.start_date, self.end_date)
# 
#     @cached_property
#     def description_html(self):
#         return markdown(self.description)
# 
#     def save(self, *args, **kwargs):
#         if not self.auth_token:
#             self.auth_token = str(uuid.uuid4())
#         super(Event, self).save(*args, **kwargs)
# 
# class EventReview(TimeStampedUUIDModel):
#     event = models.ForeignKey(Event, related_name="reviews")
#     comment = MarkdownField(blank=True, null=True, verbose_name=_("Notes"))
#     moderator = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="event_reviews")
#     is_approved = models.BooleanField()
# 
#     class Meta:
#         ordering = ('-created', )
# 
#     def __str__(self):
#         return '{} -> {}'.format(self.moderator, self.event)


from django import forms
from .models import Event, EventReview
        exclude = ('auth_token', 'is_published')
        widgets = {
            'name': forms.TextInput(attrs={'placeholder': 'Title'}),
            'owner_email': forms.EmailInput(attrs={'placeholder': 'user@example.com'}),
        }

    def clean(self):
        cleaned_data = super().clean()
        start_date = cleaned_data.get('start_date')
        end_date = cleaned_data.get('end_date')
        if end_date and start_date:
            if end_date < start_date:
                self.add_error('end_date',
                               forms.ValidationError('End date should be greater than or equal to start date.'))
        return cleaned_data


class EventReviewForm(forms.ModelForm):
    comment = forms.CharField(widget=forms.Textarea(attrs={'placeholder': 'Enter notes or comments...', 'rows': 2},),
                              help_text='<a href="https://guides.github.com/features/mastering-markdown/">'
                                        'Markdown supported</a>',
                              required=False)

    class Meta:
        model = EventReview
        exclude = ('event', 'moderator')
        widgets = {'is_approved': forms.HiddenInput()}

    def clean(self):
        cleaned_data = super().clean()

# Path: fossevents/events/models.py
# class Event(TimeStampedUUIDModel):
#     """ Model to capture all details about the event.
#     """
#     name = models.CharField(blank=False, null=False, max_length=100, verbose_name=_("name"),)
#     description = MarkdownField(blank=False, null=False, verbose_name=_("description"))
#     start_date = models.DateTimeField(blank=False, verbose_name=_("start date"))
#     end_date = models.DateTimeField(blank=True, verbose_name=_("end date"))
#     homepage = models.URLField(blank=True, verbose_name=_("homepage"))
#     is_published = models.BooleanField(blank=False, null=False, default=False, verbose_name=_("is published"))
# 
#     auth_token = models.CharField(blank=True, null=False, max_length=50)
#     owner_email = models.EmailField(
#         blank=False, null=False, max_length=256, verbose_name=_("owner's email address"),
#         help_text=_("An email with the edit link for this event would be sent to this address. \
#             Please provide a vaild address here."))
# 
#     class Meta:
#         verbose_name = _("event")
#         verbose_name_plural = _("events")
#         ordering = ('-start_date', )
# 
#     def __str__(self):
#         return self.name
# 
#     def get_absolute_url(self):
#         return reverse('event-detail', kwargs={'slug': self.slug, 'pk': self.id.hex})
# 
#     def get_edit_url(self):
#         return reverse('events:update', kwargs={'slug': self.slug, 'pk': self.id.hex, 'token': self.auth_token})
# 
#     @property
#     def slug(self):
#         return slugify(self.name)
# 
#     # TODO: return date in localize timezone
#     def date(self):
#         return get_date_diff_display(self.start_date, self.end_date)
# 
#     @cached_property
#     def description_html(self):
#         return markdown(self.description)
# 
#     def save(self, *args, **kwargs):
#         if not self.auth_token:
#             self.auth_token = str(uuid.uuid4())
#         super(Event, self).save(*args, **kwargs)
# 
# class EventReview(TimeStampedUUIDModel):
#     event = models.ForeignKey(Event, related_name="reviews")
#     comment = MarkdownField(blank=True, null=True, verbose_name=_("Notes"))
#     moderator = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="event_reviews")
#     is_approved = models.BooleanField()
# 
#     class Meta:
#         ordering = ('-created', )
# 
#     def __str__(self):
#         return '{} -> {}'.format(self.moderator, self.event)


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

        exclude = ('auth_token', 'is_published')
        widgets = {
            'name': forms.TextInput(attrs={'placeholder': 'Title'}),
            'owner_email': forms.EmailInput(attrs={'placeholder': 'user@example.com'}),
        }

    def clean(self):
        cleaned_data = super().clean()
        start_date = cleaned_data.get('start_date')
        end_date = cleaned_data.get('end_date')
        if end_date and start_date:
            if end_date < start_date:
                self.add_error('end_date',
                               forms.ValidationError('End date should be greater than or equal to start date.'))
        return cleaned_data


class EventReviewForm(forms.ModelForm):
    comment = forms.CharField(widget=forms.Textarea(attrs={'placeholder': 'Enter notes or comments...', 'rows': 2},),
                              help_text='<a href="https://guides.github.com/features/mastering-markdown/">'
                                        'Markdown supported</a>',
                              required=False)

    class Meta:
        model = EventReview
        exclude = ('event', 'moderator')
        widgets = {'is_approved': forms.HiddenInput()}

    def clean(self):
        cleaned_data = super().clean()

        is_approved = cleaned_data.get('is_approved')