Files
grecia/app/models/abilities/common.rb
iagirre 4db2584f87 The tags are suggested based on the entries the user makes.
Cambios para hacer commit:
	modificado:    app/assets/javascripts/tag_autocomplete.js.coffee
	modificado:    app/assets/stylesheets/autocomplete_overrides.scss
	nuevo archivo: app/controllers/tags_controller.rb
	modificado:    app/models/abilities/common.rb
	modificado:    app/views/debates/_form.html.erb
	modificado:    app/views/proposals/_form.html.erb
	modificado:    config/initializers/acts_as_taggable_on.rb
	modificado:    config/routes.rb
	modificado:    spec/lib/acts_as_taggable_on_spec.rb
2017-09-21 18:21:45 +02:00

81 lines
2.4 KiB
Ruby

module Abilities
class Common
include CanCan::Ability
def initialize(user)
merge Abilities::Everyone.new(user)
can [:read, :update], User, id: user.id
can :read, Debate
can :update, Debate do |debate|
debate.editable_by?(user)
end
can :read, Proposal
can :update, Proposal do |proposal|
proposal.editable_by?(user)
end
can [:retire_form, :retire], Proposal, author_id: user.id
can :create, Comment
can :create, Debate
can :create, Proposal
can :suggest, Debate
can :suggest, Proposal
can :suggest, ActsAsTaggableOn::Tag
can [:flag, :unflag], Comment
cannot [:flag, :unflag], Comment, user_id: user.id
can [:flag, :unflag], Debate
cannot [:flag, :unflag], Debate, author_id: user.id
can [:flag, :unflag], Proposal
cannot [:flag, :unflag], Proposal, author_id: user.id
can [:create, :destroy], Follow
can [:create, :destroy, :new], Document, documentable: { author_id: user.id }
can [:new_nested, :upload, :destroy_upload], Document
unless user.organization?
can :vote, Debate
can :vote, Comment
end
if user.level_two_or_three_verified?
can :vote, Proposal
can :vote_featured, Proposal
can :vote, SpendingProposal
can :create, SpendingProposal
can :create, Budget::Investment, budget: { phase: "accepting" }
can :suggest, Budget::Investment, budget: { phase: "accepting" }
can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id
can :vote, Budget::Investment, budget: { phase: "selecting" }
can [:show, :create], Budget::Ballot, budget: { phase: "balloting" }
can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" }
can :create, DirectMessage
can :show, DirectMessage, sender_id: user.id
can :answer, Poll do |poll|
poll.answerable_by?(user)
end
can :answer, Poll::Question do |question|
question.answerable_by?(user)
end
end
can [:create, :show], ProposalNotification, proposal: { author_id: user.id }
can :create, Annotation
can [:update, :destroy], Annotation, user_id: user.id
can [:create], Topic
can [:update, :destroy], Topic, author_id: user.id
end
end
end