Skip to content
Snippets Groups Projects
Commit f5c07140 authored by jindra12's avatar jindra12 Committed by jan.bednarik
Browse files

Add support for generic links in events location in calendar

Also, add overflow-auto to markdown event descriptions

#181
parent 59081104
No related branches found
No related tags found
2 merge requests!787Release,!745Add support for generic links in events location in calendar
......@@ -3,6 +3,7 @@ from datetime import date, timedelta
import arrow
from django.core.serializers.json import DjangoJSONEncoder
from django.core.validators import URLValidator
from django.db import models
from icalevents import icalevents
......@@ -25,10 +26,17 @@ class EventsJSONField(models.JSONField):
def from_db_value(self, value, expression, connection):
value = super().from_db_value(value, expression, connection)
urlValidator = URLValidator()
if value:
for event in value:
event["start"] = arrow.get(event.get("start")).datetime
event["end"] = arrow.get(event["end"]).datetime
try:
urlValidator(event.get("location"))
event["url"] = event.get("location")
except:
pass
return value
......
......@@ -32,7 +32,7 @@
{{ event.summary }}
</span>
{% if event.description %}
<p class="font-light text-sm mt-1">
<p class="font-light text-sm mt-1 overflow-auto">
{{ event.description | safe }}
</p>
{% endif %}
......@@ -44,6 +44,11 @@
<i aria-hidden="true" class="ico--jitsi text-violet-300 mr-1"></i>
<span>Jitsi URL</span>
</a>
{% elif event.url %}
<a href="{{ event.url }}" class="icon-link">
<i aria-hidden="true" class="ico--link text-violet-300 mr-1"></i>
<span>Odkaz</span>
</a>
{% elif event.location %}
<a href="https://maps.google.com/maps?q={{ event.location }}" class="icon-link">
<i aria-hidden="true" class="ico--location text-violet-300 mr-1"></i>
......
......@@ -18,7 +18,7 @@
{{ event.summary }}
</span>
{% if event.description %}
<p class="font-light text-sm mt-1">{{ event.description | safe }}</p>
<p class="font-light text-sm mt-1 overflow-auto">{{ event.description | safe }}</p>
{% endif %}
</div>
</div>
......@@ -28,6 +28,11 @@
<i aria-hidden="true" class="ico--link text-violet-300 mr-1"></i>
<span>Jitsi URL</span>
</a>
{% elif event.url %}
<a href="{{ event.url }}" class="icon-link">
<i aria-hidden="true" class="ico--link text-violet-300 mr-1"></i>
<span>Odkaz</span>
</a>
{% elif event.location %}
<a href="https://maps.google.com/maps?q={{ event.location }}" class="icon-link">
<i aria-hidden="true" class="ico--location text-violet-300 mr-1"></i>
......
......@@ -12,7 +12,7 @@
<div class="col-span-3 md:col-span-2 mt-4 md:mt-0">
<strong class="block">{{ event.summary }}</strong>
{% if event.description %}
<p class="font-light text-sm mt-1">{{ event.description }}</p>
<p class="font-light text-sm mt-1 ">{{ event.description }}</p>
{% endif %}
{% if event.location %}
<p class="font-light text-sm mt-1">{{ event.location }}</p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment