diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb
index 37d7ba239..cb80a2a54 100644
--- a/app/controllers/api/v1/users_controller.rb
+++ b/app/controllers/api/v1/users_controller.rb
@@ -219,7 +219,7 @@ def find
def find_or_create
OSU::AccessPolicy.require_action_allowed!(:create, current_api_user, User)
# OpenStax::Api#standard_(update|create) require an ActiveRecord model, which we don't have
- # Substitue a Hashie::Mash to read the JSON encoded body
+ # Substitute a Hashie::Mash to read the JSON encoded body
payload = consume!(Hashie::Mash.new, represent_with: Api::V1::FindOrCreateUserRepresenter)
payload.application = current_api_user.application
diff --git a/app/representers/api/v1/user_representer.rb b/app/representers/api/v1/user_representer.rb
index 3280c38cf..4bc7e663e 100644
--- a/app/representers/api/v1/user_representer.rb
+++ b/app/representers/api/v1/user_representer.rb
@@ -50,10 +50,10 @@ class UserRepresenter < Roar::Decorator
readable: true,
writeable: false
- property :support_identifier,
- type: String,
+ property :consent_preferences,
+ type: JSON,
readable: true,
- writeable: false
+ writeable: true
property :is_not_gdpr_location,
if: ->(user_options:, **) { user_options.try(:fetch, :include_private_data, false) },
@@ -102,15 +102,6 @@ class UserRepresenter < Roar::Decorator
description: "One of #{User.faculty_statuses.keys.map(&:to_s).inspect}"
}
- property :needs_to_complete_educator_profile?,
- as: :needs_complete_edu_profile,
- type: String,
- readable: true,
- writeable: false,
- schema_info: {
- description: "New flow faculty user needs to finish signing up?"
- }
-
property :role,
as: :self_reported_role,
if: ->(user_options:, **) { user_options.try(:fetch, :include_private_data, false) },
@@ -161,14 +152,6 @@ class UserRepresenter < Roar::Decorator
description: "One of #{User.school_locations.keys.map(&:to_s).inspect}"
}
- property :is_kip,
- type: :boolean,
- readable: true,
- writeable: false,
- schema_info: {
- description: 'Whether the user is part of a Key Institutional Partner school'
- }
-
property :is_administrator,
type: :boolean,
readable: true,
@@ -177,14 +160,6 @@ class UserRepresenter < Roar::Decorator
description: 'Whether the user is an Accounts admin'
}
- property :grant_tutor_access,
- type: :boolean,
- readable: true,
- writeable: false,
- schema_info: {
- description: 'Whether the user should be granted Tutor access'
- }
-
collection :contact_infos,
if: ->(user_options:, **) { user_options.try(:fetch, :include_private_data, false) },
decorator: ContactInfoRepresenter
diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb
index 11c0e76de..a9ae648bd 100644
--- a/app/views/admin/users/_form.html.erb
+++ b/app/views/admin/users/_form.html.erb
@@ -133,6 +133,15 @@
<% end %>
+
+
<% if @user.school %>
<%= f.label :school, class: "col-sm-2 control-label" %>
diff --git a/db/migrate/20240808171751_add_consent_preferences_to_user.rb b/db/migrate/20240808171751_add_consent_preferences_to_user.rb
new file mode 100644
index 000000000..abbf80286
--- /dev/null
+++ b/db/migrate/20240808171751_add_consent_preferences_to_user.rb
@@ -0,0 +1,5 @@
+class AddConsentPreferencesToUser < ActiveRecord::Migration[5.2]
+ def change
+ add_column :users, :consent_preferences, :jsonb
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 040887a30..25d004d8e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2024_01_23_173834) do
+ActiveRecord::Schema.define(version: 2024_08_08_171751) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
@@ -471,6 +471,7 @@
t.boolean "sheer_id_webhook_received"
t.jsonb "books_used_details"
t.string "adopter_status"
+ t.jsonb "consent_preferences"
t.index "lower((first_name)::text)", name: "index_users_on_first_name"
t.index "lower((last_name)::text)", name: "index_users_on_last_name"
t.index "lower((username)::text)", name: "index_users_on_username_case_insensitive"
diff --git a/spec/factories/user.rb b/spec/factories/user.rb
index dd972c56d..21eed1962 100644
--- a/spec/factories/user.rb
+++ b/spec/factories/user.rb
@@ -7,6 +7,7 @@
uuid {Faker::Alphanumeric.alphanumeric(number: 10, min_alpha: 3, min_numeric: 3)}
role { User::STUDENT_ROLE }
school { FactoryBot.build(:school) }
+ consent_preferences { JSON.generate({'accepted': ['functional', 'analytical'], 'rejected': ['essential', 'personalization']}) }
is_profile_complete { true }
diff --git a/spec/representers/api/v1/user_representer_spec.rb b/spec/representers/api/v1/user_representer_spec.rb
index 0e809a4d2..7fafc6300 100644
--- a/spec/representers/api/v1/user_representer_spec.rb
+++ b/spec/representers/api/v1/user_representer_spec.rb
@@ -22,9 +22,9 @@
end
end
- context 'support_identifier' do
+ context 'consent_preferences' do
it 'can be read' do
- expect(representer.to_hash['support_identifier']).to eq user.support_identifier
+ expect(representer.to_hash['consent_preferences']).to eq user.consent_preferences
end
it 'cannot be written (attempts are silently ignored)' do
diff --git a/spec/support/user_hash.rb b/spec/support/user_hash.rb
index 954b723ab..9c7d88907 100644
--- a/spec/support/user_hash.rb
+++ b/spec/support/user_hash.rb
@@ -8,11 +8,10 @@ def user_matcher(user, include_private_data: false)
first_name: user.first_name,
last_name: user.last_name,
full_name: user.full_name,
- needs_complete_edu_profile: false,
title: user.title,
suffix: user.suffix,
uuid: user.uuid,
- support_identifier: user.support_identifier,
+ consent_preferences: user.consent_preferences,
is_test: user.is_test?,
is_administrator: user.is_administrator?,
salesforce_contact_id: user.salesforce_contact_id,