diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index 0a79838..1422efc 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -69,7 +69,7 @@ class CustomersController < ApplicationController def create @customer = Customer.new(allowed_params) if @customer.save - flash[:notice] = "New Customer Created" + flash[:notice] = t :notice_customer_created redirect_to @customer else flash[:error] = @customer.errors.full_messages.to_sentence @@ -90,6 +90,7 @@ class CustomersController < ApplicationController @issues.open.each { |i| @hours+= i.total_spent_hours } @closed_issues.each { |i| @closed_hours+= i.total_spent_hours } rescue + flash[:error] = t :notice_customer_not_found render_404 end end @@ -99,6 +100,7 @@ class CustomersController < ApplicationController begin @customer = Customer.find_by_id(params[:id]) rescue + flash[:error] = t :notice_customer_not_found render_404 end end @@ -108,13 +110,14 @@ class CustomersController < ApplicationController begin @customer = Customer.find_by_id(params[:id]) if @customer.update(allowed_params) - flash[:notice] = "Customer updated" + flash[:notice] = tv :notice_customer_updated redirect_to @customer else redirect_to edit_customer_path flash[:error] = @customer.errors.full_messages.to_sentence if @customer.errors end rescue + flash[:error] = t :notice_customer_not_found render_404 end end @@ -123,9 +126,10 @@ class CustomersController < ApplicationController def destroy begin Customer.find_by_id(params[:id]).destroy - flash[:notice] = "Customer deleted successfully" + flash[:notice] = t :notice_customer_deleted redirect_to action: :index rescue + flash[:error] = t :notice_customer_not_deleted render_404 end end @@ -143,6 +147,7 @@ class CustomersController < ApplicationController issue = Issue.find_by_id(params[:id]) redirect_to view_path issue.share_token.token rescue + flash[:error] = t :notice_issue_not_found render_404 end end @@ -178,6 +183,7 @@ class CustomersController < ApplicationController @time_entry = TimeEntry.new(issue: @issue, project: @issue.project) @relation = IssueRelation.new rescue + flash[:error] = t :notice_forbidden render_403 end end diff --git a/app/controllers/estimate_controller.rb b/app/controllers/estimate_controller.rb index 78e4f00..14ccbec 100644 --- a/app/controllers/estimate_controller.rb +++ b/app/controllers/estimate_controller.rb @@ -38,7 +38,7 @@ class EstimateController < ApplicationController begin send_data estimate.pdf, filename: "estimate #{estimate.doc_number}.pdf", disposition: :inline, type: "application/pdf" rescue - redirect_to :back, flash: { error: "Estimate not found" } + redirect_to :back, flash: { error: I18n.t(:notice_estimate_not_found) } end end @@ -51,7 +51,7 @@ class EstimateController < ApplicationController begin send_data estimate.pdf, filename: "estimate #{estimate.doc_number}.pdf", disposition: :inline, type: "application/pdf" rescue - redirect_to :back, flash: { error: "Estimate not found" } + redirect_to :back, flash: { error: I18n.t(:notice_estimate_not_found) } end end diff --git a/app/controllers/invoice_controller.rb b/app/controllers/invoice_controller.rb index dc7241b..09a9749 100644 --- a/app/controllers/invoice_controller.rb +++ b/app/controllers/invoice_controller.rb @@ -48,7 +48,7 @@ class InvoiceController < ApplicationController send_data @pdf, filename: "invoice #{ref}.pdf", disposition: :inline, type: "application/pdf" end rescue - redirect_to :back, flash: { error: "Invoice not found" } + redirect_to :back, flash: { error: I18n.t(:notice_invoice_not_found) } end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 0201549..14d9116 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -85,4 +85,17 @@ en: label_syncing: "Syncing Quickbooks" label_sandbox: "Sandbox" button_bulk_pdf: "Bulk PDF" - label_select_all: "Select All" \ No newline at end of file + label_select_all: "Select All" + notice_customer_created: "Customer created in Quickbooks" + notice_customer_updated: "Customer updated in Quickbooks" + notice_customer_not_found: "Customer not found in Quickbooks" + notice_customer_not_deleted: "Customer could not be deleted in Quickbooks" + notice_customer_deleted: "Customer deleted in Quickbooks" + notice_estimate_created: "Estimate created in Quickbooks" + notice_estimate_updated: "Estimate updated in Quickbooks" + notice_estimate_not_found: "Estimate not found" + notice_invoice_created: "Invoice created in Quickbooks" + notice_invoice_updated: "Invoice updated in Quickbooks" + notice_invoice_not_found: "Invoice not found" + notice_forbidden: "You do not have permission to access this resource" + notice_issue_not_found: "Issue not found" \ No newline at end of file