Skip to content
Permalink
Browse files

Merge branch 'master' into edit_org_page

Conflicts:
	public/stylesheets/sass/screen.scss
  • Loading branch information...
jordan@futurefridays.com jordan@futurefridays.com
jordan@futurefridays.com authored and jordan@futurefridays.com committed Dec 28, 2010
2 parents 737fe68 + f9f6d0b commit 4c781e107b6106bc77c46ae28cf705001c849605
Showing with 833 additions and 265 deletions.
  1. +3 −1 Gemfile
  2. +15 −2 Gemfile.lock
  3. +1 −8 README.rdoc
  4. +1 −0 app/controllers/admin/organizations_controller.rb
  5. +1 −1 app/controllers/admin/projects_controller.rb
  6. +8 −0 app/controllers/admin/users_controller.rb
  7. +5 −0 app/controllers/application_controller.rb
  8. +10 −0 app/helpers/admin/users_helper.rb
  9. +9 −0 app/models/ability.rb
  10. +4 −3 app/models/photo.rb
  11. +25 −0 app/models/user.rb
  12. +7 −0 app/views/admin/users/_user.html.haml
  13. +14 −0 app/views/admin/users/index.html.haml
  14. +1 −1 app/views/layouts/admin.html.haml
  15. +6 −0 app/views/pages/access_denied.html.haml
  16. +5 −0 app/views/pages/access_denied_anonymous.html.haml
  17. +30 −48 app/views/projects/show.html.haml
  18. +3 −2 app/views/shared/_header.html.haml
  19. +10 −0 config/locales/en.yml
  20. +10 −0 config/locales/fr.yml
  21. +1 −0 config/routes.rb
  22. +9 −0 db/migrate/20101211173312_add_roles_mask_to_users.rb
  23. +38 −2 features/admin_creates_organization.feature
  24. +35 −0 features/admin_creates_project.feature
  25. +13 −0 features/admin_views_homepage.feature
  26. +53 −0 features/admin_views_users.feature
  27. +4 −0 features/support/paths.rb
  28. +1 −0 features/visitor_views_homepage.feature
  29. +1 −1 features/visitor_views_project.feature
  30. +21 −0 lib/tasks/maintenance.rake
  31. BIN public/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png
  32. BIN public/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png
  33. BIN public/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png
  34. BIN public/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png
  35. BIN public/stylesheets/images/ui-bg_glass_75_dadada_1x400.png
  36. BIN public/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png
  37. BIN public/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png
  38. BIN public/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png
  39. BIN public/stylesheets/images/ui-icons_222222_256x240.png
  40. BIN public/stylesheets/images/ui-icons_2e83ff_256x240.png
  41. BIN public/stylesheets/images/ui-icons_454545_256x240.png
  42. BIN public/stylesheets/images/ui-icons_888888_256x240.png
  43. BIN public/stylesheets/images/ui-icons_cd0a0a_256x240.png
  44. +76 −75 public/stylesheets/sass/screen.scss
  45. +154 −64 spec/controllers/admin/organizations_controller_spec.rb
  46. +154 −57 spec/controllers/admin/projects_controller_spec.rb
  47. +53 −0 spec/controllers/admin/users_controller_spec.rb
  48. +10 −0 spec/helpers/admin/users_helper.rb
  49. +42 −0 spec/models/user_spec.rb
  50. BIN vendor/cache/cancan-1.4.1.gem
  51. BIN vendor/cache/code_buddy-0.0.6.gem
  52. BIN vendor/cache/coderay-0.9.6.gem
  53. BIN vendor/cache/paperclip-2.3.4.gem
  54. BIN vendor/cache/paperclip-2.3.8.gem
  55. BIN vendor/cache/sinatra-1.1.0.gem
  56. BIN vendor/cache/tilt-1.1.gem
@@ -5,7 +5,7 @@ gem "rack"
gem "haml"
gem "high_voltage"
gem "hoptoad_notifier"
gem "paperclip"
gem "paperclip", "2.3.8"
gem "formtastic"
gem "pg"
gem "flutie"
@@ -16,6 +16,7 @@ gem 'devise_rpx_connectable'
gem 'aws-s3'
gem "http_accept_language", :git => 'http://github.com/iain/http_accept_language.git'
gem 'will_paginate', '3.0.pre2' # still not release for Rails 3
gem 'cancan'
gem 'hassle', :git => 'git://github.com/koppen/hassle.git'

# http://blog.davidchelimsky.net/2010/07/11/rspec-rails-2-generators-and-rake-tasks/
@@ -24,6 +25,7 @@ group :development, :test, :cucumber do
gem "ruby-debug"
gem "faker"
gem "factory_girl_rails"
gem "code_buddy"
end

group :test, :cucumber do
@@ -52,13 +52,20 @@ GEM
bourne (1.0)
mocha (= 0.9.8)
builder (2.1.2)
cancan (1.4.1)
capybara (0.3.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.3)
code_buddy (0.0.6)
coderay (~> 0.9.6)
json_pure (~> 1.4.6)
rack
sinatra (~> 1.1.0)
coderay (0.9.6)
columnize (0.3.1)
configuration (1.1.0)
cucumber (0.9.2)
@@ -121,7 +128,7 @@ GEM
mocha (0.9.8)
rake
nokogiri (1.4.3.1)
paperclip (2.3.4)
paperclip (2.3.8)
activerecord
activesupport
pg (0.9.0)
@@ -172,8 +179,12 @@ GEM
json_pure
rubyzip
shoulda (2.11.3)
sinatra (1.1.0)
rack (~> 1.1)
tilt (~> 1.1)
term-ansicolor (1.0.5)
thor (0.14.3)
tilt (1.1)
timecop (0.3.5)
treetop (1.4.8)
polyglot (>= 0.3.1)
@@ -189,7 +200,9 @@ PLATFORMS
DEPENDENCIES
aws-s3
bourne
cancan
capybara
code_buddy
cucumber-rails
database_cleaner
devise
@@ -209,7 +222,7 @@ DEPENDENCIES
http_accept_language!
launchy
nokogiri
paperclip
paperclip (= 2.3.8)
pg
rack
rails (= 3.0.1)
@@ -31,18 +31,11 @@ http://github.com/ReliefHub/reliefhub
Pivotal Tracker:

https://www.pivotaltracker.com/projects/122363

Campfire Chat Room:

https://futurefridays.campfirenow.com/7f77a


Designs:

http://melissayasko.com/ReliefHub/reliefhub.html

Build Machine:

http://ci.reliefhub.railsmachina.com

==Development Notes

@@ -1,5 +1,6 @@
class Admin::OrganizationsController < ApplicationController
layout 'admin'
load_and_authorize_resource

def index
@organizations = Organization.all
@@ -1,7 +1,7 @@
class Admin::ProjectsController < ApplicationController
layout 'admin'

before_filter :organization, :except => [:index]
load_and_authorize_resource

def index
@projects = Project.all
@@ -0,0 +1,8 @@
class Admin::UsersController < ApplicationController
layout 'admin'
load_and_authorize_resource

def index
@users = User.ascending.paginate :page => params[:page], :per_page => 10
end
end
@@ -26,4 +26,9 @@ def sign_out_path
destroy_user_session_path
end
helper_method :sign_out_path

rescue_from CanCan::AccessDenied do |exception|
redirect_to page_path(current_user.nil? ? 'access_denied_anonymous' : 'access_denied')
end

end
@@ -0,0 +1,10 @@
module Admin::UsersHelper
def display_if_is?(user, role)
if user.is? role
'Enabled'
else
'Disabled'
end
end
end

@@ -0,0 +1,9 @@
class Ability
include CanCan::Ability

def initialize(user)
if user && user.is?('admin')
can :manage, :all
end
end
end
@@ -1,6 +1,7 @@
class Photo < ActiveRecord::Base
include Mixins::PaperclipStorageDecider
has_attached_file :file, @paperclip_storage.merge({ :styles => { :thumb => '100x80#',
:small => '114x114#',
:full => '288x255#'} })
has_attached_file :file, @paperclip_storage.merge({:styles => {:thumb => '100x80#',
:small => '114x114#',
:medium => '209x209#',
:full => '288x255#'}})
end
@@ -13,6 +13,31 @@ class User < ActiveRecord::Base
validates_presence_of :first_name
validates_presence_of :last_name

scope :ascending, order('last_name, first_name')

# http://github.com/ryanb/cancan/wiki/role-based-authorization

ROLES =%w[admin field_operator organization_manager]

def roles=(roles)
roles = roles.split if roles.is_a? String
self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum
end

def roles
ROLES.reject do |r|
((roles_mask || 0) & 2**ROLES.index(r)).zero?
end
end

def is?(role)
roles.include?(role.to_s)
end

def display_name
"#{first_name} #{last_name}"
end

def unique_projects
projects.uniq
end
@@ -0,0 +1,7 @@
%tr
%td= user.created_at.strftime("%m/%d/%Y")
%td= user.display_name
%td= user.email
%td= display_if_is?(user, 'field_operator')
%td= display_if_is?(user, 'organization_manager')
%td= display_if_is?(user, 'admin')
@@ -0,0 +1,14 @@
%h1.left
Users
%table
%tr.header
%th Created
%th User Name
%th Email
%th Field Operator
%th Orphanage Manager
%th Site Administrator
= render @users
.pagination
%ul=will_paginate @users
.clear
@@ -6,7 +6,7 @@
%li{:class => "#{controller_name == 'projects' ? 'selected' : ''}"}
%h3= link_to 'Projects', admin_projects_path
%li{:class => "#{controller_name == 'users' ? 'selected' : ''}"}
%h3= link_to 'Users', '#'
%h3= link_to 'Users', admin_users_path
#content.round.projects.content
= yield
= render :file => 'layouts/application'
@@ -0,0 +1,6 @@
#body_wrap
#access_denied
%h1=t '.access_denied'
=t('.access_denied_text1')
= link_to t('.access_denied_sign_out'), sign_out_path
=t('.access_denied_text2')
@@ -0,0 +1,5 @@
#body_wrap
#access_denied
%h1=t '.access_denied'
=t('.access_denied_text')
= link_to t('.access_denied_sign_in'), sign_in_path
@@ -1,77 +1,59 @@
#col_left
- if @project.photo
#project_photo= image_tag(@project.photo_url(:small))
#project_photo= image_tag(@project.photo_url(:medium))
#project_map
= google_map_image("146x146", @project.organization_address)
= google_map_image("212x212", @project.organization_address)
#project_information
%h1= @project.name
%h3= @project.organization_name
%h4= @project.organization_address
%br
%p= @project.description
%p= @project.overview
%br
%p Funds Purpose: #{@project.funds_purpose}
%br
%p Funding Needed: #{number_to_currency(@project.goal, :precision => 0)}
%br
%p Funding Received: #{number_to_currency(@project.amount_raised, :precision => 0)}
%br
%div{:id => ['pb', @project.id]}
#progressbar
=render :partial => 'shared/progbar', :object => @project
.clear
#percent_raised_number
#{number_to_percentage(@project.percent_raised, :precision => 0)} Raised
#more_projects
%p View more projects
#more_projects_photos
#project_photo1
%a{ :href => "#" }
%img{ :src => "/images/more_projects_img.jpg", :alt => "project photo" }
#project_photo2
%a{ :href => "#" }
%img{ :src => "/images/more_projects_img.jpg", :alt => "project photo" }
#project_photo3
%a{ :href => "#" }
%img{ :src => "/images/more_projects_img.jpg", :alt => "project photo" }
#social_logos_large
.addthis_toolbox.addthis_default_style
%a.addthis_button_facebook_like{ "fb:like:layout" => "button_count" }
%a.addthis_button_tweet
%script{ :type => "text/javascript", :src => "http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cfc4db62e7d6471" }
.clear
%br
#donor_info
#form_left
#donor_head Donor Information
.row
%label{ :class => "required" } Name:
.field_holder
%input{ :name => "#", :type => "text", :id => "first_name" }
%span{ :class => "error", :style => "display:none;" }
Please enter your First Name
.clear
.row
%label{ :class => "required" } Email:
.field_holder
%input{ :name => "#", :type => "text", :id => "email" }
%span{ :class => "error", :style => "display:none;" }
Please enter your Email
.clear
.row
%label Additional Comments:
.field_holder
%textarea{ :name => "#", :rows => "6", :cols => "20", :id => "comments" }
.clear
#form_right
#col_right
#donor_info
= amazon_simple_pay_form_tag do
#amount_project_detail
%label Amount
= text_field_tag 'amount'
= hidden_field_tag 'referenceId', @project.id
= hidden_field_tag 'description', @project.name
#pay_type
#submit_signup
= image_submit_tag('/images/contribute_btn.gif')
= image_submit_tag('/images/contributenow.png')
.clear
#pay_type
.clear
#more_projects
%p View more projects
#more_projects_photos
#project_photo1
%a{ :href => "#" }
%img{ :src => "/images/more_projects_img.jpg", :alt => "project photo" }
#project_photo2
%a{ :href => "#" }
%img{ :src => "/images/more_projects_img.jpg", :alt => "project photo" }
#project_photo3
%a{ :href => "#" }
%img{ :src => "/images/more_projects_img.jpg", :alt => "project photo" }
#social_logos_large
.addthis_toolbox.addthis_default_style
%p Tell your friends about this project
%a.addthis_button_facebook_like{ "fb:like:layout" => "button_count" }
%a.addthis_button_tweet
%script{ :type => "text/javascript", :src => "http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cfc4db62e7d6471" }
.clear
%br
=render :partial => 'comments', :object => @project


@@ -10,7 +10,8 @@
%ul
- if user_signed_in?
%li= link_to t('.logout'), destroy_user_session_url
%li= link_to 'Admin', admin_organizations_path
- if current_user.is?('admin')
%li= link_to 'Admin', admin_organizations_path
- else
%li= link_to t('.login'), user_session_url
%li= link_to 'Blog', 'http://blog.reliefhub.org/'
@@ -22,4 +23,4 @@
#lang
=link_to_language image_tag('/images/francais.png'), :fr
=link_to_language image_tag('/images/english.jpg'), :en
.clear
.clear
@@ -32,6 +32,16 @@ en:
donation_error:
were_sorry: "We're sorry"
there_was_a_problem: "There was a problem with your donation. Please try again."
access_denied:
access_denied: "Access Denied"
access_denied_text1: "You don't have access to this page. Please"
access_denied_sign_out: "sign out"
access_denied_sign_in: "sign in"
access_denied_text2: "and sign in as a different user."
access_denied_anonymous:
access_denied: "Access Denied"
access_denied_text: "You don't have access to this page. Please"
access_denied_sign_in: "sign in."
shared:
header:
home: Home

0 comments on commit 4c781e1

Please sign in to comment.
You can’t perform that action at this time.