Skip to content

Commit 46eb812

Browse files
committed
Allow setting a "home space" in trainer profile. #1204
1 parent 4db5db6 commit 46eb812

7 files changed

Lines changed: 19 additions & 2 deletions

File tree

app/controllers/trainers_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def set_trainer
4141
# Never trust parameters from the scary internet, only allow the white list through.
4242
def trainer_params
4343
params.require(:trainer).permit(:id, :firstname, :surname, :website,
44-
:orcid, :email, :public, :description,
44+
:orcid, :email, :public, :description, :space_id,
4545
:location, :experience, { :language => [] }, { :expertise_academic => [] },
4646
{ :expertise_technical => [] }, { :interest => [] }, { :activity => [] },
4747
{ :fields => [] }, { :social_media => [] })

app/controllers/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def init_user
130130
def user_params
131131
allowed_parameters = [:email, :username, :password, :image, :image_url, {
132132
profile_attributes: [:id, :firstname, :surname, :email, :website, :public,
133-
:description, :location, :orcid, :experience,
133+
:description, :location, :orcid, :experience, :space_id,
134134
{ expertise_academic: [] }, { expertise_technical: [] },
135135
{ interest: [] }, { activity: [] }, { language: [] },
136136
{ fields: [] }, { social_media: [] }]

app/models/trainer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Trainer < Profile
66
friendly_id :full_name, use: :slugged
77

88
include Searchable
9+
include InSpace
910

1011
if TeSS::Config.solr_enabled
1112
# :nocov:

app/views/users/_form.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@
102102
model_name: 'user[profile_attributes]',
103103
title: t('profile.hints.social_media') %>
104104

105+
<% if TeSS::Config.feature['spaces'] %>
106+
<%= f.association :space, errors: @user.profile.errors[:space],
107+
model_name: 'user[profile_attributes]',
108+
hint: t('profile.hints.space') %>
109+
<% end %>
110+
105111
<p><i class="fa fa-exclamation-triangle"></i>&nbsp;<%= t 'profile.trainer.disclaimer' %></p>
106112

107113

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ en:
763763
interest: 'Add keyword(s) to identify your main areas of interest.'
764764
activity: 'Include any global connections or activities that relate to your skills and training work.'
765765
social_media: 'Links or handles for your social media profiles.'
766+
space: 'The space in which your trainer profile will appear.'
766767
authentication:
767768
password:
768769
title: Login
@@ -1046,6 +1047,7 @@ en:
10461047
check_broken_scrapers: Receive emails with scrapers that have not found anything last period.
10471048
profile:
10481049
language: Languages Spoken
1050+
space: Home space
10491051

10501052
helpers:
10511053
submit:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddSpaceIdToProfiles < ActiveRecord::Migration[7.2]
2+
def change
3+
add_reference :profiles, :space, foreign_key: true
4+
end
5+
end

db/schema.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,10 @@
469469
t.string "type", default: "Profile"
470470
t.string "fields", default: [], array: true
471471
t.boolean "orcid_authenticated", default: false
472+
t.bigint "space_id"
472473
t.index ["orcid"], name: "index_profiles_on_orcid"
473474
t.index ["slug"], name: "index_profiles_on_slug", unique: true
475+
t.index ["space_id"], name: "index_profiles_on_space_id"
474476
end
475477

476478
create_table "roles", force: :cascade do |t|
@@ -696,6 +698,7 @@
696698
add_foreign_key "node_links", "nodes"
697699
add_foreign_key "nodes", "users"
698700
add_foreign_key "people", "profiles"
701+
add_foreign_key "profiles", "spaces"
699702
add_foreign_key "source_filters", "sources"
700703
add_foreign_key "sources", "content_providers"
701704
add_foreign_key "sources", "spaces"

0 commit comments

Comments
 (0)