Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename default pet task to checklist task template #847

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
46cf248
Update Controller and routing changes
ErinClaudio Jun 26, 2024
d5b0d0e
Update with main pull
ErinClaudio Jul 5, 2024
5328a2a
Update Controller and routing changes
ErinClaudio Jun 26, 2024
0bc19d5
Update merge conflict resolved
ErinClaudio Jul 5, 2024
c700105
Update merge conflict resolved
ErinClaudio Jul 5, 2024
d65f94c
Merge branch 'main' into Rename-DefaultPetTask-to-ChecklistTaskTemplate
ErinClaudio Jul 5, 2024
5a08d19
Update move files
ErinClaudio Jul 5, 2024
cb88f89
Update to view files
ErinClaudio Jul 5, 2024
08955cb
Update to testing files
ErinClaudio Jul 5, 2024
6a87457
Merge branch 'main' into Rename-DefaultPetTask-to-ChecklistTaskTemplate
ErinClaudio Jul 9, 2024
206fbd2
Merge branch 'main' into Rename-DefaultPetTask-to-ChecklistTaskTemplate
ErinClaudio Jul 10, 2024
4ea9462
Update Controller and routing changes
ErinClaudio Jun 26, 2024
749116e
Update with debugging
ErinClaudio Jul 10, 2024
680f6f0
Update Controller and routing changes
ErinClaudio Jun 26, 2024
b06fdc4
Update with main pull
ErinClaudio Jul 5, 2024
f2fc5d9
Update Controller and routing changes
ErinClaudio Jun 26, 2024
356a938
Update merge conflict resolved
ErinClaudio Jul 5, 2024
f089f9e
Update merge conflict resolved
ErinClaudio Jul 5, 2024
7079aec
Update to view files
ErinClaudio Jul 5, 2024
f3deac8
Update Controller and routing changes
ErinClaudio Jun 26, 2024
fc7b6cd
Major cleanup
ErinClaudio Jul 17, 2024
03531a7
More clean up
ErinClaudio Jul 17, 2024
74fc397
Test improved
ErinClaudio Jul 17, 2024
02cf146
Test improved
ErinClaudio Jul 17, 2024
6c0918d
file changed
ErinClaudio Jul 17, 2024
4c4f98b
file changed
ErinClaudio Jul 17, 2024
2a00720
file changed
ErinClaudio Jul 17, 2024
6c0d592
file changed
ErinClaudio Jul 17, 2024
50f76ad
file changed
ErinClaudio Jul 17, 2024
af24ecc
file removed
ErinClaudio Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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(Organizations::Staff::Checklist::TaskTemplate.all)
end

def new
@task = TaskTemplate.new
end

def create
binding.pry
@task = TaskTemplate.new(task_params)

if @task.save
redirect_to staff_checklist_task_templates_path, notice: t(".success")
else
flash.now[:alert] = t(".error")
render :new, status: :unprocessable_entity
end
end

def edit
binding.pry
end

def update
if @task_template.update(task_params)
binding.pry
redirect_to staff_checklist_task_templates_path, notice: t(".success")
else
binding.pry
render :edit, status: :unprocessable_entity
end
end

def destroy
# binding.pry
@task.destroy

redirect_to staff_checklist_task_templates_path, notice: t(".success")
end

private

def task_params
binding.pry
params.require(:task_template).permit(:name, :description, :due_in_days, :recurring)
end

def set_task
# binding.pry
@task = TaskTemplate.find(params[:id])
authorize! @task # here
rescue ActiveRecord::RecordNotFound
redirect_to staff_checklist_task_templates_path, alert: t(".error")
end

def context_authorize!
authorize! TaskTemplate,
context: {organization: Current.organization}
end
end
end
end
end

This file was deleted.

5 changes: 2 additions & 3 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ class Organization < ApplicationRecord
has_many :staff_accounts
has_many :users, through: :staff_accounts
has_many :pets
has_many :default_pet_tasks
has_many :forms, class_name: "CustomForm::Form", dependent: :destroy
has_many :task_templates
has_many :forms, dependent: :destroy
has_many :faqs

has_one :profile, dependent: :destroy, class_name: "OrganizationProfile", required: true
has_one :location, through: :profile
has_one :form_submission, dependent: :destroy
has_one :custom_page, dependent: :destroy
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# == Schema Information
#
# Table name: default_pet_tasks
# Table name: task_templates
#
# id :bigint not null, primary key
# description :string
Expand All @@ -13,13 +13,13 @@
#
# Indexes
#
# index_default_pet_tasks_on_organization_id (organization_id)
# index_task_templates_on_organization_id (organization_id)
#
# Foreign Keys
#
# fk_rails_... (organization_id => organizations.id)
#
class DefaultPetTask < ApplicationRecord
class TaskTemplate < ApplicationRecord
acts_as_tenant(:organization)

validates :name, presence: true
Expand Down
10 changes: 0 additions & 10 deletions app/policies/organizations/default_pet_task_policy.rb

This file was deleted.

10 changes: 10 additions & 0 deletions app/policies/organizations/task_template_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Organizations::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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
id: "recur"} %>
</div>
<%= f.submit t('general.save'), class: 'btn btn-primary' %>
<%= link_to t('general.cancel'), staff_default_pet_tasks_path, class: 'btn btn-secondary' %>
<%= link_to t('general.cancel'), staff_checklist_task_templates_path, class: 'btn btn-secondary' %>
<% end %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--page heading-->
<div class="text-center">
<h1 class="h4 mb-5">
<%= t('.edit_default_pet_task') %>
<%= t('.edit_staff_checklist_task_template') %>
</h1>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= render DashboardPageComponent.new(crumb: :default_pet_tasks_index) do |c| %>
<% c.with_header_title { t(".default_pet_tasks") } %>
<%= render DashboardPageComponent.new(crumb: :task_templates_index) do |c| %>
<% c.with_header_title { t(".task_templates") } %>
<% c.with_action do %>
<%= link_to t('.create_default_task'), new_staff_default_pet_task_path, class: "btn btn-primary" %><br>
<%= link_to t('.create_default_task'), new_staff_checklist_task_template_path, class: "btn btn-primary" %><br> # Here Erin
<% end %>
<% c.with_body do %>
<!-- row -->
Expand All @@ -21,7 +21,7 @@
</tr>
</thead>
<tbody>
<% @default_pet_tasks.each do |task| %>
<% @task_templates.each do |task| %>
<tr>
<td>
<%= task.name %>
Expand All @@ -39,8 +39,8 @@
<td>
<div class="text-right">
<div class="d-flex align-items-center justify-content-end">
<%= link_to 'Edit', edit_staff_default_pet_task_path(task), class: 'btn btn-warning m-2' %>
<%= link_to 'Delete', staff_default_pet_task_path(task), class: 'btn btn-danger m-2', data: { turbo_method: "delete", turbo_confirm: t('.are_you_sure_delete') } %>
<%= link_to 'Edit', edit_staff_checklist_task_template_path(task), class: 'btn btn-warning m-2' %>
<%= link_to 'Delete', staff_checklist_task_template_path(task), class: 'btn btn-danger m-2', data: { turbo_method: "delete", turbo_confirm: t('.are_you_sure_delete') } %>
</div>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--page heading-->
<div class="text-center">
<h1 class="h4 mb-5">
<%= t('.new_default_pet_task') %>
<%= t('.new_default_pet_task') %> #here Erin
</h1>
</div>

Expand Down
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
post "attach_files", on: :member, to: "pets#attach_files"
end

resources :default_pet_tasks
namespace :checklist do
resources :task_templates # here erin
end
resources :faqs
resources :dashboard, only: [:index] do
collection do
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ class ChangePageTextsToCustomPages < ActiveRecord::Migration[7.1]
def change
rename_table :page_texts, :custom_pages
end
end
end
26 changes: 13 additions & 13 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading