1
1
# frozen_string_literal: true
2
2
3
3
class ProfilesController < ApplicationController
4
- $units = { access : "Access Services" ,
5
- archives : "Archives" ,
6
- bib : "Cataloguing Strategies" ,
7
- collections : "Collection Strategies" ,
8
- copyright : "Copyright" ,
9
- digital : "Digital Production & Preservation Services" ,
10
- digrepo : "Digital Repository & Data Services" ,
11
- dsc : "Digital Scholarship Centre" ,
12
- facilities : "Facilities" ,
13
- health : "Faculty Engagement (Health Sciences)" ,
14
- science : "Faculty Engagement (Natural + Applied Sciences)" ,
15
- humanities : "Faculty Engagement (Social Sciences + Humanities)" ,
16
- iss : "Information Services & User Engagement" ,
17
- admin : "Library Administration" ,
18
- lad : "Library Application Development" ,
19
- las : "Library Application Support" ,
20
- metadata : "Metadata Strategies" ,
21
- open : "Open Publishing & Digitization Services" ,
22
- rdm : "Research Data Management" ,
23
- researchimpact : "Research Impact" ,
24
- its : "Specialized Technical Support" ,
25
- special : "Special Collections" ,
26
- stratigic : "Strategic Partnerships" ,
27
- tl : "Teaching & Learning" ,
28
- ux : "User Experience" }
29
- $buildings = { augustana : "Augustana Campus Library" ,
30
- bsj : "Bibliothèque Saint-Jean" ,
31
- bpsc : "Bruce Peel Special Collections" ,
32
- cameron : "Cameron Library" ,
33
- sperber : "Sperber Library" ,
34
- rcrf : "Research & Collections Resource Facility" ,
35
- rutherford : "Rutherford Library" ,
36
- stjosephs : "St. Joseph's Library" }
4
+ before_action :set_units , only : [ :index , :show , :new , :edit ]
5
+ before_action :set_buildings , only : [ :index , :show , :new , :edit ]
37
6
38
7
# You'll have to define "cmsPassword" in secrets.yml, or this will fail. Thanks, ansible.
39
8
http_basic_authenticate_with name : Rails . application . secrets . cms_user , password : Rails . application . secrets . cms_password , except : [ :index , :show ]
@@ -42,14 +11,14 @@ def index
42
11
path = request . url
43
12
if path . include? "unit"
44
13
@unit = params [ :unit ]
45
- @unitname = $ units[ params [ :unit ] . to_sym ]
14
+ @unitname = @ units[ params [ :unit ] . to_sym ]
46
15
@allunit = Profile . where ( unit : @unit )
47
16
@heads = @allunit . where ( opt_in : true ) . order ( :last_name )
48
17
@staff = @allunit . where ( opt_in : nil ) . order ( :last_name )
49
18
@profiles = @heads + @staff
50
19
elsif path . include? "building"
51
20
@building = params [ :building ]
52
- @buildingname = $ buildings[ params [ :building ] . to_sym ]
21
+ @buildingname = @ buildings[ params [ :building ] . to_sym ]
53
22
@profiles = Profile . where ( "campus_address=?" , params [ :building ] ) . order ( :first_name )
54
23
else
55
24
@profiles = Profile . order ( :first_name )
@@ -66,14 +35,10 @@ def show
66
35
67
36
def new
68
37
@profile = Profile . new
69
- @buildings = $buildings
70
- @units = $units
71
38
end
72
39
73
40
def edit
74
41
@profile = Profile . friendly . find ( params [ :id ] )
75
- @buildings = $buildings
76
- @units = $units
77
42
end
78
43
79
44
def create
@@ -104,4 +69,43 @@ def destroy
104
69
def profile_params
105
70
params . require ( :profile ) . permit ( :first_name , :last_name , :job_title , :unit , :email , :phone , :campus_address , :expertise , :introduction , :publications , :staff_since , :liason , :links , :orcid , :committees , :personal_interests , :opt_in )
106
71
end
72
+
73
+ def set_buildings
74
+ @buildings = { augustana : "Augustana Campus Library" ,
75
+ bsj : "Bibliothèque Saint-Jean" ,
76
+ bpsc : "Bruce Peel Special Collections" ,
77
+ cameron : "Cameron Library" ,
78
+ sperber : "Sperber Library" ,
79
+ rcrf : "Research & Collections Resource Facility" ,
80
+ rutherford : "Rutherford Library" ,
81
+ stjosephs : "St. Joseph's Library" }
82
+ end
83
+
84
+ def set_units
85
+ @units = { access : "Access Services" ,
86
+ archives : "Archives" ,
87
+ bib : "Cataloguing Strategies" ,
88
+ collections : "Collection Strategies" ,
89
+ copyright : "Copyright" ,
90
+ digital : "Digital Production & Preservation Services" ,
91
+ digrepo : "Digital Repository & Data Services" ,
92
+ dsc : "Digital Scholarship Centre" ,
93
+ facilities : "Facilities" ,
94
+ health : "Faculty Engagement (Health Sciences)" ,
95
+ science : "Faculty Engagement (Natural + Applied Sciences)" ,
96
+ humanities : "Faculty Engagement (Social Sciences + Humanities)" ,
97
+ iss : "Information Services & User Engagement" ,
98
+ admin : "Library Administration" ,
99
+ lad : "Library Application Development" ,
100
+ las : "Library Application Support" ,
101
+ metadata : "Metadata Strategies" ,
102
+ open : "Open Publishing & Digitization Services" ,
103
+ rdm : "Research Data Management" ,
104
+ researchimpact : "Research Impact" ,
105
+ its : "Specialized Technical Support" ,
106
+ special : "Special Collections" ,
107
+ stratigic : "Strategic Partnerships" ,
108
+ tl : "Teaching & Learning" ,
109
+ ux : "User Experience" }
110
+ end
107
111
end
0 commit comments