diff --git a/calendar_utils/models.py b/calendar_utils/models.py index 939e7c02d2a9c7ea24019a8ca838b71588e60946..c733fe7dc16446b7e56847b0e962f79d5f85b09a 100644 --- a/calendar_utils/models.py +++ b/calendar_utils/models.py @@ -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 diff --git a/shared/templates/shared/calendar_current_events_snippet.html b/shared/templates/shared/calendar_current_events_snippet.html index e16b5a334b9d87acee94bd07ea6bab4266a49cc8..da8181a21fac479979c97ad06b1984c3ca7e6018 100644 --- a/shared/templates/shared/calendar_current_events_snippet.html +++ b/shared/templates/shared/calendar_current_events_snippet.html @@ -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> diff --git a/shared/templates/shared/small_calendar_snippet.html b/shared/templates/shared/small_calendar_snippet.html index 07a550e1c8e8772ece6da40002e8fd85279f8ecd..e0e15409cf53c021f93536f23e26ba7ce0dccd1c 100644 --- a/shared/templates/shared/small_calendar_snippet.html +++ b/shared/templates/shared/small_calendar_snippet.html @@ -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> diff --git a/uniweb/templates/uniweb/blocks/calendar_agenda.html b/uniweb/templates/uniweb/blocks/calendar_agenda.html index c45f1caf7bc2ca53fe759fb336ac2c6de44ecfda..7a14074dc3eed9a8595c9ee510b8447d2505a979 100644 --- a/uniweb/templates/uniweb/blocks/calendar_agenda.html +++ b/uniweb/templates/uniweb/blocks/calendar_agenda.html @@ -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>