Skip to content

Commit

Permalink
Merge branch 'calculators-constructor' of github.com:ita-social-proje…
Browse files Browse the repository at this point in the history
…cts/ZeroWaste into 963-view-of-the-constructors-calculator
  • Loading branch information
olexandervanzuriak committed Nov 26, 2024
2 parents 8744fe7 + 9130d91 commit 8a0a37f
Show file tree
Hide file tree
Showing 31 changed files with 34 additions and 868 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ jobs:
bundler-cache: true

- name: Install system dependencies
run: sudo apt-get install -y libvips42 libvips-dev imagemagick
run: |
sudo apt-get update
sudo apt-get install -y libvips42 libvips-dev imagemagick
- uses: actions/setup-node@v1
with:
Expand Down
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.

4 changes: 2 additions & 2 deletions app/models/calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Calculator < ApplicationRecord
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 8a0a37f

Please sign in to comment.