Skip to content
2 changes: 1 addition & 1 deletion app/controllers/v1/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def generate_alias
def ical # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
return head :unauthorized unless authenticate_user_by_ical_secret_key

requested_categories = params[:categories].try(:split, ',')
requested_categories = User.find_by(id: params[:user_id]).ical_categories

permitted_categories = (requested_categories & Activity.categories) ||
Activity.categories
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def context
def excluded_display_properties
%i[created_at updated_at deleted_at activated_at archived_at password_digest activation_token
avatar activation_token_valid_till setup_complete otp_secret_key otp_required
ical_secret_key id]
ical_secret_key ical_categories id]
end

def otp_already_required_error
Expand Down
2 changes: 1 addition & 1 deletion app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Activity < ApplicationRecord
after_save :copy_author_and_group_to_form!

def self.categories
%w[algemeen societeit vorming dinsdagkring woensdagkring
%w[algemeen societeit vorming kring
choose ifes ozon disputen kiemgroepen huizen extern eerstejaars curiositates]
end

Expand Down
10 changes: 6 additions & 4 deletions app/resources/v1/user_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class V1::UserResource < V1::ApplicationResource # rubocop:disable Metrics/Class
:ifes_data_sharing_preference, :info_in_almanak, :almanak_subscription_preference,
:digtus_subscription_preference, :email, :birthday, :address, :postcode, :city,
:phone_number, :food_preferences, :vegetarian, :study, :start_study,
:picture_publication_preference, :ical_secret_key,
:picture_publication_preference, :ical_secret_key, :ical_categories
:password, :avatar, :avatar_url, :avatar_thumb_url,
:user_details_sharing_preference, :allow_sofia_sharing, :trailer_drivers_license,
:sidekiq_access, :setup_complete
Expand Down Expand Up @@ -51,12 +51,13 @@ def fetchable_fields
# Relationships
allowed_keys += %i[groups active_groups memberships mail_aliases mandates
group_mail_aliases permissions photos user_permissions]
allowed_keys += %i[ical_secret_key] if me?

allowed_keys += %i[ical_secret_key ical_categories] if me?
if update_or_me?
allowed_keys += %i[login_enabled otp_required activated_at emergency_contact
emergency_number ifes_data_sharing_preference info_in_almanak
almanak_subscription_preference digtus_subscription_preference
user_details_sharing_preference allow_sofia_sharing
user_details_sharing_preference allow_sofia_sharing ical_secret_key
sidekiq_access setup_complete]
end
allowed_keys += %i[picture_publication_preference] if read_or_me?
Expand All @@ -78,7 +79,8 @@ def self.creatable_fields(context) # rubocop:disable Metrics/MethodLength
attributes += %i[otp_required password
user_details_sharing_preference allow_sofia_sharing
picture_publication_preference info_in_almanak
ifes_data_sharing_preference sidekiq_access setup_complete]
ifes_data_sharing_preference ical_secret_key sidekiq_access
setup_complete]
end

if user_can_create_or_update?(context)
Expand Down
19 changes: 19 additions & 0 deletions db/migrate/20241113104056_simplyfing_calender_options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class SimplyfingCalenderOptions < ActiveRecord::Migration[7.0]
def up
add_column :users, :ical_categories, :string, array: true, default: []
Activity.where(category: 'dinsdagkring').find_each do |activity|
activity.update(category: 'kring')
end

Activity.where(category: 'woensdagkring').find_each do |activity|
activity.update(category: 'kring')
end
end

def down
remove_column :users, :ical_categories
Activity.where(category: 'kring').find_each do |activity|
activity.update(category: 'dinsdagkring')
end
end
end
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@
t.string "user_details_sharing_preference"
t.boolean "allow_sofia_sharing", default: false, null: false
t.string "nickname"
t.string "ical_categories", default: [], array: true
t.boolean "trailer_drivers_license", default: false, null: false
t.boolean "setup_complete", default: false, null: false
t.index ["deleted_at"], name: "index_users_on_deleted_at"
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/activities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
start_time { Faker::Time.between(from: 1.day.ago, to: Time.zone.today) }
end_time { Faker::Time.between(from: 1.day.from_now, to: 2.days.from_now) }
category do
%w[algemeen societeit vorming dinsdagkring woensdagkring
%w[algemeen societeit vorming kring
choose ifes ozon disputen kiemgroepen huizen extern eerstejaars curiositates].sample
end
publicly_visible { false }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
context 'when it is another category' do
let(:record) do
build_stubbed(:activity,
category: %w[algemeen sociëteit vorming dinsdagkring woensdagkring
category: %w[algemeen sociëteit vorming kring
disputen kiemgroepen huizen extern curiositates].sample)
end

Expand Down
Loading