Skip to content

Commit

Permalink
Fixed CI by deleting the redundant code from the old constructor of c…
Browse files Browse the repository at this point in the history
…alculators. Also fixed Diapers calculator by returning related to it methods
  • Loading branch information
SleekMutt committed Nov 20, 2024
1 parent 707e3fc commit ce1b77e
Show file tree
Hide file tree
Showing 29 changed files with 35 additions and 857 deletions.
9 changes: 7 additions & 2 deletions app/controllers/account/calculators_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

class Account::CalculatorsController < Account::BaseController
before_action :resource, only: [:edit, :update, :destroy]
load_and_authorize_resource

def index
Expand All @@ -23,6 +22,8 @@ def new
end

def edit
@calculator = resource

collect_fields_for_form
end

Expand All @@ -37,6 +38,8 @@ def create
end

def update
@calculator = resource

if updater
redirect_to edit_account_calculator_path(slug: @calculator), notice: t("notifications.calculator_updated")
else
Expand All @@ -47,6 +50,8 @@ def update
end

def destroy
@calculator = resource

@calculator.destroy

redirect_to account_calculators_path, notice: t("notifications.calculator_deleted"), status: :see_other
Expand All @@ -59,7 +64,7 @@ def collection
end

def resource
Calculator.find(params[:slug])
collection.friendly.find(params[:slug])
end

def collect_fields_for_form
Expand Down
9 changes: 0 additions & 9 deletions app/controllers/api/v2/calculators_controller.rb

This file was deleted.

23 changes: 0 additions & 23 deletions app/lib/calculation_resolver.rb

This file was deleted.

62 changes: 0 additions & 62 deletions app/lib/calculator_resolver.rb

This file was deleted.

27 changes: 0 additions & 27 deletions app/models/calculation.rb

This file was deleted.

6 changes: 4 additions & 2 deletions app/models/calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ class Calculator < ApplicationRecord

translates :name

has_paper_trail

has_many :fields, dependent: :destroy
has_many :formulas, dependent: :destroy

accepts_nested_attributes_for :fields, reject_if: :all_blank, allow_destroy: true
accepts_nested_attributes_for :formulas, reject_if: :all_blank, allow_destroy: true
accepts_nested_attributes_for :fields, allow_destroy: true
accepts_nested_attributes_for :formulas, allow_destroy: true

scope :ordered_by_name, -> { order(:en_name) }

Expand Down
10 changes: 7 additions & 3 deletions app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@
#
class Category < ApplicationRecord
include Translatable
translates :name

belongs_to :field
PRIORITY_RANGE = 0..10

translates :name
belongs_to :field, optional: true
has_many :diapers_periods, dependent: :destroy
has_many :category_categoryables, dependent: :restrict_with_exception

enum :preferable, { not_preferable: false, preferable: true }

validates :uk_name, :en_name, presence: true
validates :uk_name, :en_name,
length: { minimum: 3, maximum: 30 },
format: { with: /\A[\p{L}0-9\s'-]+\z/i },
uniqueness: { case_sensitive: false },
allow_blank: true
validates :priority, numericality: { greater_than_or_equal_to: 0 }

Expand Down
28 changes: 0 additions & 28 deletions app/models/named_value.rb

This file was deleted.

28 changes: 0 additions & 28 deletions app/models/range_field.rb

This file was deleted.

27 changes: 0 additions & 27 deletions app/models/select.rb

This file was deleted.

28 changes: 0 additions & 28 deletions app/models/value.rb

This file was deleted.

53 changes: 0 additions & 53 deletions app/serializers/field_serializer.rb

This file was deleted.

5 changes: 5 additions & 0 deletions db/migrate/20241119192344_change_field_in_category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeFieldInCategory < ActiveRecord::Migration[7.2]
def change
change_column_null :categories, :field_id, true
end
end
Loading

0 comments on commit ce1b77e

Please sign in to comment.