Skip to content
This repository has been archived by the owner on Dec 10, 2017. It is now read-only.

Commit

Permalink
Merge pull request #29 from compserv/kevin/admin_bridge
Browse files Browse the repository at this point in the history
Kevin/admin bridge
  • Loading branch information
negativetwelve committed Jan 5, 2014
2 parents bbeb998 + 94ebcfd commit 7279a59
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 18 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require twitter/bootstrap
//= require jquery.ui.all
1 change: 0 additions & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
12 changes: 11 additions & 1 deletion app/assets/stylesheets/main.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions app/controllers/admin/bridge_controller.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/controllers/candidate_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions app/models/member_semester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/bridge/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>Bridge Admin</h1>

<ul>
<li><%= link_to 'Photo Upload', admin_bridge_officer_index_path %></li>
</ul>
16 changes: 16 additions & 0 deletions app/views/admin/bridge/officer_photo_index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1>Officer Photo Upload</h1>
<%= form_tag nil, :multipart => true do %>
<div class="field">
<%= label :name, "Officer Name" %>
<%= collection_select(:user, :id, @officers, :id, :full_name) %> </br>
</div>
<div class="field">
<%= label :picture, "Picture" %>
<%= file_field_tag :file_info %>
</div>
<div class="field">
<%= label :submit, "" %>
<label>&nbsp;</label>
<%= submit_tag "Save changes" %>
</div>
<% end %>
2 changes: 0 additions & 2 deletions app/views/alum/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<p id="notice"><%= notice %></p>

<p>
<strong>Grad semester:</strong>
<%= @alum.grad_semester %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_officer_submenu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<li><a href="/admin/indrel/" class="navigation_sublevel_item">Indrel Admin</a></li>
<% end %>
<% if authorize(:bridge) %>
<li><%= link_to 'Bridge Admin', 'admin_bridge_index_path', :class => 'navigation_sublevel_item' %></li>
<li><%= link_to 'Bridge Admin', admin_bridge_path, :class => 'navigation_sublevel_item' %></li>
<% end %>
<% if authorize(:vp) %>
<li><%= link_to "VP Admin", admin_vp_path, :class => "navigation_sublevel_item" %></li>
Expand Down
8 changes: 3 additions & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@
<div id="container">
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
<div class="alert alert-<%= name == :notice ? "success" : "danger" %>">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<div id="messages" class="<%= 'alert' if name != :notice%>">
<%= content_tag :div, msg, :id => "flash_#{name}", :class => ('message' if name == :notice) %>
</div>
<% end %>
<% end %>
Expand All @@ -94,8 +93,7 @@

<div id="footer">
<div id="footer-right">Eta Kappa Nu, Mu Chapter</div>
<div id="footer-left"><%= link_to "HOME", root_url %> | <%= link_to "CONTACT", contact_path %> | <%= link_to "Confirm Candidate Accounts", users_list_path('candidates', approved: "false") %></div>
<% # I know this is the wrong spot for this, but I don't really want to sort through the admin stuff yet %>
<div id="footer-left"><%= link_to "HOME", root_url %> | <%= link_to "CONTACT", contact_path %> </div>
</div>

</body>
Expand Down
1 change: 0 additions & 1 deletion app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<%= f.label :picture %>
<%= f.file_field :file %>
</div>
<br style="clear: both;" />
<% end %>
<div class="field">
<%= f.label :private, "Keep my profile private" %>
Expand Down
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions spec/controllers/admin/bridge_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7279a59

Please sign in to comment.