add rental calendar
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from django.urls import path
|
||||
|
||||
from . import apps
|
||||
from . import apps, views
|
||||
from .views import RentalCreateDoneView, RentalCreateView, RentalItemDetailView, RentalListView
|
||||
|
||||
app_name = apps.RentalConfig.name
|
||||
|
||||
urlpatterns = [
|
||||
path("rental_calendar.ics", views.rental_calendar, name="calendar"),
|
||||
path("rental/", RentalListView.as_view(), name="index"),
|
||||
path("request-rental/", RentalCreateView.as_view(), name="rental_create"),
|
||||
path(
|
||||
|
||||
@@ -2,6 +2,7 @@ import calendar
|
||||
import datetime
|
||||
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
from django.views.generic import ListView, TemplateView
|
||||
from django.views.generic.detail import DetailView
|
||||
@@ -170,3 +171,21 @@ class RentalCreateDoneView(TemplateView):
|
||||
class RentalItemDetailView(DetailView):
|
||||
model = RentalItem
|
||||
template_name = "rental/rentalitem_detail.html"
|
||||
|
||||
|
||||
def rental_calendar(request):
|
||||
"""
|
||||
ICS-calendar for outlook, google calender, ...
|
||||
"""
|
||||
rentals = Rental.objects.all()
|
||||
|
||||
context = {
|
||||
"rentals": rentals,
|
||||
}
|
||||
|
||||
response = render(request, "rental/rental_calendar.ics", context, content_type="text/calendar")
|
||||
|
||||
# End of line (EOL) must be CRLF, to be compliant with RFC5545. Django/Python set the EOL to LF.
|
||||
response.content = response.content.replace(b"\n", b"\r\n")
|
||||
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user