-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle autosave of additional expenses
form html/css tidy
- Loading branch information
1 parent
403fabb
commit 97bc3cf
Showing
18 changed files
with
417 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class AdditionalExpensesController < ApplicationController | ||
def create | ||
@additional_expense = AdditionalExpense.new(additional_expense_params) | ||
authorize @additional_expense | ||
|
||
respond_to do |format| | ||
if @additional_expense.save | ||
format.json { render json: @additional_expense, status: :created } | ||
else | ||
format.json { render json: @additional_expense.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
def destroy | ||
@additional_expense = AdditionalExpense.find(params[:id]) | ||
authorize @additional_expense | ||
|
||
@additional_expense.destroy! | ||
|
||
respond_to do |format| | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
|
||
def additional_expense_params | ||
params.require(:additional_expense) | ||
.permit(:case_contact_id, :other_expense_amount, :other_expenses_describe) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class AdditionalExpensePolicy < ApplicationPolicy | ||
class Scope < ApplicationPolicy::Scope | ||
def resolve | ||
case user | ||
when CasaAdmin, Supervisor | ||
scope.joins([:case_contact, :casa_case]).where(casa_case: {casa_org_id: user.casa_org.id}) | ||
when Volunteer | ||
scope.where(case_contact: user.case_contacts) | ||
else | ||
scope.none | ||
end | ||
end | ||
end | ||
|
||
def create? | ||
case user | ||
when Volunteer | ||
user.case_contacts.include?(record.case_contact) | ||
when CasaAdmin, Supervisor | ||
same_org? | ||
else | ||
false | ||
end | ||
end | ||
|
||
def destroy? | ||
case user | ||
when Volunteer | ||
user.case_contacts.include?(record.case_contact) | ||
when CasaAdmin, Supervisor | ||
same_org? | ||
else | ||
false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.