-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55b4085
commit 5b3a53c
Showing
1 changed file
with
13 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
from django.dispatch import receiver | ||
from channels.layers import get_channel_layer | ||
from asgiref.sync import async_to_sync | ||
from ics.grammar.parse import ContentLine | ||
|
||
from .consumers import CHANNEL_GROUP_NAME | ||
from django.contrib.auth.models import User | ||
from django.db import models | ||
|
@@ -125,7 +127,7 @@ def ics_url_path(self): | |
return reverse("download_bar_events_ics", args=[slugify(self.name), self.id]) | ||
|
||
def google_maps_url(self): | ||
return f"https://maps.google.com/?q={ self.name }, { self.street }, { self.zip_code } { self.city }" | ||
return f"https://maps.google.com/?q={self.name}, {self.street}, {self.zip_code} {self.city}" | ||
|
||
def content_description(self): | ||
if self.description: | ||
|
@@ -186,12 +188,21 @@ def to_ics_event(self) -> IcsEvent: | |
ics_event.begin = self.start_date | ||
ics_event.end = self.end_date if self.end_date else self.start_date + timedelta(hours=4) | ||
ics_event.description = self.description | ||
ics_event.location = f"{self.bar.street}, {self.bar.zip_code} {self.bar.city}" | ||
ics_event.location = f"{self.bar.name}\n{self.bar.street}, {self.bar.zip_code} {self.bar.city}, Germany" | ||
if self.bar.latitude and self.bar.longitude: | ||
ics_event.geo = Geo(self.bar.latitude, self.bar.longitude) | ||
ics_event.status = "CONFIRMED" | ||
ics_event.uid = f"event-{self.id}@studibars-ac.de" | ||
ics_event.organizer = Organizer(common_name=self.bar.name, email="[email protected]") | ||
ics_event.extra.append(ContentLine(name="X-APPLE-STRUCTURED-LOCATION", | ||
params={ | ||
"VALUE": ["URI"], | ||
"X-ADDRESS": [ | ||
f"\"{self.bar.name}, {self.bar.street}, {self.bar.zip_code} {self.bar.city}, Germany\""], | ||
"X-APPLE-RADIUS": ["15"], | ||
"X-TITLE": [self.bar.name], | ||
}, | ||
value=f"geo:{self.bar.latitude},{self.bar.longitude}")) | ||
|
||
# Add an alarm/reminder | ||
alarm = DisplayAlarm(trigger=timedelta(days=-1)) | ||
|