Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#361 add google calendar link #414

Merged
merged 5 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ class Meta:
def slug(self):
return self.hashtag.lower()

def end_datetime(self):
try:
return self.schedule.order_by('end').last().end
except AttributeError:
end_time = datetime.time(
23, 59, 59, tzinfo=timezone.get_current_timezone())
return datetime.datetime.combine(self.start_date, end_time)

def get_google_calendar_url(self):
start_datetime = self.start_datetime().strftime('%Y%m%dT%H%M%S%Z')
end_datetime = self.end_datetime().strftime('%Y%m%dT%H%M%S%Z')
return f"https://www.google.com/calendar/render?action=TEMPLATE&text={self.name}&details={self.description}&location={self.venue}&dates={start_datetime}%2F{end_datetime}"

CrisKrus marked this conversation as resolved.
Show resolved Hide resolved
@classmethod
def get_by_slug(cls, slug):
return cls.objects.get(hashtag__iexact=slug)
Expand Down
1 change: 1 addition & 0 deletions apps/events/templates/events/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ <h2 class="speaker-name">{{ speaker.name }} {{ speaker.surname }}</h2>
<h1 class="title section-title">
<p>Agenda</p>
<p class="section-detail"><i class="far fa-calendar-alt"></i> {{ event.start_date|as_date }}</p>
<a target="_blank" href="{{ event.get_google_calendar_url }}">Añadir a Google Calendar</a>
{% if event.schedule_for_display and not event.closed_schedule %}
<span class="tag is-warning is-medium not-closed-schedule">
<i class="fas fa-info-circle"></i>
Expand Down
1 change: 1 addition & 0 deletions apps/events/templates/events/includes/event-section.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h1 class="title is-3">
</h1>
<div class="event-date">
<i class="far fa-calendar-alt"></i> {{ event.start_date|as_date }}
<a target="_blank" href="{{ event.get_google_calendar_url }}">Añadir a Google Calendar</a>
</div>
{% if event.venue %}
<div class="event-location">
Expand Down