-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Controller and routing changes
* add: authenticate_user! as a before action in application controller instead of calling it within multiple controllers * add: skip_before_action authenticate_user! for controllers that don't need user authentication * remove: commented out 'skip_before_action' from controllers * fix failing tests: after adding authentication * add: config for devise configuration for setting up custom failures through warden in the devise.rb * add custom failure file * update: failure app Co-authored-by: Paul DobbinSchmaltz <[email protected]> * add more context to why this authentication failure app is needed. * update: rails standard fix
- Loading branch information
1 parent
feb4cb1
commit 46cf248
Showing
8 changed files
with
105 additions
and
88 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
app/controllers/organizations/staff/checklist/task_template_controller.rb
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,67 @@ | ||
module Organizations | ||
module Staff | ||
module Checklist | ||
class TaskTemplatesController < Organizations::BaseController | ||
before_action :context_authorize!, only: %i[index new create] | ||
before_action :set_task, only: %i[edit update destroy] | ||
|
||
layout "dashboard" | ||
|
||
def index | ||
@task_templates = authorized_scope(TaskTemplate.all) | ||
end | ||
|
||
def new | ||
@task_template = TaskTemplate.new | ||
end | ||
|
||
def create | ||
@task_template = TaskTemplate.new(task_params) | ||
|
||
if @task_template | ||
redirect_to staff_task_templates_path, notice: t(".success") | ||
else | ||
flash.now[:alert] = t(".error") | ||
render :new, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @task_template.update(task_params) | ||
redirect_to staff_task_templates_path, notice: t(".success") | ||
else | ||
render :edit, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy | ||
@task_template.destroy | ||
|
||
redirect_to staff_task_templates_path, notice: t(".success") | ||
end | ||
|
||
private | ||
|
||
def task_params | ||
params.require(:task_template).permit(:name, :description, :due_in_days, :recurring) | ||
end | ||
|
||
def set_task | ||
@task_template = TaskTemplate.find(params[:id]) | ||
|
||
authorize! @task_template | ||
rescue ActiveRecord::RecordNotFound | ||
redirect_to staff_task_templates_path, alert: t(".error") | ||
end | ||
|
||
def context_authorize! | ||
authorize! TaskTemplate, | ||
context: {organization: Current.organization} | ||
end | ||
end | ||
end | ||
end | ||
end |
61 changes: 0 additions & 61 deletions
61
app/controllers/organizations/staff/default_pet_tasks_controller.rb
This file was deleted.
Oops, something went wrong.
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
14 changes: 14 additions & 0 deletions
14
app/policies/organizations/checklist/task_template_policy.rb
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,14 @@ | ||
module Organizations | ||
module Checklist | ||
class TaskTemplatePolicy < ApplicationPolicy | ||
pre_check :verify_organization! | ||
pre_check :verify_active_staff! | ||
|
||
alias_rule :new?, :create?, :index?, to: :manage? | ||
|
||
def manage? | ||
permission?(:manage_task_templates) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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
5 changes: 5 additions & 0 deletions
5
db/migrate/20240625184654_rename_default_pet_tasks_to_task_templates.rb
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,5 @@ | ||
class RenameDefaultPetTasksToTaskTemplates < ActiveRecord::Migration[7.1] | ||
def change | ||
rename_table :default_pet_tasks, :task_templates | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.