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