From 5e2adc37751efe7105b4ab3e60e9148e89553d62 Mon Sep 17 00:00:00 2001 From: Kevin Casey Date: Sat, 4 Jan 2014 13:37:07 -0800 Subject: [PATCH 1/3] bridge admin base --- app/assets/javascripts/application.js | 1 - app/assets/stylesheets/application.css | 1 - app/assets/stylesheets/main.css.scss | 12 +++++++- app/controllers/admin/bridge_controller.rb | 19 ++++++++++++ .../infosession_requests_controller.rb | 29 +++++++++++++++++++ app/helpers/admin/bridge_helper.rb | 2 ++ app/helpers/admin/vp_helper.rb | 2 ++ app/models/member_semester.rb | 8 ++--- app/models/role.rb | 2 +- app/models/user.rb | 1 + app/views/admin/bridge/index.html.erb | 5 ++++ .../admin/bridge/officer_photo_index.html.erb | 16 ++++++++++ .../admin/vp/officer_photo_upload.html.erb | 2 ++ app/views/alum/show.html.erb | 2 -- app/views/layouts/_officer_submenu.html.erb | 2 +- app/views/layouts/application.html.erb | 8 ++--- app/views/users/edit.html.erb | 1 - config/routes.rb | 5 ++++ .../admin/bridge_controller_spec.rb | 19 ++++++++++++ 19 files changed, 120 insertions(+), 17 deletions(-) create mode 100644 app/controllers/admin/bridge_controller.rb create mode 100644 app/controllers/infosession_requests_controller.rb create mode 100644 app/helpers/admin/bridge_helper.rb create mode 100644 app/helpers/admin/vp_helper.rb create mode 100644 app/views/admin/bridge/index.html.erb create mode 100644 app/views/admin/bridge/officer_photo_index.html.erb create mode 100644 app/views/admin/vp/officer_photo_upload.html.erb create mode 100644 spec/controllers/admin/bridge_controller_spec.rb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8e0d3f2..9666b83 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,5 +14,4 @@ //= require jquery_ujs //= require turbolinks //= require_tree . -//= require twitter/bootstrap //= require jquery.ui.all diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index d2f2ec3..ee44657 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -8,7 +8,6 @@ * You're free to add application-wide styles to this file and they'll appear at the top of the * compiled file, but it's generally better to create a new file per style scope. * - *= require twitter/bootstrap *= require_tree . *= require jquery.ui.all */ \ No newline at end of file diff --git a/app/assets/stylesheets/main.css.scss b/app/assets/stylesheets/main.css.scss index 766563b..c46de11 100644 --- a/app/assets/stylesheets/main.css.scss +++ b/app/assets/stylesheets/main.css.scss @@ -276,7 +276,7 @@ html[xmlns] .clearfix { body { background: image-url('back_gray.png'); font-family: "Puritan", "Lucinda Grande", Helvetica, Arial, serif; - font-size: 1.5em; + font-size: 0.9em; line-height: 1.3em; color: #403f3f; } @@ -590,6 +590,16 @@ h4 { color: #FFFFFF; } +.alert { + padding: 15px; + margin-bottom: 20px; + border: 1px solid transparent; + border-radius: 4px; + background-color: #f2dede; + border-color: #eed3d7; + color: #b94a48; +} + /*** Specific Page Styling ***/ #sidebar { float:right; diff --git a/app/controllers/admin/bridge_controller.rb b/app/controllers/admin/bridge_controller.rb new file mode 100644 index 0000000..a172981 --- /dev/null +++ b/app/controllers/admin/bridge_controller.rb @@ -0,0 +1,19 @@ +class Admin::BridgeController < ApplicationController + def index + end + + def officer_photo_index + @officers = MemberSemester.current.officers + end + + def officer_photo_upload + officer = User.find_by_id(params[:user][:id]) + officer.picture = params[:file_info] + if officer.save + flash[:notice] = "Successfully uploaded photo for #{officer.full_name}" + else + flash[:alert] = "Failed to upload photo for #{officer.full_name}" + end + redirect_to admin_bridge_officer_index_path + end +end diff --git a/app/controllers/infosession_requests_controller.rb b/app/controllers/infosession_requests_controller.rb new file mode 100644 index 0000000..7131909 --- /dev/null +++ b/app/controllers/infosession_requests_controller.rb @@ -0,0 +1,29 @@ +class InfosessionRequestsController < ApplicationController + + def about + end + + def new + @infosession_request = InfosessionRequest.new + end + + def create + @infosession_request = InfosessionRequest.new(infosession_request_params) + if verify_recaptcha(:model => @infosession_request, :message => "oops recaptcha failed!") && @infosession_request.save + IndrelMailer.infosession_registration(@infosession_request).deliver + redirect_to infosessions_path, success: "Infosession Request for #{@infosession_request.company_name} has been submitted." + else + flash.delete(:recaptcha_error) + render :new + end + end + + private + + def infosession_request_params + params.require(:infosession_request).permit(:company_name, :address1, :address2, :city, + :state, :zip_code, :name, :title, :phone, :email, + :alt_name, :alt_title, :alt_phone, :alt_email, + :pref_date, :pref_food, :pref_ad, :comments) + end +end diff --git a/app/helpers/admin/bridge_helper.rb b/app/helpers/admin/bridge_helper.rb new file mode 100644 index 0000000..ed2bc32 --- /dev/null +++ b/app/helpers/admin/bridge_helper.rb @@ -0,0 +1,2 @@ +module Admin::BridgeHelper +end diff --git a/app/helpers/admin/vp_helper.rb b/app/helpers/admin/vp_helper.rb new file mode 100644 index 0000000..68170de --- /dev/null +++ b/app/helpers/admin/vp_helper.rb @@ -0,0 +1,2 @@ +module Admin::VpHelper +end diff --git a/app/models/member_semester.rb b/app/models/member_semester.rb index 643af22..1b04698 100644 --- a/app/models/member_semester.rb +++ b/app/models/member_semester.rb @@ -24,19 +24,19 @@ def name end def candidates - Role.semester_filter(self).candidates.includes(:users).all_users + Role.semester_filter(self).candidates.all_users end def officers - Role.semester_filter(self).officers.includes(:users).all_users + Role.semester_filter(self).officers.all_users end def committee_members - Role.semester_filter(self).committee_members.includes(:users).all_users + Role.semester_filter(self).committee_members.all_users end def members - Role.members.includes(:users).all_users + Role.members.all_users end end diff --git a/app/models/role.rb b/app/models/role.rb index 41681d8..1fb82dc 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -36,7 +36,7 @@ def position_for_semester(position, semester) #returns array of users def all_users - all.collect { |role| role.users }.flatten + all.includes(:users).collect { |role| role.users }.flatten end def current_officers_from_committee(committee) diff --git a/app/models/user.rb b/app/models/user.rb index 07c017a..538bad4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -50,6 +50,7 @@ class User < ActiveRecord::Base has_and_belongs_to_many :member_semesters has_attached_file :picture, :default_url => "/pictures/:normalized_file_name.png", #guess saved as png to work w/ old system, if this gets updated (should only have to do it for current officers) can swap this to assets/person_placeholder.png + :styles => {original: "125x100#"}, :path => ":rails_root/public/pictures/:normalized_file_name.:extension", :url => "/pictures/:normalized_file_name.:extension" diff --git a/app/views/admin/bridge/index.html.erb b/app/views/admin/bridge/index.html.erb new file mode 100644 index 0000000..c4da4d0 --- /dev/null +++ b/app/views/admin/bridge/index.html.erb @@ -0,0 +1,5 @@ +

Bridge Admin

+ + diff --git a/app/views/admin/bridge/officer_photo_index.html.erb b/app/views/admin/bridge/officer_photo_index.html.erb new file mode 100644 index 0000000..20a6585 --- /dev/null +++ b/app/views/admin/bridge/officer_photo_index.html.erb @@ -0,0 +1,16 @@ +

Officer Photo Upload

+<%= form_tag nil, :multipart => true do %> +
+ <%= label :name, "Officer Name" %> + <%= collection_select(:user, :id, @officers, :id, :full_name) %>
+
+
+ <%= label :picture, "Picture" %> + <%= file_field_tag :file_info %> +
+
+ <%= label :submit, "" %> + + <%= submit_tag "Save changes" %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/vp/officer_photo_upload.html.erb b/app/views/admin/vp/officer_photo_upload.html.erb new file mode 100644 index 0000000..377b350 --- /dev/null +++ b/app/views/admin/vp/officer_photo_upload.html.erb @@ -0,0 +1,2 @@ +

Admin::Vp#officer_photo_upload

+

Find me in app/views/admin/vp/officer_photo_upload.html.erb

diff --git a/app/views/alum/show.html.erb b/app/views/alum/show.html.erb index 32b663f..90572cf 100644 --- a/app/views/alum/show.html.erb +++ b/app/views/alum/show.html.erb @@ -1,5 +1,3 @@ -

<%= notice %>

-

Grad semester: <%= @alum.grad_semester %> diff --git a/app/views/layouts/_officer_submenu.html.erb b/app/views/layouts/_officer_submenu.html.erb index 177f5d6..f3f6d06 100644 --- a/app/views/layouts/_officer_submenu.html.erb +++ b/app/views/layouts/_officer_submenu.html.erb @@ -121,7 +121,7 @@

  • Indrel Admin
  • <% end %> <% if authorize(:bridge) %> -
  • <%= link_to 'Bridge Admin', 'admin_bridge_index_path', :class => 'navigation_sublevel_item' %>
  • +
  • <%= link_to 'Bridge Admin', admin_bridge_path, :class => 'navigation_sublevel_item' %>
  • <% end %> <% if authorize(:vp) %>
  • <%= link_to "VP Admin", admin_vp_path, :class => "navigation_sublevel_item" %>
  • diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2b0be4f..163fd89 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -78,9 +78,8 @@
    <% flash.each do |name, msg| %> <% if msg.is_a?(String) %> -
    "> - - <%= content_tag :div, msg, :id => "flash_#{name}" %> +
    + <%= content_tag :div, msg, :id => "flash_#{name}", :class => ('message' if name == :notice) %>
    <% end %> <% end %> @@ -94,8 +93,7 @@ diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index dbeda43..a867076 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -26,7 +26,6 @@ <%= f.label :picture %> <%= f.file_field :file %>
    -
    <% end %>
    <%= f.label :private, "Keep my profile private" %> diff --git a/config/routes.rb b/config/routes.rb index 04cab7b..419b437 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,6 +39,11 @@ scope "vp" do get "/" => "vp#index", :as => :vp end + scope "bridge" do + match "/", to: "bridge#index", via: :get, as: :bridge + match "officer_photo_upload", to: "bridge#officer_photo_index", via: :get, as: :bridge_officer_index + match "officer_photo_upload", to: "bridge#officer_photo_upload", via: :post, as: :bridge_officer_upload + end end end diff --git a/spec/controllers/admin/bridge_controller_spec.rb b/spec/controllers/admin/bridge_controller_spec.rb new file mode 100644 index 0000000..ec80645 --- /dev/null +++ b/spec/controllers/admin/bridge_controller_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe Admin::BridgeController do + + describe "GET 'index'" do + it "returns http success" do + get 'index' + response.should be_success + end + end + + describe "GET 'officer_photo_upload'" do + it "returns http success" do + get 'officer_photo_upload' + response.should be_success + end + end + +end From 2dd1aae9648605d434a80b6d98f2cf7bb7bc580a Mon Sep 17 00:00:00 2001 From: Kevin Casey Date: Sat, 4 Jan 2014 13:40:31 -0800 Subject: [PATCH 2/3] removed some extra files --- .../infosession_requests_controller.rb | 29 ------------------- app/helpers/admin/bridge_helper.rb | 2 -- app/helpers/admin/vp_helper.rb | 2 -- .../admin/vp/officer_photo_upload.html.erb | 2 -- 4 files changed, 35 deletions(-) delete mode 100644 app/controllers/infosession_requests_controller.rb delete mode 100644 app/helpers/admin/bridge_helper.rb delete mode 100644 app/helpers/admin/vp_helper.rb delete mode 100644 app/views/admin/vp/officer_photo_upload.html.erb diff --git a/app/controllers/infosession_requests_controller.rb b/app/controllers/infosession_requests_controller.rb deleted file mode 100644 index 7131909..0000000 --- a/app/controllers/infosession_requests_controller.rb +++ /dev/null @@ -1,29 +0,0 @@ -class InfosessionRequestsController < ApplicationController - - def about - end - - def new - @infosession_request = InfosessionRequest.new - end - - def create - @infosession_request = InfosessionRequest.new(infosession_request_params) - if verify_recaptcha(:model => @infosession_request, :message => "oops recaptcha failed!") && @infosession_request.save - IndrelMailer.infosession_registration(@infosession_request).deliver - redirect_to infosessions_path, success: "Infosession Request for #{@infosession_request.company_name} has been submitted." - else - flash.delete(:recaptcha_error) - render :new - end - end - - private - - def infosession_request_params - params.require(:infosession_request).permit(:company_name, :address1, :address2, :city, - :state, :zip_code, :name, :title, :phone, :email, - :alt_name, :alt_title, :alt_phone, :alt_email, - :pref_date, :pref_food, :pref_ad, :comments) - end -end diff --git a/app/helpers/admin/bridge_helper.rb b/app/helpers/admin/bridge_helper.rb deleted file mode 100644 index ed2bc32..0000000 --- a/app/helpers/admin/bridge_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::BridgeHelper -end diff --git a/app/helpers/admin/vp_helper.rb b/app/helpers/admin/vp_helper.rb deleted file mode 100644 index 68170de..0000000 --- a/app/helpers/admin/vp_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::VpHelper -end diff --git a/app/views/admin/vp/officer_photo_upload.html.erb b/app/views/admin/vp/officer_photo_upload.html.erb deleted file mode 100644 index 377b350..0000000 --- a/app/views/admin/vp/officer_photo_upload.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

    Admin::Vp#officer_photo_upload

    -

    Find me in app/views/admin/vp/officer_photo_upload.html.erb

    From 94ebcfdeab5224172142ec70bfd6d1941f9ff206 Mon Sep 17 00:00:00 2001 From: Kevin Casey Date: Sat, 4 Jan 2014 15:51:43 -0800 Subject: [PATCH 3/3] extraneous includes(:users) --- app/controllers/candidate_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/candidate_controller.rb b/app/controllers/candidate_controller.rb index 3338d60..efafa60 100644 --- a/app/controllers/candidate_controller.rb +++ b/app/controllers/candidate_controller.rb @@ -42,6 +42,6 @@ def submit_quiz end def autocomplete_officer_name - render :json => Role.members.includes(:users).all_users.map {|p| {:label => p.full_name, :id => p.id} } + render :json => Role.members.all_users.map {|p| {:label => p.full_name, :id => p.id} } end end