Skip to content

Commit f0f479e

Browse files
Merged WebPredict/tech-screen into master
2 parents 9eec895 + 1081e38 commit f0f479e

File tree

77 files changed

+1005
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1005
-469
lines changed

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ gem 'newrelic_rpm'
2222
gem 'chartkick'
2323
gem 'groupdate'
2424

25+
gem 'font-awesome-rails'
26+
gem 'jquery-ui-rails'
27+
gem "wysiwyg-rails"
28+
2529
group :development, :test do
2630
gem 'sqlite3', '1.3.9'
2731
gem 'byebug', '3.4.0'

Gemfile.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ GEM
105105
fog-softlayer (0.4.1)
106106
fog-core
107107
fog-json
108+
font-awesome-rails (4.3.0.0)
109+
railties (>= 3.2, < 5.0)
108110
formatador (0.2.5)
109111
globalid (0.3.3)
110112
activesupport (>= 4.1.0)
@@ -134,6 +136,8 @@ GEM
134136
rails-dom-testing (~> 1.0)
135137
railties (>= 4.2.0)
136138
thor (>= 0.14, < 2.0)
139+
jquery-ui-rails (5.0.3)
140+
railties (>= 3.2.16)
137141
json (1.8.2)
138142
listen (2.8.5)
139143
celluloid (>= 0.15.2)
@@ -259,6 +263,9 @@ GEM
259263
railties (~> 4.0)
260264
sprockets-rails (>= 2.0, < 4.0)
261265
will_paginate (3.0.7)
266+
wysiwyg-rails (1.2.6)
267+
font-awesome-rails (>= 4.2.0.0)
268+
railties (>= 3.2, < 5.0)
262269

263270
PLATFORMS
264271
ruby
@@ -275,10 +282,12 @@ DEPENDENCIES
275282
coffee-rails (= 4.1.0)
276283
faker (= 1.4.2)
277284
fog (= 1.23.0)
285+
font-awesome-rails
278286
groupdate
279287
guard-minitest (= 2.3.1)
280288
jbuilder (= 2.2.3)
281289
jquery-rails (= 4.0.3)
290+
jquery-ui-rails
282291
mini_backtrace (= 0.1.3)
283292
mini_magick (= 3.8.0)
284293
minitest-reporters (= 1.0.5)
@@ -295,3 +304,4 @@ DEPENDENCIES
295304
uglifier (= 2.5.3)
296305
web-console (= 2.0.0.beta3)
297306
will_paginate (= 3.0.7)
307+
wysiwyg-rails

app/assets/javascripts/application.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,27 @@
1414
//= require jquery_ujs
1515
//= require bootstrap
1616
//= require turbolinks
17+
//= require jquery-ui
18+
//= require froala_editor.min.js
19+
//= require plugins/font_family.min.js
20+
//= require plugins/font_size.min.js
21+
//= require plugins/file_upload.min.js
22+
//= require plugins/lists.min.js
1723
//= require_tree .
24+
25+
var ready;
26+
ready = (function() {
27+
$('a[href="' + this.location.pathname + '"]').parent().addClass('active');
28+
$("#navbar-search-input").autocomplete({
29+
source: '/categories/autocomplete.json',
30+
});
31+
});
32+
33+
// $('#search-questions-form').bind("change keyup",function() {
34+
// alert('change keyup called');
35+
// $('#search-questions-form').submit();
36+
// });
37+
38+
$(document).ready(ready);
39+
$(document).on('page:load', ready);
40+

app/assets/stylesheets/application.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
1111
* file per style scope.
1212
*
13+
*= require jquery-ui
14+
*= require froala_editor.min.css
15+
*= require froala_style.min.css
16+
*= require font-awesome
1317
*= require_tree .
1418
*= require_self
1519
*/

app/assets/stylesheets/custom.css.scss

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,18 @@ footer {
9898
float: left;
9999
}
100100
ul {
101-
float: right;
102101
list-style: none;
103102
li {
104-
float: left;
105-
margin-left: 15px;
106-
}
103+
float: left;
104+
margin-left: 8px;
105+
}
106+
}
107+
108+
.centered_list {
109+
width: 100%;
110+
float: none;
111+
text-align: center;
112+
margin-left: 15px;
107113
}
108114
}
109115

@@ -152,13 +158,13 @@ aside {
152158
}
153159

154160
.row {
155-
margin-left: 5%;
156-
margin-right: 5%;
161+
margin-left: 2%;
162+
margin-right: 2%;
157163
}
158164

159165
.page-header {
160-
margin-left: 5%;
161-
margin-right: 5%;
166+
margin-left: 2%;
167+
margin-right: 2%;
162168
}
163169

164170
.padded-col {
@@ -167,6 +173,12 @@ aside {
167173
font-size: 1.2em;
168174
}
169175

176+
.btn-table {
177+
td {
178+
padding: 1px;
179+
}
180+
}
181+
170182
@media (min-width: 993px) {
171183
.mobile-section {
172184
display: none;
@@ -190,14 +202,6 @@ aside {
190202
display: none;
191203
}
192204

193-
footer {
194-
ul {
195-
li {
196-
margin-left: 8px;
197-
}
198-
}
199-
}
200-
201205
.responsive-image {
202206
width: 300px;
203207
}
@@ -308,6 +312,10 @@ input[type="radio"] {
308312
vertical-align: middle;
309313
}
310314

315+
input[type="checkbox"] {
316+
width: 15px;
317+
}
318+
311319
#error_explanation {
312320
color: red;
313321
ul {
@@ -444,6 +452,11 @@ span.picture {
444452
margin-right: 5%;
445453
}
446454

455+
.min-padded-row {
456+
margin-left: 1%;
457+
margin-right: 1%;
458+
}
459+
447460
.padded-bottom-row {
448461
padding-bottom: 40px;
449462
}

app/controllers/application_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class ApplicationController < ActionController::Base
55
include SessionsHelper
66

77
def admin_user
8-
redirect_to(root_url) unless current_user.admin?
9-
end
8+
redirect_to(root_url) unless current_user.admin?
9+
end
1010

1111
private
1212
def logged_in_user

app/controllers/candidates_controller.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CandidatesController < ApplicationController
1010
def index
1111
query = ''
1212
searchparam = ""
13-
if params[:search] && params[:search] != ''
13+
if !params[:search].blank?
1414
query += ' lower(name) LIKE ? '
1515
searchparam = "%#{params[:search].downcase}%"
1616
end
@@ -76,7 +76,7 @@ def select_candidate
7676

7777
def create
7878
if params[:commit] == "Cancel"
79-
redirect_to root_url
79+
redirect_to candidates_path
8080
else
8181
if current_user.membership_level_id == 1 && current_user.candidates.any? &&
8282
current_user.candidates.count > Limits::MAX_CANDIDATES_FREE
@@ -121,6 +121,12 @@ def create
121121
end
122122
end
123123

124+
def add_note
125+
@note = Note.new
126+
@note.candidate_id = params[:id]
127+
render 'notes/new'
128+
end
129+
124130
def update
125131
@candidate = Candidate.find(params[:id])
126132
respond_to do |format|
@@ -159,6 +165,7 @@ def edit
159165
def show
160166
@candidate = Candidate.find(params[:id])
161167
@candidate_test_submissions = @candidate.test_submissions.paginate(page: params[:page]).order(sort_column + " " + sort_direction)
168+
@candidate_notes = @candidate.notes.paginate(page: params[:page])
162169
end
163170

164171
def destroy

app/controllers/categories_controller.rb

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,37 @@ def index
2222

2323
def create
2424
if params[:commit] == "Cancel"
25-
redirect_to root_url
25+
redirect_to all_categories_path
2626
else
27-
@candidate = current_user.candidates.build(candidate_params)
28-
if @candidate.save
29-
flash[:success] = "Candidate created!"
27+
@category = Category.new(category_params)
28+
if @category.save
29+
flash[:success] = "Category " + @category.name + " created!"
3030

31-
if params[:commit] == "Save And Send Test"
32-
flash[:info] = "Select test to send to candidate:"
33-
@single_test_select = true
34-
redirect_to tests_path
35-
else
36-
redirect_to root_url
37-
end
31+
redirect_to all_categories_path
3832
else
3933
render 'new'
4034
end
4135
end
4236
end
4337

38+
def autocomplete
39+
@categories = Category.order(:name).where("lower(name) like ?", "%#{params[:term].downcase}%")
40+
respond_to do |format|
41+
format.html
42+
format.json {
43+
render json: @categories.map(&:name)
44+
}
45+
end
46+
end
47+
4448
def update
4549
@category = Category.find(params[:id])
4650
respond_to do |format|
4751
if @category.update_attributes(category_params)
48-
format.html { redirect_to @category, notice: 'Category was successfully updated.' }
52+
format.html {
53+
flash[:success] = "Category was successfully updated."
54+
redirect_to @category
55+
}
4956
format.json { render :show, status: :ok, location: @category }
5057
else
5158
format.html { render :edit }
@@ -74,9 +81,8 @@ def destroy
7481
end
7582

7683
private
77-
7884
def category_params
79-
params.require(:category).permit(:name)
85+
params.require(:category).permit(:name, :term)
8086
end
8187

8288
def admin_user
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
class NotesController < ApplicationController
2+
before_action :logged_in_user, only: [:create, :destroy, :edit, :update, :show, :index]
3+
before_action :correct_user, only: [:destroy, :edit, :update, :show, :index]
4+
5+
helper_method :sort_column, :sort_direction
6+
7+
add_breadcrumb "Dashboard", :root_path
8+
add_breadcrumb "Notes", :notes_path
9+
10+
def index
11+
query = ''
12+
searchparam = ""
13+
if !params[:search].blank?
14+
query += ' lower(content) LIKE ? '
15+
searchparam = "%#{params[:search].downcase}%"
16+
end
17+
18+
@notes = Note.where(query, searchparam).paginate(page: params[:page], per_page: 10).order(sort_column + " " + sort_direction)
19+
20+
@searched = query != ''
21+
end
22+
23+
def create
24+
@candidate = Candidate.find(params[:note][:candidate_id])
25+
if params[:commit] == "Cancel"
26+
redirect_to @candidate
27+
else
28+
@candidate.notes.build(note_params)
29+
if @candidate.save
30+
flash[:success] = "Note added."
31+
redirect_to @candidate
32+
else
33+
render 'new'
34+
end
35+
end
36+
end
37+
38+
private
39+
def note_params
40+
params.require(:note).permit(:content, :candidate_id)
41+
end
42+
43+
def correct_user
44+
@candidate = current_user.candidates.find_by(id: params[:candidate_id])
45+
redirect_to root_url if @candiate.nil?
46+
end
47+
48+
def sort_column
49+
Note.column_names.include?(params[:sort]) ? params[:sort] : "created_at"
50+
end
51+
52+
def sort_direction
53+
%w[asc desc].include?(params[:direction]) ? params[:direction] : "desc"
54+
end
55+
56+
end

0 commit comments

Comments
 (0)