Mooooore resources
This commit is contained in:
parent
a2cbcac798
commit
2c4cd4a020
|
@ -1,11 +1,16 @@
|
||||||
class ResourcesController < ApplicationController
|
class ResourcesController < ApplicationController
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
before_filter :authenticate_user!, :load_users
|
before_filter :load_users
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@featured_resource = @resources.where("picture_file_name IS NOT NULL").sample
|
@featured_resource = @resources.where("picture_file_name IS NOT NULL").sample
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
# don't get too excited... for some reason this gets set to the current_user
|
||||||
|
@resource.user_id = nil
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
authorize! :create, @resource
|
authorize! :create, @resource
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Ability
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
can :read, Mac # Anonymous can read mac
|
can :read, Mac # Anonymous can read mac
|
||||||
can :scan, Mac # Need anonymous so CRON can scan
|
can :scan, Mac # Need anonymous so CRON can scan
|
||||||
|
can :read, Resource
|
||||||
|
|
||||||
if !user.nil?
|
if !user.nil?
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ class Ability
|
||||||
can [:update], Mac, :user_id => nil
|
can [:update], Mac, :user_id => nil
|
||||||
can [:create,:update], Mac, :user_id => user.id
|
can [:create,:update], Mac, :user_id => user.id
|
||||||
can :read, Payment, :user_id => user.id
|
can :read, Payment, :user_id => user.id
|
||||||
can :read, Resource
|
can [:create,:update], Resource, :user_id => user.id
|
||||||
can :read, UserCertification, :user_id => user.id
|
can :read, UserCertification, :user_id => user.id
|
||||||
can :read, User, :id => user.id #TODO: why can users update themselves? Maybe because Devise doesn't check users/edit?
|
can :read, User, :id => user.id #TODO: why can users update themselves? Maybe because Devise doesn't check users/edit?
|
||||||
can :compose_email, User
|
can :compose_email, User
|
||||||
|
|
|
@ -16,6 +16,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :certifications, :through => :user_certifications
|
has_many :certifications, :through => :user_certifications
|
||||||
has_many :payments
|
has_many :payments
|
||||||
has_many :macs
|
has_many :macs
|
||||||
|
has_many :resources
|
||||||
|
|
||||||
validates_format_of [:twitter_url, :facebook_url, :github_url, :website_url], :with => URI::regexp(%w(http https)), :allow_blank => true
|
validates_format_of [:twitter_url, :facebook_url, :github_url, :website_url], :with => URI::regexp(%w(http https)), :allow_blank => true
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<%= link_to 'People', users_path if can? :read, User %>
|
<%= link_to 'People', users_path if can? :read, User %>
|
||||||
</li>
|
</li>
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<%= link_to 'Tools', resources_path if can? :read, Resource %>
|
<%= link_to 'Tools & Resources', resources_path if can? :read, Resource %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to 'Access Cards', cards_path if can? :manage, Card %>
|
<%= link_to 'Access Cards', cards_path if can? :manage, Card %>
|
||||||
|
|
|
@ -40,13 +40,11 @@
|
||||||
<%= f.date_select :disposed_at, include_blank: true %>
|
<%= f.date_select :disposed_at, include_blank: true %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<% if can? :assign_user, @resource %>
|
|
||||||
<p>
|
<p>
|
||||||
<%= f.label :user_id, "Owner" %>
|
<%= f.label :user_id, "Owner" %>
|
||||||
<br />
|
<br />
|
||||||
<%= select(:resource, :user_id, options_from_collection_for_select(@users, :id, :name, @resource.user_id), include_blank: true) %>
|
<%= select(:resource, :user_id, options_from_collection_for_select(@users, :id, :name, @resource.user_id), include_blank: true) %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= f.label :donatable %><br />
|
<%= f.label :donatable %><br />
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script>
|
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#accordion .thumbnail { height: 150px; position: relative; }
|
.thumbnail { height: 150px; position: relative; }
|
||||||
#accordion .thumbnail .ownership,
|
.thumbnail .ownership,
|
||||||
#accordion .thumbnail .disposed
|
.thumbnail .disposed
|
||||||
{ position: absolute; top: 1px;
|
{ position: absolute; top: 1px;
|
||||||
text-shadow:
|
text-shadow:
|
||||||
-1px -1px 0 #fff,
|
-1px -1px 0 #fff,
|
||||||
|
@ -15,8 +15,8 @@
|
||||||
-1px 1px 0 #fff,
|
-1px 1px 0 #fff,
|
||||||
1px 1px 0 #fff;
|
1px 1px 0 #fff;
|
||||||
font-weight: bold; left: 10px; }
|
font-weight: bold; left: 10px; }
|
||||||
#accordion .thumbnail .disposed { color: red; }
|
.thumbnail .disposed { color: red; }
|
||||||
#accordion .thumbnail h4 { position: absolute; bottom: 1px; margin-bottom: 1px; }
|
.thumbnail h4 { position: absolute; bottom: 1px; margin-bottom: 1px; }
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,54 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-left: -15px;
|
||||||
|
margin-right: -15px;
|
||||||
|
}
|
||||||
|
.col-sm-2 {
|
||||||
|
width: 16.666666666666664%;
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
min-height: 1px;
|
||||||
|
padding-left: 15px;
|
||||||
|
padding-right: 15px;
|
||||||
|
}
|
||||||
|
.thumbnail {
|
||||||
|
display: block;
|
||||||
|
padding: 4px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
line-height: 1.428571429;
|
||||||
|
background-color: #fff;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
-webkit-transition: all .2s ease-in-out;
|
||||||
|
transition: all .2s ease-in-out;
|
||||||
|
}
|
||||||
|
.thumbnail a>img {
|
||||||
|
display: block;
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
.thumbnail a:hover { color: black; }
|
||||||
|
|
||||||
|
.thumbnail { height: 150px; position: relative; }
|
||||||
|
.thumbnail .ownership,
|
||||||
|
.thumbnail .disposed
|
||||||
|
{ display: none; }
|
||||||
|
.thumbnail h4 { position: absolute; bottom: 1px; margin-bottom: 1px; }
|
||||||
|
|
||||||
|
.clearfix { clear: both }
|
||||||
|
</style>
|
||||||
|
<b>Resources: </b><%= link_to "+ Add", new_resource_path, :class => 'btn' if can? :create, Resource %>
|
||||||
|
<div class="row"><%= render @user.resources if @user.resources %></div>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<b>Waiver?</b>
|
<b>Waiver?</b>
|
||||||
<%= @user.waiver.strftime("%B %d %Y") unless @user.waiver.blank? %>
|
<%= @user.waiver.strftime("%B %d %Y") unless @user.waiver.blank? %>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user