-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into snyk-fix-76bceeb9f3e5d0278a99f655e0f8095a
- Loading branch information
Showing
54 changed files
with
1,599 additions
and
557 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 |
---|---|---|
@@ -1 +1 @@ | ||
3.2.2 | ||
3.3.4 |
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,12 @@ | ||
class ItemsController < ApplicationController | ||
def update_status | ||
@item = Item.find(params[:id]) | ||
case params[:status] | ||
when 'resolved' | ||
@item.resolve! | ||
when 'unresolved' | ||
@item.unresolve! | ||
end | ||
redirect_back(fallback_location: show_pending_orders_path, notice: 'Status atualizado com sucesso.') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,86 @@ | ||
# app/controllers/productions_controller.rb | ||
|
||
class ProductionsController < ApplicationController | ||
before_action :set_production, only: [:show, :edit, :update, :destroy] | ||
before_action :set_tailor_options, only: [:new, :edit, :create, :update] | ||
before_action :set_production, only: [:show, :edit, :update, :destroy, :verify] | ||
before_action :set_tailors, only: [:new, :edit, :create, :update] | ||
|
||
def index | ||
@productions = Production.all | ||
@productions = Production.includes(:tailor, production_products: :product).all | ||
end | ||
|
||
def show | ||
def show; end | ||
|
||
def verify | ||
@production = @account.productions.find(params[:id]) | ||
end | ||
|
||
def new | ||
@production = Production.new | ||
@production.production_products.build | ||
end | ||
|
||
def edit | ||
@tailors = Tailor.all | ||
end | ||
|
||
def create | ||
@production = Production.new(production_params) | ||
if @production.save | ||
redirect_to @production, notice: 'Production was successfully created.' | ||
redirect_to @production, notice: t('.production_created') | ||
else | ||
render :new | ||
@tailors = Tailor.all | ||
flash.now[:alert] = t('.creation_failed') | ||
logger.error("Failed to create production: #{@production.errors.full_messages}") | ||
end | ||
end | ||
|
||
def edit | ||
@production = Production.find(params[:id]) | ||
@tailors = Tailor.all # Ensure @tailors is set for the edit view | ||
end | ||
|
||
def update | ||
if @production.update(production_params) | ||
redirect_to @production, notice: 'Production was successfully updated.' | ||
@production = Production.find(params[:id]) | ||
if @production.update!(production_params) | ||
redirect_to @production, notice: t('.production_updated') | ||
else | ||
@tailors = Tailor.all | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
begin | ||
ProductionProduct.where(production_id: @production.id).destroy_all | ||
@production.destroy | ||
respond_to do |format| | ||
format.html { redirect_to productions_path, notice: 'Produção deletado.' } | ||
format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@production)) } | ||
end | ||
rescue ActiveRecord::InvalidForeignKey | ||
# Handle invalid foreign key by raising a custom error message | ||
raise "Can't delete production because it has associated records" | ||
if @production.destroy | ||
redirect_to productions_url, notice: t('.production_destroyed') | ||
else | ||
redirect_to productions_url, alert: t('.destruction_failed') | ||
end | ||
end | ||
|
||
private | ||
def missing_pieces | ||
@productions_with_missing_pieces = Production.includes(:tailor, production_products: :product) | ||
.where(id: ProductionProduct.select(:production_id) | ||
.where('quantity > COALESCE(pieces_delivered, 0)')) | ||
.distinct | ||
|
||
def set_production | ||
@production = Production.find(params[:id]) | ||
if params[:tailor_id].present? | ||
@productions_with_missing_pieces = @productions_with_missing_pieces.where(tailor_id: params[:tailor_id]) | ||
end | ||
end | ||
|
||
def production_params | ||
params.require(:production).permit(:cut_date, :deliver_date, :quantity, :tailor_id, :consider, production_products_attributes: [:id, :product_id, :quantity, :_destroy]) | ||
end | ||
private | ||
|
||
def set_tailor_options | ||
@tailors = Tailor.all | ||
end | ||
end | ||
def set_production | ||
@production = Production.find(params[:id]) | ||
end | ||
|
||
def set_tailors | ||
@tailors = Tailor.all | ||
end | ||
|
||
def production_params | ||
params.require(:production).permit( | ||
:cut_date, :tailor_id, :service_order_number, :expected_delivery_date, | ||
:confirmed, :paid, :consider, :observation, | ||
production_products_attributes: [:id, :product_id, :quantity, :pieces_delivered, :delivery_date, | ||
:_destroy] | ||
) | ||
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.