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 ...@@ -3,6 +3,7 @@ from datetime import date, timedelta
import arrow import arrow
from django.core.serializers.json import DjangoJSONEncoder from django.core.serializers.json import DjangoJSONEncoder
from django.core.validators import URLValidator
from django.db import models from django.db import models
from icalevents import icalevents from icalevents import icalevents
...@@ -25,10 +26,17 @@ class EventsJSONField(models.JSONField): ...@@ -25,10 +26,17 @@ class EventsJSONField(models.JSONField):
def from_db_value(self, value, expression, connection): def from_db_value(self, value, expression, connection):
value = super().from_db_value(value, expression, connection) value = super().from_db_value(value, expression, connection)
urlValidator = URLValidator()
if value: if value:
for event in value: for event in value:
event["start"] = arrow.get(event.get("start")).datetime event["start"] = arrow.get(event.get("start")).datetime
event["end"] = arrow.get(event["end"]).datetime event["end"] = arrow.get(event["end"]).datetime
try:
urlValidator(event.get("location"))
event["url"] = event.get("location")
except:
pass
return value return value
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
{{ event.summary }} {{ event.summary }}
</span> </span>
{% if event.description %} {% if event.description %}
<p class="font-light text-sm mt-1"> <p class="font-light text-sm mt-1 overflow-auto">
{{ event.description | safe }} {{ event.description | safe }}
</p> </p>
{% endif %} {% endif %}
...@@ -44,6 +44,11 @@ ...@@ -44,6 +44,11 @@
<i aria-hidden="true" class="ico--jitsi text-violet-300 mr-1"></i> <i aria-hidden="true" class="ico--jitsi text-violet-300 mr-1"></i>
<span>Jitsi URL</span> <span>Jitsi URL</span>
</a> </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 %} {% elif event.location %}
<a href="https://maps.google.com/maps?q={{ event.location }}" class="icon-link"> <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> <i aria-hidden="true" class="ico--location text-violet-300 mr-1"></i>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
{{ event.summary }} {{ event.summary }}
</span> </span>
{% if event.description %} {% 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 %} {% endif %}
</div> </div>
</div> </div>
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
<i aria-hidden="true" class="ico--link text-violet-300 mr-1"></i> <i aria-hidden="true" class="ico--link text-violet-300 mr-1"></i>
<span>Jitsi URL</span> <span>Jitsi URL</span>
</a> </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 %} {% elif event.location %}
<a href="https://maps.google.com/maps?q={{ event.location }}" class="icon-link"> <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> <i aria-hidden="true" class="ico--location text-violet-300 mr-1"></i>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment