Authorize creating requests for users, and add links for pennings to zeus requests
This commit is contained in:
parent
ad395945f2
commit
a803d005a3
4 changed files with 7 additions and 2 deletions
|
@ -19,6 +19,7 @@ class TransactionsController < ApplicationController
|
|||
end
|
||||
else
|
||||
request = Request.new @transaction.info
|
||||
authorize!(:create, request)
|
||||
if request.save
|
||||
render json: request, status: :created
|
||||
else
|
||||
|
|
|
@ -47,7 +47,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.zeus
|
||||
find_or_create_by name: 'Zeus'
|
||||
@@zeus ||= find_or_create_by name: 'Zeus'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class UserAbility
|
|||
|
||||
can :manage, :all if user.penning?
|
||||
can :read, user, id: user.id
|
||||
can :manage, Request, user_id: user.id
|
||||
can :manage, Request, creditor_id: user.id
|
||||
can :manage, Notification, user_id: user.id
|
||||
can :create, Transaction do |t|
|
||||
t.debtor == user && t.amount <= Rails.application.config.maximum_amount
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
- if current_user.penning
|
||||
%li.pure-menu-item
|
||||
=link_to "Zeus", User.zeus, class: "pure-menu-link"
|
||||
%li.pure-menu-item
|
||||
= link_to "Requests (#{User.zeus.incoming_requests.size})", user_requests_path(User.zeus), class: 'pure-menu-link'
|
||||
%li.pure-menu-item
|
||||
= link_to "Notifications (#{User.zeus.notifications.size})", user_notifications_path(User.zeus), class: 'pure-menu-link'
|
||||
%li.pure-menu-item
|
||||
= link_to "Requests (#{current_user.incoming_requests.size})", user_requests_path(current_user), class: 'pure-menu-link'
|
||||
%li.pure-menu-item
|
||||
|
|
Loading…
Reference in a new issue