Skip to content

Commit

Permalink
added to ability rb admins to do stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangaaron committed May 1, 2015
1 parent 7cbd654 commit 5208839
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion app/controllers/problems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def index
end
problems = Problem.filter(@current_user, session[:filters])
@problems = problems.results
# @paginated_problems =
end

#eventually this will be an AJAX call. ALSO WE NEED TO CHANGE OUR HABTM ASSOCIATION TO HAS_MANY: THROUGH SO WE CAN USE VALIDATIONS AND STUFF
Expand Down
4 changes: 3 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def initialize(user)
user ||= Instructor.new
if user.admin?
can :manage, Instructor
can :manage, Problem
can :manage, Collection
end
if user.instructor? or user.admin?
if user.instructor?
can :manage, Problem, :instructor_id => user.id
can :read, Problem, :is_public => true
can :read, Problem, :collection => { :is_public => true }
Expand Down
2 changes: 1 addition & 1 deletion app/views/collections/_collections_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
= "Created By: " + problem.instructor.name
%td
- problem.collections.each do |collection|
= link_to "#{collection.name.truncate(20)} \n", collection_path(:id => collection.id)
= link_to "#{collection.name} \n", collection_path(:id => collection.id)
%td= problem.tags.map {|tags| tags.name + ', '}.join
%td= link_to "", remove_problem_path( :id => problem.id, :collection_id => collection), {:id => "problem_#{problem.id}", :class => 'glyphicon glyphicon-trash'}
2 changes: 1 addition & 1 deletion app/views/collections/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
= f.submit 'Update', class: 'btn btn-primary'
=link_to collection_path(collection), :class => 'btn btn-default', method: :delete, :confirm => 'Delete this collection?' do
%span.glyphicon.glyphicon-trash
Delete
Delete Collection
=link_to export_path(:id => collection), :class => 'btn btn-default' do
%span.glyphicon.glyphicon-export
Export
2 changes: 1 addition & 1 deletion app/views/collections/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%div.table-responsive
%h2 Create New Collection

= form_for(@collection, :html => {:class => 'form-inline'}) do |f| #magical hacks to set remote to be true when called from finalize_upload
= form_for(@collection, :html => {:class => 'form-inline'}) do |f|
= f.label :name
= f.text_field :name, :class => 'form-control'
= f.label :description
Expand Down
1 change: 1 addition & 0 deletions app/views/problems/_problems_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
%table.table.table-striped#problems
%thead
%tr
%th
%th Question Text
%th Collections
%th Tags
Expand Down

0 comments on commit 5208839

Please sign in to comment.