auctify 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +229 -0
- data/Rakefile +34 -0
- data/app/assets/config/auctify_manifest.js +1 -0
- data/app/assets/javascripts/folio/console/main_app.coffee +1 -0
- data/app/assets/stylesheets/auctify/application.css +15 -0
- data/app/assets/stylesheets/auctify/bidder_registrations.css +4 -0
- data/app/assets/stylesheets/auctify/bids.css +4 -0
- data/app/assets/stylesheets/auctify/sales.css +4 -0
- data/app/assets/stylesheets/auctify/sales_packs.css +4 -0
- data/app/assets/stylesheets/folio/console/_main_app.sass +1 -0
- data/app/assets/stylesheets/scaffold.css +80 -0
- data/app/cells/folio/console/atoms/previews/main_app.coffee +1 -0
- data/app/concerns/auctify/behavior/base.rb +20 -0
- data/app/concerns/auctify/behavior/buyer.rb +16 -0
- data/app/concerns/auctify/behavior/item.rb +27 -0
- data/app/concerns/auctify/behavior/seller.rb +36 -0
- data/app/concerns/auctify/sale/auction_callbacks.rb +44 -0
- data/app/controllers/auctify/api/v1/auctions_controller.rb +61 -0
- data/app/controllers/auctify/api/v1/base_controller.rb +22 -0
- data/app/controllers/auctify/api/v1/console/bids_controller.rb +37 -0
- data/app/controllers/auctify/application_controller.rb +8 -0
- data/app/controllers/auctify/bidder_registrations_controller.rb +65 -0
- data/app/controllers/auctify/bids_controller.rb +64 -0
- data/app/controllers/auctify/sales_controller.rb +75 -0
- data/app/controllers/auctify/sales_packs_controller.rb +75 -0
- data/app/helpers/auctify/application_helper.rb +10 -0
- data/app/helpers/auctify/bidder_registrations_helper.rb +6 -0
- data/app/helpers/auctify/bids_helper.rb +6 -0
- data/app/helpers/auctify/sales_helper.rb +15 -0
- data/app/helpers/auctify/sales_packs_helper.rb +6 -0
- data/app/jobs/auctify/application_job.rb +6 -0
- data/app/jobs/auctify/bidding_closer_job.rb +23 -0
- data/app/jobs/auctify/bidding_is_close_to_end_notifier_job.rb +29 -0
- data/app/mailers/auctify/application_mailer.rb +8 -0
- data/app/models/auctify/application_record.rb +14 -0
- data/app/models/auctify/behaviors.rb +27 -0
- data/app/models/auctify/bid.rb +72 -0
- data/app/models/auctify/bidder_registration.rb +84 -0
- data/app/models/auctify/sale/auction.rb +404 -0
- data/app/models/auctify/sale/base.rb +210 -0
- data/app/models/auctify/sale/retail.rb +97 -0
- data/app/models/auctify/sales_pack.rb +101 -0
- data/app/serializers/auctify/sale/auction_serializer.rb +46 -0
- data/app/services/auctify/bids_appender.rb +241 -0
- data/app/services/auctify/service_base.rb +78 -0
- data/app/types/auctify/minimal_bids_ladder_type.rb +77 -0
- data/app/views/auctify/api/v1/console/bids/index.html.erb +1 -0
- data/app/views/auctify/api/v1/console/bids/show.html.erb +1 -0
- data/app/views/auctify/bidder_registrations/_form.html.erb +27 -0
- data/app/views/auctify/bidder_registrations/edit.html.erb +6 -0
- data/app/views/auctify/bidder_registrations/index.html.erb +33 -0
- data/app/views/auctify/bidder_registrations/new.html.erb +5 -0
- data/app/views/auctify/bidder_registrations/show.html.erb +24 -0
- data/app/views/auctify/bids/_form.html.erb +32 -0
- data/app/views/auctify/bids/edit.html.erb +6 -0
- data/app/views/auctify/bids/index.html.erb +31 -0
- data/app/views/auctify/bids/new.html.erb +5 -0
- data/app/views/auctify/bids/show.html.erb +19 -0
- data/app/views/auctify/sales/_form.html.erb +32 -0
- data/app/views/auctify/sales/edit.html.erb +6 -0
- data/app/views/auctify/sales/index.html.erb +36 -0
- data/app/views/auctify/sales/new.html.erb +5 -0
- data/app/views/auctify/sales/show.html.erb +19 -0
- data/app/views/auctify/sales_packs/_form.html.erb +57 -0
- data/app/views/auctify/sales_packs/edit.html.erb +6 -0
- data/app/views/auctify/sales_packs/index.html.erb +40 -0
- data/app/views/auctify/sales_packs/new.html.erb +5 -0
- data/app/views/auctify/sales_packs/show.html.erb +44 -0
- data/app/views/layouts/auctify/application.html.erb +15 -0
- data/config/locales/auctify.cs.yml +121 -0
- data/config/locales/default.cs.yml +220 -0
- data/config/locales/default.en.yml +215 -0
- data/config/routes.rb +23 -0
- data/db/migrate/20210212163000_create_auctify_sales.rb +16 -0
- data/db/migrate/20210216151350_add_type_to_auctify_sales.rb +7 -0
- data/db/migrate/20210217101246_add_state_to_auctify_sales.rb +7 -0
- data/db/migrate/20210217110819_add_prices_to_auctify_sales.rb +9 -0
- data/db/migrate/20210222103031_add_published_at_to_auctify_sale.rb +7 -0
- data/db/migrate/20210223090240_create_auctify_bidder_registrations.rb +15 -0
- data/db/migrate/20210223152139_create_auctify_bids.rb +13 -0
- data/db/migrate/20210225103227_add_bid_steps_ladder_to_auctify_sales.rb +7 -0
- data/db/migrate/20210412114319_add_reserve_price_to_auctify_sales.rb +7 -0
- data/db/migrate/20210416140603_create_auctify_sales_packs.rb +17 -0
- data/db/migrate/20210416141111_add_pack_reference_to_auctify_sales.rb +7 -0
- data/db/migrate/20210419075003_add_ends_at_to_auctify_sales.rb +7 -0
- data/db/migrate/20210419082800_add_position_to_auctify_sales.rb +8 -0
- data/db/migrate/20210419083321_add_indexes.rb +12 -0
- data/db/migrate/20210421093652_add_number_to_auctify_sales.rb +7 -0
- data/db/migrate/20210423071326_removing_polymorphic_assoc_sale_to_item.rb +7 -0
- data/db/migrate/20210423071534_add_currently_ends_at_to_auctify_sales.rb +7 -0
- data/db/migrate/20210427121353_change_column_published_on_auctify_sale.rb +15 -0
- data/db/migrate/20210427122315_add_featured_to_auctify_sales.rb +7 -0
- data/db/migrate/20210428045651_add_sales_bool_indices.rb +9 -0
- data/db/migrate/20210428064615_allow_seller_to_be_nil.rb +13 -0
- data/db/migrate/20210429051508_add_sales_pack_start_and_end.rb +15 -0
- data/db/migrate/20210430080419_add_sales_slug.rb +11 -0
- data/db/migrate/20210503095704_add_cancelled_to_auctify_bids.rb +7 -0
- data/db/migrate/20210504072041_add_commission_and_contract_to_auctify_sales.rb +8 -0
- data/db/migrate/20210506064100_add_winner_to_auctify_sales.rb +7 -0
- data/db/migrate/20210506072438_add_bids_count_to_auctify_sales.rb +7 -0
- data/db/migrate/20210507085845_rename_bids_count_to_applied_bids_count.rb +7 -0
- data/db/migrate/20210510063146_add_dont_confirm_bids_to_registrations.rb +7 -0
- data/db/migrate/20210511081556_add_index_on_cancelled_on.rb +7 -0
- data/db/migrate/20210512162942_add_sold_at_to_auctify_sales.rb +7 -0
- data/db/migrate/20210607113440_add_commission_in_percent_to_sales_packs.rb +7 -0
- data/db/migrate/20210617062509_add_index_to_auctify_sales_currently_ends_at.rb +7 -0
- data/db/migrate/20210625125732_add_current_winner_to_auctify_sales.rb +7 -0
- data/lib/auctify.rb +7 -0
- data/lib/auctify/configuration.rb +43 -0
- data/lib/auctify/engine.rb +25 -0
- data/lib/auctify/version.rb +5 -0
- data/lib/tasks/auctify_tasks.rake +23 -0
- metadata +442 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateAuctifySales < ActiveRecord::Migration[6.0]
|
4
|
+
# rubocop:disable Layout/LineLength
|
5
|
+
# cool! Generated by `bin/rails generate scaffold sale seller:references{polymorphic}, buyer:references{polymorphic}, item:references{polymorphic}`
|
6
|
+
# rubocop:enable Layout/LineLength
|
7
|
+
def change
|
8
|
+
create_table :auctify_sales do |t|
|
9
|
+
t.references :seller, polymorphic: true, null: false
|
10
|
+
t.references :buyer, polymorphic: true, null: true
|
11
|
+
t.references :item, polymorphic: true, null: false
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddPricesToAuctifySales < ActiveRecord::Migration[6.0]
|
4
|
+
def change
|
5
|
+
add_column :auctify_sales, :offered_price, :decimal, precision: 12, scale: 2
|
6
|
+
add_column :auctify_sales, :current_price, :decimal, precision: 12, scale: 2
|
7
|
+
add_column :auctify_sales, :sold_price, :decimal, precision: 12, scale: 2
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateAuctifyBidderRegistrations < ActiveRecord::Migration[6.0]
|
4
|
+
def change
|
5
|
+
create_table :auctify_bidder_registrations do |t|
|
6
|
+
t.references :bidder, polymorphic: true, null: false,
|
7
|
+
index: { name: "index_auctify_bidder_registrations_on_bidder" }
|
8
|
+
t.references :auction, null: false, foreign_key: { to_table: "auctify_sales" }
|
9
|
+
t.string :aasm_state, null: false, default: "pending", index: true
|
10
|
+
t.datetime :handled_at
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateAuctifyBids < ActiveRecord::Migration[6.0]
|
4
|
+
def change
|
5
|
+
create_table :auctify_bids do |t|
|
6
|
+
t.references :registration, null: false, foreign_key: { to_table: "auctify_bidder_registrations" }
|
7
|
+
t.decimal :price, null: false, precision: 12, scale: 2
|
8
|
+
t.decimal :max_price, null: true, precision: 12, scale: 2
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateAuctifySalesPacks < ActiveRecord::Migration[6.0]
|
4
|
+
def change
|
5
|
+
create_table :auctify_sales_packs do |t|
|
6
|
+
t.string :title
|
7
|
+
t.text :description
|
8
|
+
t.integer :position, default: 0
|
9
|
+
t.string :slug
|
10
|
+
t.string :time_frame
|
11
|
+
t.string :place
|
12
|
+
t.boolean :published, default: false
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddIndexes < ActiveRecord::Migration[6.0]
|
4
|
+
def change
|
5
|
+
add_index :auctify_sales, :published_at
|
6
|
+
add_index :auctify_sales, :position
|
7
|
+
|
8
|
+
add_index :auctify_sales_packs, :position
|
9
|
+
add_index :auctify_sales_packs, :slug
|
10
|
+
add_index :auctify_sales_packs, :published
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ChangeColumnPublishedOnAuctifySale < ActiveRecord::Migration[6.0]
|
4
|
+
def up
|
5
|
+
add_column :auctify_sales, :published, :boolean, default: false, index: true
|
6
|
+
execute("UPDATE auctify_sales set published = TRUE where published_at IS NOT NULL;")
|
7
|
+
remove_column :auctify_sales, :published_at
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
add_column :auctify_sales, :published_at, :datetime
|
12
|
+
execute("UPDATE auctify_sales set published_at = NOW() WHERE published = TRUE ;")
|
13
|
+
remove_column :auctify_sales, :published
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AllowSellerToBeNil < ActiveRecord::Migration[6.0]
|
4
|
+
def up
|
5
|
+
change_column :auctify_sales, :seller_id, :integer, null: true
|
6
|
+
change_column :auctify_sales, :seller_type, :string, null: true
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
change_column :auctify_sales, :seller_id, :integer, null: false
|
11
|
+
change_column :auctify_sales, :seller_type, :string, null: false
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddSalesPackStartAndEnd < ActiveRecord::Migration[6.0]
|
4
|
+
def change
|
5
|
+
add_column :auctify_sales_packs, :start_date, :date
|
6
|
+
add_column :auctify_sales_packs, :end_date, :date
|
7
|
+
|
8
|
+
add_column :auctify_sales_packs, :sales_interval, :integer, default: 3
|
9
|
+
|
10
|
+
add_column :auctify_sales_packs, :sales_beginning_hour, :integer, default: 20
|
11
|
+
add_column :auctify_sales_packs, :sales_beginning_minutes, :integer, default: 0
|
12
|
+
|
13
|
+
remove_column :auctify_sales_packs, :time_frame, :string
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddSalesSlug < ActiveRecord::Migration[6.0]
|
4
|
+
def change
|
5
|
+
add_column :auctify_sales, :slug, :string
|
6
|
+
add_index :auctify_sales, :slug, unique: true
|
7
|
+
|
8
|
+
remove_index :auctify_sales_packs, :slug
|
9
|
+
add_index :auctify_sales_packs, :slug, unique: true
|
10
|
+
end
|
11
|
+
end
|
data/lib/auctify.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Auctify
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :autoregister_as_bidders_all_instances_of_classes,
|
6
|
+
:auction_prolonging_limit,
|
7
|
+
:auctioneer_commission_in_percent,
|
8
|
+
:autofinish_auction_after_bidding,
|
9
|
+
:when_to_notify_bidders_before_end_of_bidding,
|
10
|
+
:default_bid_steps_ladder,
|
11
|
+
:restrict_overbidding_yourself_to_max_price_increasing
|
12
|
+
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
# set defaults here
|
16
|
+
@autoregister_as_bidders_all_instances_of_classes = []
|
17
|
+
@auction_prolonging_limit = 2.minutes
|
18
|
+
@auctioneer_commission_in_percent = 1 # %
|
19
|
+
@autofinish_auction_after_bidding = false
|
20
|
+
@when_to_notify_bidders_before_end_of_bidding = nil # no notifying
|
21
|
+
@default_bid_steps_ladder = { 0.. => 1 }
|
22
|
+
@restrict_overbidding_yourself_to_max_price_increasing = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def autoregistering_for?(instance)
|
26
|
+
return false if instance.blank?
|
27
|
+
|
28
|
+
autoregister_as_bidders_all_instances_of_classes.include?(instance.class.name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def self.configuration
|
34
|
+
@configuration ||= Auctify::Configuration.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.configure
|
38
|
+
yield(configuration)
|
39
|
+
|
40
|
+
class_names = configuration.autoregister_as_bidders_all_instances_of_classes.collect { |klass| klass.is_a?(String) ? klass : klass.name }
|
41
|
+
configuration.autoregister_as_bidders_all_instances_of_classes = class_names.sort
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "aasm"
|
4
|
+
require_relative "../../app/models/auctify/behaviors"
|
5
|
+
|
6
|
+
module Auctify
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
# we choose not to use this `isolate_namespace Auctify`
|
9
|
+
# there was problem with routes when using it from main app,
|
10
|
+
# (`url_for(Auctify::SalesPack)` => `NoMethodError: sales_pack_url`)
|
11
|
+
|
12
|
+
initializer :append_migrations do |app|
|
13
|
+
unless app.root.to_s.include? root.to_s
|
14
|
+
config.paths["db/migrate"].expanded.each do |expanded_path|
|
15
|
+
app.config.paths["db/migrate"] << expanded_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# trick borrowed from Devise
|
23
|
+
ActiveSupport.on_load(:active_record) do
|
24
|
+
extend Auctify::Behaviors
|
25
|
+
end
|