add rental calendar
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from . import apps
|
from . import apps, views
|
||||||
from .views import RentalCreateDoneView, RentalCreateView, RentalItemDetailView, RentalListView
|
from .views import RentalCreateDoneView, RentalCreateView, RentalItemDetailView, RentalListView
|
||||||
|
|
||||||
app_name = apps.RentalConfig.name
|
app_name = apps.RentalConfig.name
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path("rental_calendar.ics", views.rental_calendar, name="calendar"),
|
||||||
path("rental/", RentalListView.as_view(), name="index"),
|
path("rental/", RentalListView.as_view(), name="index"),
|
||||||
path("request-rental/", RentalCreateView.as_view(), name="rental_create"),
|
path("request-rental/", RentalCreateView.as_view(), name="rental_create"),
|
||||||
path(
|
path(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import calendar
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from django.shortcuts import render
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.views.generic import ListView, TemplateView
|
from django.views.generic import ListView, TemplateView
|
||||||
from django.views.generic.detail import DetailView
|
from django.views.generic.detail import DetailView
|
||||||
@@ -170,3 +171,21 @@ class RentalCreateDoneView(TemplateView):
|
|||||||
class RentalItemDetailView(DetailView):
|
class RentalItemDetailView(DetailView):
|
||||||
model = RentalItem
|
model = RentalItem
|
||||||
template_name = "rental/rentalitem_detail.html"
|
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
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
Willkommen bei unserem Verleih!
|
Willkommen bei unserem Verleih!
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<a href="{% url 'rental:calendar' %}" class="block btn btn-secondary max-w-xs mx-auto sm:w-max sm:mr-0 sm:ml-auto my-6"><i class="fa-solid fa-calendar-days mr-2"></i>Verleih-Kalender abonnieren</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<a href="{% url 'rental:rental_create' %}" class="page-subtitle block btn-small btn-primary max-w-xs mx-auto sm:w-max sm:mr-0 sm:ml-auto">
|
<a href="{% url 'rental:rental_create' %}" class="page-subtitle block btn-small btn-primary max-w-xs mx-auto sm:w-max sm:mr-0 sm:ml-auto">
|
||||||
<i class="fa-solid fa-plus mr-1"></i> Verleih anfragen
|
<i class="fa-solid fa-plus mr-1"></i> Verleih anfragen
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
37
fet2020/templates/rental/rental_calendar.ics
Normal file
37
fet2020/templates/rental/rental_calendar.ics
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//FET//Verleih Kalender//DE
|
||||||
|
METHOD:PUBLISH
|
||||||
|
X-WR-CALNAME:Verleih Kalender
|
||||||
|
X-WR-CALDESC:Übersicht aller Verleihtermine
|
||||||
|
X-WR-TIMEZONE:Europe/Vienna
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Europe/Vienna
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19961027T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
||||||
|
TZNAME:MEZ
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19810329T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
||||||
|
TZNAME:MESZ
|
||||||
|
END:DAYLIGHT
|
||||||
|
END:VTIMEZONE{% for rental in rentals %}{% for rentalitem in rental.rentalitems.all %}
|
||||||
|
BEGIN:VEVENT
|
||||||
|
UID:{% now 'Ymd' %}_{{ rental.id }}_{{ rentalitem.id }}@fet.at
|
||||||
|
ORGANIZER;CN="Fachschaft Elektrotechnik":MAILTO:verleih@fet.at
|
||||||
|
SUMMARY:#{{ rental.id }}: {{ rentalitem.name }} - {{ rental.get_status_display }}
|
||||||
|
DESCRIPTION:Anfrage bearbeiten: {{ request.scheme }}://
|
||||||
|
{{ request.get_host }}{% url 'admin:rental_rental_change' rental.id %}
|
||||||
|
CLASS:PUBLIC
|
||||||
|
DTSTART;TZID=Europe/Vienna:{{ rental.date_start|date:'Ymd' }}
|
||||||
|
DTEND;TZID=Europe/Vienna:{{ rental.date_end|date:'Ymd' }}
|
||||||
|
DTSTAMP;TZID=Europe/Vienna:{% now 'Ymd' %}T{% now 'His' %}
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
END:VEVENT{% endfor %}{% endfor %}
|
||||||
|
END:VCALENDAR
|
||||||
Reference in New Issue
Block a user