# Path: happenings/models.py
# class Update(models.Model):
#     """
#     Allows updating the event in near real-time, with blog-style content updates.
#     """
#     event = models.ForeignKey(
#         Event,
#         on_delete=models.CASCADE,
#         limit_choices_to={'featured': True},
#         db_index=True
#     )
#     title = models.CharField("Update title", max_length=200)
#     author = models.ForeignKey(
#         UserModel,
#         on_delete=models.CASCADE,
#         limit_choices_to={'is_staff': True})
#     update = models.TextField()
#     update_formatted = models.TextField(blank=True, editable=False)
#     pub_time = models.DateTimeField(auto_now_add=True)
#     last_updated = models.DateTimeField(auto_now=True)
#     audio = models.FileField(
#         upload_to='audio/events/special/',
#         blank=True,
#         null=True,
#         help_text="Should be MP3 format"
#     )
# 
#     def __str__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         return reverse('event_update_detail', args=[str(self.event.slug), str(self.id)])
# 
#     def save(self, *args, **kwargs):
#         self.update_formatted = sanetize_text(self.update)
#         super(Update, self).save(*args, **kwargs)
# 
#     @cached_property
#     def comments_open(self):
#         """
#         Based on the update's event's comments open status
#         """
#         return self.event.comments_open
# 
#     def has_image(self):
#         if self.updateimage_set.count():
#             return True
# 
#     def get_image(self):
#         return self.updateimage_set.latest('id')
# 
#     def get_gallery_url(self):
#         return reverse('update_slides', args=[self.event.slug, str(self.id)])
# 
#     def get_top_assets(self):
#         return self.updateimage_set.all()
# 
# Path: happenings/views.py
# class EventList(ListView):
# class EventsForPeriod(EventList):
# class EventDetail(DetailView):
# class EventUpdate(DetailView):
# class ExtraInfoDetail(EventUpdate):
# class EditEvent(UpdateView):
# class AddRecap(EditEvent):
# class MemoryDetail(DetailView):
#     def get_queryset(self):
#     def get_context_data(self, **kwargs):
#     def get_queryset(self, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_context_data(self, **kwargs):
#     def dispatch(self, request, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_object(self):
#     def get_object(self):
# def create_ical(request, slug):
# def event_all_comments_list(request, slug):
# def event_update_list(request, slug):
# def video_list(request, slug):
# def add_event(request):
#     def dispatch(self, *args, **kwargs):
#     def get_context_data(self, **kwargs):
# def add_attending(request, slug):
# def add_memory(request, slug):
#     def dispatch(self, request, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_object(self):
# def process_upload(upload_file, instance, form, event, request):


from django.urls import path, re_path
from django.views.generic import DetailView
from .models import Update
from .views import add_event, edit_event, add_recap, create_ical, \
    event_list, event_detail, events_period, \
    event_update, memory_detail, extrainfo_detail, event_update_list, \
    video_list, event_all_comments_list, add_attending, add_memory
    path('<slug:slug>/videos/', video_list, name="event_video_list"),
    path('<slug:slug>/all-comments/', event_all_comments_list, name="event_comments"),
    path('<slug:slug>/map/', event_detail, 
        {'template_name': 'happenings/event_map.html'},
        name="event_map"
    ),
    path('<slug:slug>/attending/', event_detail, 
        {'template_name': 'happenings/attending/list.html'},
        name='event_attending_list'
    ),
    path('<slug:slug>/attending/add/', add_attending, name="attending_add"),
    path('<slug:slug>/memories/', event_detail, 
        {'template_name': 'happenings/memory_list.html'},
        name="event_memories"
    ),
    path('<slug:event_slug>/memories/<int:pk>/', memory_detail, name="memory_detail"),
    path('<slug:slug>/memories/add/', add_memory, name="add_memory"),

    # extra info pages
    path('<slug:event_slug>/extra/<slug:slug>/', extrainfo_detail, name="special_event_extra"),

    # updates
    path('<slug:slug>/updates/', event_update_list, name="event_update_list"),
    path('<slug:event_slug>/updates/<int:pk>/', event_update, name="event_update_detail"),
    path('<slug:event_slug>/updates/<int:pk>/slides/',
        DetailView.as_view(
            template_name="happenings/updates/update_slides.html",
            queryset=Update.objects.all()
        ),
        name="update_slides",

# Path: happenings/models.py
# class Update(models.Model):
#     """
#     Allows updating the event in near real-time, with blog-style content updates.
#     """
#     event = models.ForeignKey(
#         Event,
#         on_delete=models.CASCADE,
#         limit_choices_to={'featured': True},
#         db_index=True
#     )
#     title = models.CharField("Update title", max_length=200)
#     author = models.ForeignKey(
#         UserModel,
#         on_delete=models.CASCADE,
#         limit_choices_to={'is_staff': True})
#     update = models.TextField()
#     update_formatted = models.TextField(blank=True, editable=False)
#     pub_time = models.DateTimeField(auto_now_add=True)
#     last_updated = models.DateTimeField(auto_now=True)
#     audio = models.FileField(
#         upload_to='audio/events/special/',
#         blank=True,
#         null=True,
#         help_text="Should be MP3 format"
#     )
# 
#     def __str__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         return reverse('event_update_detail', args=[str(self.event.slug), str(self.id)])
# 
#     def save(self, *args, **kwargs):
#         self.update_formatted = sanetize_text(self.update)
#         super(Update, self).save(*args, **kwargs)
# 
#     @cached_property
#     def comments_open(self):
#         """
#         Based on the update's event's comments open status
#         """
#         return self.event.comments_open
# 
#     def has_image(self):
#         if self.updateimage_set.count():
#             return True
# 
#     def get_image(self):
#         return self.updateimage_set.latest('id')
# 
#     def get_gallery_url(self):
#         return reverse('update_slides', args=[self.event.slug, str(self.id)])
# 
#     def get_top_assets(self):
#         return self.updateimage_set.all()
# 
# Path: happenings/views.py
# class EventList(ListView):
# class EventsForPeriod(EventList):
# class EventDetail(DetailView):
# class EventUpdate(DetailView):
# class ExtraInfoDetail(EventUpdate):
# class EditEvent(UpdateView):
# class AddRecap(EditEvent):
# class MemoryDetail(DetailView):
#     def get_queryset(self):
#     def get_context_data(self, **kwargs):
#     def get_queryset(self, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_context_data(self, **kwargs):
#     def dispatch(self, request, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_object(self):
#     def get_object(self):
# def create_ical(request, slug):
# def event_all_comments_list(request, slug):
# def event_update_list(request, slug):
# def video_list(request, slug):
# def add_event(request):
#     def dispatch(self, *args, **kwargs):
#     def get_context_data(self, **kwargs):
# def add_attending(request, slug):
# def add_memory(request, slug):
#     def dispatch(self, request, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_object(self):
# def process_upload(upload_file, instance, form, event, request):


# Path: happenings/urls.py
from django.urls import path, re_path
from django.views.generic import DetailView
from .models import Update
from .views import add_event, edit_event, add_recap, create_ical, \
    event_list, event_detail, events_period, \
    event_update, memory_detail, extrainfo_detail, event_update_list, \
    video_list, event_all_comments_list, add_attending, add_memory

    path('<slug:slug>/videos/', video_list, name="event_video_list"),
    path('<slug:slug>/all-comments/', event_all_comments_list, name="event_comments"),
    path('<slug:slug>/map/', event_detail, 
        {'template_name': 'happenings/event_map.html'},
        name="event_map"
    ),
    path('<slug:slug>/attending/', event_detail, 
        {'template_name': 'happenings/attending/list.html'},
        name='event_attending_list'
    ),
    path('<slug:slug>/attending/add/', add_attending, name="attending_add"),
    path('<slug:slug>/memories/', event_detail, 
        {'template_name': 'happenings/memory_list.html'},
        name="event_memories"
    ),
    path('<slug:event_slug>/memories/<int:pk>/', memory_detail, name="memory_detail"),
    path('<slug:slug>/memories/add/', add_memory, name="add_memory"),

    # extra info pages
    path('<slug:event_slug>/extra/<slug:slug>/', extrainfo_detail, name="special_event_extra"),

    # updates
    path('<slug:slug>/updates/', event_update_list, name="event_update_list"),
    path('<slug:event_slug>/updates/<int:pk>/', event_update, name="event_update_detail"),
    path('<slug:event_slug>/updates/<int:pk>/slides/',
        DetailView.as_view(
            template_name="happenings/updates/update_slides.html",
            queryset=Update.objects.all()
        ),
        name="update_slides",

    ),