Skip to content

Commit 7a59268

Browse files
committed
Revert "feat: personalised ical feed (#1101)"
This reverts commit 01c3d07.
1 parent 01c3d07 commit 7a59268

21 files changed

+23
-292
lines changed

Gemfile

-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ gem 'pg'
4949
# Full text search
5050
gem 'pg_search'
5151

52-
# iCalendar feeds
53-
gem 'icalendar'
54-
5552
group :production, :staging do
5653
gem 'sentry-raven'
5754
gem 'uglifier'

Gemfile.lock

-4
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ GEM
151151
rails-i18n
152152
rainbow (>= 2.2.2, < 4.0)
153153
terminal-table (>= 1.5.1)
154-
icalendar (2.10.1)
155-
ice_cube (~> 0.16)
156-
ice_cube (0.16.4)
157154
image_processing (1.12.1)
158155
mini_magick (>= 4.9.5, < 5)
159156
ruby-vips (>= 2.0.17, < 3)
@@ -351,7 +348,6 @@ DEPENDENCIES
351348
i15r (~> 0.5.5)
352349
i18n-js
353350
i18n-tasks (~> 0.9.31)
354-
icalendar
355351
image_processing
356352
impressionist!
357353
listen

app/controllers/admin/members_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def create
7575
impressionist(@member, 'nieuwe lid')
7676
redirect_to(@member)
7777
else
78+
7879
# If the member hasn't filled in a study, again show an empty field
7980
@member.educations.build(id: '-1') if @member.educations.empty?
8081

app/controllers/api/calendars_controller.rb

-56
This file was deleted.

app/controllers/members/participants_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def create
121121
participant_limit: @activity.participant_limit,
122122
participant_count: @activity.participants.count
123123
})
124+
return
124125
else
125126
@new_enrollment = Participant.new(
126127
member_id: @member.id,

app/javascript/src/members/activities/activities.js

+4-35
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,16 @@ import { Activity } from "./activity.js";
1010
var token, modal;
1111

1212
function copyICSToClipboard() {
13+
/* Link to copy */
14+
var copy_text =
15+
"https://calendar.google.com/calendar/ical/stickyutrecht.nl_thvhicj5ijouaacp1elsv1hceo%40group.calendar.google.com/public/basic.ics";
1316
new Clipboard("#copy-btn", {
1417
text: function () {
15-
return "https://calendar.google.com/calendar/ical/stickyutrecht.nl_thvhicj5ijouaacp1elsv1hceo%40group.calendar.google.com/public/basic.ics";
18+
return copy_text;
1619
},
1720
});
1821
}
1922

20-
function copyPersonalICSToClipboard() {
21-
fetch("/api/calendar/fetch")
22-
.then((response) => response.text())
23-
.then((icsFeed) => {
24-
new Clipboard("#copy-btn-personal", {
25-
text: function () {
26-
return icsFeed;
27-
},
28-
});
29-
})
30-
.catch((error) => {
31-
console.log(error);
32-
});
33-
} // TODO makes an API call even if the button is not pressed
34-
35-
document.getElementById("copy-btn-personal").addEventListener("click", (_) => {
36-
Swal.fire({
37-
title: I18n.t(
38-
"members.activities.calendar.confirm_understand_icalendar.title",
39-
),
40-
text: I18n.t(
41-
"members.activities.calendar.confirm_understand_icalendar.text",
42-
),
43-
icon: "warning",
44-
showCancelButton: false,
45-
confirmButtonText: I18n.t(
46-
"members.activities.calendar.confirm_understand_icalendar.confirm",
47-
),
48-
}).then((_) => {
49-
/* Do nothing, warning has been displayed and that's enough */
50-
});
51-
});
52-
5323
export function get_activity_container() {
5424
return $("#activity-container");
5525
}
@@ -274,7 +244,6 @@ $(document).on("ready page:load turbolinks:load", function () {
274244
initialize_enrollment();
275245
initialize_modal();
276246
copyICSToClipboard();
277-
copyPersonalICSToClipboard();
278247
});
279248

280249
document.addEventListener("turbolinks:load", function () {

app/models/activity.rb

+7-60
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'icalendar' # https://github.com/icalendar/icalendar
2-
31
# Represents an activity in the database.
42
#:nodoc:
53
class Activity < ApplicationRecord
@@ -226,34 +224,6 @@ def end
226224
Activity.combine_dt(end_date, end_time)
227225
end
228226

229-
def whole_day?
230-
return !start_time && !end_time
231-
end
232-
233-
# Format a datetime in UTC for the iCalendar format
234-
def format_utc(datetime)
235-
datetime.utc.strftime('%Y%m%dT%H%M%SZ')
236-
end
237-
238-
# Format a datetime to a whole day for the iCalendar format
239-
def format_whole_day(datetime)
240-
datetime.utc.strftime('%Y%m%d')
241-
# For whole days, do not convert to UTC, because if 'start' is a date, it's
242-
# time will be 00:00:00 and will be converted to the previous day
243-
end
244-
245-
# Properly format the start datetime, depending on if the event is a whole day event or not
246-
def calendar_start
247-
normalised_start = start_time ? start : start.change(hour: 0, min: 0) # Won't have effect if whole_day
248-
return whole_day? ? format_whole_day(normalised_start) : format_utc(normalised_start)
249-
end
250-
251-
# Properly format the end datetime, depending on if the event is a whole day event or not
252-
def calendar_end
253-
normalised_end = end_time ? self.end : self.end.change(hour: 23, min: 59) # Won't have effect if whole_day
254-
return whole_day? ? format_whole_day(normalised_end + 1.day) : format_utc(normalised_end) # +1 day, end is exclusive
255-
end
256-
257227
def when_open
258228
Activity.combine_dt(open_date, open_time)
259229
end
@@ -390,21 +360,19 @@ def activity_url
390360
return "https://koala.svsticky.nl/activities/#{ id }"
391361
end
392362

393-
def description_localised(locale)
394-
return locale == :nl ? description_nl : description_en
395-
end
396-
397-
# This generates an URL representing a calendar activity template, filled with data from the koala activity
363+
# pass along locale default to nil
398364
def google_event(loc = nil)
399365
return nil if start.nil? || self.end.nil?
400366

367+
fmt_dt = ->(dt) { dt.utc.strftime('%Y%m%dT%H%M%SZ') }
368+
401369
loc = I18n.locale if loc.nil?
402-
disclaimer = "[#{ I18n.t('activerecord.attributes.activity.disclaimer') }]"
403-
description = "#{ activity_url }\n\n#{ description_localised(loc) }\n\n#{ disclaimer }"
370+
description = "#{ activity_url }\n\n#{ loc == :nl ? description_nl : description_en }"
404371
uri_name = URI.encode_www_form_component(name)
405372
uri_description = URI.encode_www_form_component(description)
406373
uri_location = URI.encode_www_form_component(location)
407-
return "https://www.google.com/calendar/render?action=TEMPLATE&text=#{ uri_name }&dates=#{ calendar_start }%2F#{ calendar_end }&details=#{ uri_description }&location=#{ uri_location }&sf=true&output=xml"
374+
calendar_end = end_time.nil? ? self.end.change(hour: 23, min: 59) : self.end
375+
return "https://www.google.com/calendar/render?action=TEMPLATE&text=#{ uri_name }&dates=#{ fmt_dt.call(start) }%2F#{ fmt_dt.call(calendar_end) }&details=#{ uri_description }&location=#{ uri_location }&sf=true&output=xml"
408376
end
409377

410378
# Add a message containing the Activity's id and name to the logs before deleting the activity.
@@ -426,7 +394,7 @@ def whatsapp_message(loc)
426394
location: location,
427395
price: pc,
428396
url: activity_url,
429-
description: description_localised(loc),
397+
description: loc == :nl ? description_nl : description_en,
430398
locale: loc)
431399
end
432400

@@ -441,25 +409,4 @@ def gen_time_string(loc)
441409

442410
return fmt_dt.call(start_date) + fmt_tm.call(start_time) + edt
443411
end
444-
445-
# Converts a sticky activity to an iCalendar event
446-
def to_calendar_event(locale)
447-
event = Icalendar::Event.new
448-
event.uid = id.to_s
449-
450-
if whole_day? # Adhire to the iCalendar spec
451-
event.dtstart = Icalendar::Values::Date.new(calendar_start)
452-
event.dtstart.ical_param("VALUE", "DATE")
453-
event.dtend = Icalendar::Values::Date.new(calendar_end)
454-
event.dtend.ical_param("VALUE", "DATE")
455-
else
456-
event.dtstart = calendar_start
457-
event.dtend = calendar_end
458-
end
459-
460-
event.summary = name
461-
event.description = description_localised(locale)
462-
event.location = location
463-
return event
464-
end
465412
end

app/models/member.rb

-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class Member < ApplicationRecord
1616
validates :emergency_phone_number, presence: true, if: :underage?
1717

1818
validates :email, presence: true, uniqueness: { case_sensitive: false }, format: { with: /\A.+@(?!(.+\.)*uu\.nl\z).+\..+\z/i }
19-
validates :calendar_id, presence: true, uniqueness: true
2019

2120
# An attr_accessor is basically a variable attached to the model but not stored in the database
2221
attr_accessor :require_student_id
@@ -204,11 +203,6 @@ def groups
204203
return groups.values
205204
end
206205

207-
# Whilst we cannot assign an id on creation, we can assign an id before validation, which is almost the same
208-
before_validation on: [:save, :create] do
209-
self.calendar_id = SecureRandom.uuid if calendar_id.blank?
210-
end
211-
212206
# Rails also has hooks you can hook on to the process of saving, updating or deleting. Here the join_date is automatically filled in on creating a new member
213207
# We also check for a duplicate study, and discard the duplicate if found.
214208
# (Not doing this would lead to a database constraint violation.)

app/views/members/activities/index.html.haml

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
= I18n.t 'members.activities.index.activities_calendar'
99
%button.btn.btn-secondary#copy-btn{:type => 'button'}
1010
= I18n.t 'members.activities.index.copy_ICS'
11-
%button.btn.btn-secondary#copy-btn-personal{:type => 'button'}
12-
= I18n.t 'members.activities.index.copy_ICS_personal'
1311
- else
1412
.alert.alert-warning= I18n.t('members.activities.index.no_activities')
1513

config/locales/en.yml

+1-11
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ en:
3333
description: Description
3434
description_en: English description
3535
description_nl: Dutch description
36-
disclaimer: Data on this activity may be outdated, as it was addes as a one-time copy of the information given at that time. Up-to-date info can be found on Koala.
3736
end_date: Enddate
3837
end_time: Endtime
39-
google_event: Copy once to calendar
38+
google_event: Add to calendar
4039
is_alcoholic: Alcoholic(18+)
4140
is_enrollable: Enrollable
4241
is_freshmans: First year students
@@ -416,15 +415,6 @@ en:
416415
study: Study/Studies
417416
transactions: Transactions
418417
association_name: Study association Sticky
419-
calendars:
420-
errors:
421-
not_logged_in: Not logged in
422-
unkown_hash: Unkown calendar hash
423-
jargon:
424-
activities: activities
425-
reservist: reservist
426-
personalised_activities_calendar:
427-
name: Sticky Activities
428418
date:
429419
day_names:
430420
- Sunday

config/locales/members.en.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ en:
1616
unenroll: Unenroll
1717
update_info: Update info
1818
back_to_overview: Back to activity overview
19-
calendar:
20-
confirm_understand_icalendar:
21-
confirm: I understand
22-
text: Koala will maintain the icalendar feed you just copied, at all times. However, koala is only aware of activities for which you are enrolled through koala, and not trough some other platform (like Pretix or a Google form). Remember to add those activities to your calendar manually.
23-
title: Warning
2419
error:
2520
edit: Could not edit!
2621
enroll: Could not enroll!
@@ -30,16 +25,15 @@ en:
3025
full: FULL!
3126
index:
3227
activities_calendar: Activities calendar
33-
copy_ICS: Copy Webcal link for all activitites
34-
copy_ICS_personal: Copy Personalised Webcal link
28+
copy_ICS: Copy Webcal link
3529
no_activities: There are no activities for which you can enroll at the moment
3630
info:
3731
more_info: More info
3832
notes_mandatory: Extra info required!
3933
home:
4034
edit:
4135
board: the board
42-
board_only_change_info: Some data can't be edited by yourself (for example your name, date of birth and student number). If this needs to be updated please contact
36+
board_only_change_info: Some data can't be edit by yourself (for example your name, date of birth and student number). If this needs to be updated please contact
4337
download:
4438
activities: Activities
4539
address: Address

config/locales/members.nl.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ nl:
1616
unenroll: Uitschrijven
1717
update_info: Update info
1818
back_to_overview: Terug naar overzicht
19-
calendar:
20-
confirm_understand_icalendar:
21-
confirm: Ik begrijp het
22-
text: Koala zal de icalendar feed die je zojuist hebt gekopieerd te allen tijde bijwerken. Echter, is koala alleen op de hoogte van activiteiten waarvoor je je via Koala hebt ingeschreven, en niet via een ander platform (zoals Pretix of een Google form). Vergeet niet om die activiteiten handmatig aan je agenda toe te voegen.
23-
title: Waarschuwing
2419
error:
2520
edit: Kon niet bijwerken!
2621
enroll: Kon niet inschrijven!
@@ -30,8 +25,7 @@ nl:
3025
full: VOL!
3126
index:
3227
activities_calendar: Activiteitenkalender
33-
copy_ICS: Kopieer Webcal link voor alle activiteiten
34-
copy_ICS_personal: Kopieer gepersonaliseerde Webcal link
28+
copy_ICS: Kopieer Webcal link
3529
no_activities: Er zijn op het moment geen activiteiten waar je je voor kunt inschrijven
3630
info:
3731
more_info: Meer info

0 commit comments

Comments
 (0)