# Path: fossevents/events/views.py
# class EventCreateView(CreateView):
#     form_class = EventForm
#     template_name = 'events/event_form.html'
# 
#     def form_valid(self, form):
#         """
#         If the form is valid, save the associated model.
#         """
#         response = super().form_valid(form)
#         services.send_confirmation_mail(self.object, False)
#         return response
# 
# class EventUpdateView(UpdateView):
#     form_class = EventForm
#     template_name = 'events/event_form.html'
#     queryset = models.Event.objects.all()
# 
#     @method_decorator(match_token)
#     def dispatch(self, request, *args, **kwargs):
#         return super(EventUpdateView, self).dispatch(request, *args, **kwargs)
# 
#     def form_valid(self, form):
#         """
#         If the form is valid, save the associated model.
#         """
#         response = super().form_valid(form)
#         services.send_confirmation_mail(self.object, False)
#         return response
# 
# @user_passes_test(lambda u: u.is_moderator)
# @login_required()
# @require_http_methods(['POST'])
# def event_review(request, pk, token, slug=None, event_detail_template='events/event_detail.html'):
#     # TODO: Add reference in email for analytics
#     # TODO: Add history of reviews in review page
#     event = get_object_or_404(models.Event, pk=pk)
#     if event.slug != slug:
#         return redirect(event.get_absolute_url())
# 
#     form = EventReviewForm(data=request.POST)
#     if form.is_valid():
#         review = services.create_event_review(request.user, event, form.cleaned_data)
#         services.update_event_visibility(review)
#         services.send_event_review_mail(review, request.user)
#         return HttpResponseRedirect(reverse('home'))
# 
#     ctx = {
#         'event': event,
#         'review_url': services.get_event_review_url(event),
#         'form': form
#     }
#     return render(request, event_detail_template, ctx)


from django.conf.urls import url
from .views import EventCreateView, EventUpdateView, event_review
# Third Party Stuff


uuid_regex = '[a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?[1345][a-fA-F0-9]{3}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{12}'

urlpatterns = [
    url(r'^add/$', EventCreateView.as_view(), name="create"),

# Path: fossevents/events/views.py
# class EventCreateView(CreateView):
#     form_class = EventForm
#     template_name = 'events/event_form.html'
# 
#     def form_valid(self, form):
#         """
#         If the form is valid, save the associated model.
#         """
#         response = super().form_valid(form)
#         services.send_confirmation_mail(self.object, False)
#         return response
# 
# class EventUpdateView(UpdateView):
#     form_class = EventForm
#     template_name = 'events/event_form.html'
#     queryset = models.Event.objects.all()
# 
#     @method_decorator(match_token)
#     def dispatch(self, request, *args, **kwargs):
#         return super(EventUpdateView, self).dispatch(request, *args, **kwargs)
# 
#     def form_valid(self, form):
#         """
#         If the form is valid, save the associated model.
#         """
#         response = super().form_valid(form)
#         services.send_confirmation_mail(self.object, False)
#         return response
# 
# @user_passes_test(lambda u: u.is_moderator)
# @login_required()
# @require_http_methods(['POST'])
# def event_review(request, pk, token, slug=None, event_detail_template='events/event_detail.html'):
#     # TODO: Add reference in email for analytics
#     # TODO: Add history of reviews in review page
#     event = get_object_or_404(models.Event, pk=pk)
#     if event.slug != slug:
#         return redirect(event.get_absolute_url())
# 
#     form = EventReviewForm(data=request.POST)
#     if form.is_valid():
#         review = services.create_event_review(request.user, event, form.cleaned_data)
#         services.update_event_visibility(review)
#         services.send_event_review_mail(review, request.user)
#         return HttpResponseRedirect(reverse('home'))
# 
#     ctx = {
#         'event': event,
#         'review_url': services.get_event_review_url(event),
#         'form': form
#     }
#     return render(request, event_detail_template, ctx)


# Path: fossevents/events/urls.py
from django.conf.urls import url
from .views import EventCreateView, EventUpdateView, event_review

# Third Party Stuff


uuid_regex = '[a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?[1345][a-fA-F0-9]{3}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{12}'

urlpatterns = [
    url(r'^add/$', EventCreateView.as_view(), name="create"),

    url(r'^update/(?P<slug>[-\w]+)-(?P<pk>%s)-(?P<token>%s)/$' % (uuid_regex, uuid_regex),