Merge branch 'main' of git.systemausfall.org:julius/sharedlists
This commit is contained in:
commit
cbcf042992
18 changed files with 291 additions and 5 deletions
1
Gemfile
1
Gemfile
|
@ -56,3 +56,4 @@ end
|
||||||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
||||||
|
|
||||||
gem "haml-rails", "~> 2.0"
|
gem "haml-rails", "~> 2.0"
|
||||||
|
gem "bcrypt"
|
||||||
|
|
|
@ -62,6 +62,7 @@ GEM
|
||||||
zeitwerk (~> 2.3)
|
zeitwerk (~> 2.3)
|
||||||
addressable (2.8.0)
|
addressable (2.8.0)
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
|
bcrypt (3.1.16)
|
||||||
bindex (0.8.1)
|
bindex (0.8.1)
|
||||||
bootsnap (1.9.3)
|
bootsnap (1.9.3)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
|
@ -225,6 +226,7 @@ PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
bcrypt
|
||||||
bootsnap (>= 1.4.4)
|
bootsnap (>= 1.4.4)
|
||||||
byebug
|
byebug
|
||||||
capybara (>= 3.26)
|
capybara (>= 3.26)
|
||||||
|
|
|
@ -3,8 +3,6 @@ class User < ActiveRecord::Base
|
||||||
has_many :user_accesses, :dependent => :destroy
|
has_many :user_accesses, :dependent => :destroy
|
||||||
has_many :suppliers, :through => :user_accesses
|
has_many :suppliers, :through => :user_accesses
|
||||||
|
|
||||||
attr_accessible :email, :password, :password_confirmation
|
|
||||||
|
|
||||||
attr_accessor :password
|
attr_accessor :password
|
||||||
before_save :encrypt_password
|
before_save :encrypt_password
|
||||||
|
|
||||||
|
|
31
db/migrate/001_create_suppliers.rb
Normal file
31
db/migrate/001_create_suppliers.rb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
class CreateSuppliers < ActiveRecord::Migration
|
||||||
|
SUPPLIER_SAMPLE = 'Sample Supplier'
|
||||||
|
|
||||||
|
def self.up
|
||||||
|
create_table :suppliers do |t|
|
||||||
|
t.column :name, :string, :null => false
|
||||||
|
t.column :address, :string, :null => false
|
||||||
|
t.column :phone, :string, :null => false
|
||||||
|
t.column :phone2, :string
|
||||||
|
t.column :fax, :string
|
||||||
|
t.column :email, :string
|
||||||
|
t.column :url, :string
|
||||||
|
t.column :delivery_days, :string
|
||||||
|
t.column :note, :string
|
||||||
|
|
||||||
|
t.column :created_on, :datetime
|
||||||
|
t.column :updated_on, :datetime
|
||||||
|
end
|
||||||
|
add_index(:suppliers, :name, :unique => true)
|
||||||
|
|
||||||
|
# Create sample supplier...
|
||||||
|
puts "Creating sample supplier '#{SUPPLIER_SAMPLE}'..."
|
||||||
|
Supplier.create(:name => SUPPLIER_SAMPLE, :address => "Organic City", :phone => "0123-555555")
|
||||||
|
raise "Failed!" unless supplier = Supplier.find_by_name(SUPPLIER_SAMPLE)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :suppliers
|
||||||
|
end
|
||||||
|
end
|
33
db/migrate/002_create_articles.rb
Normal file
33
db/migrate/002_create_articles.rb
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
class CreateArticles < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table :articles do |t|
|
||||||
|
t.column :name, :string, :null => false
|
||||||
|
t.column :supplier_id, :integer, :null => false
|
||||||
|
t.column :number, :string
|
||||||
|
t.column :note, :string
|
||||||
|
t.column :manufacturer , :string
|
||||||
|
t.column :origin, :string
|
||||||
|
t.column :unit, :string
|
||||||
|
|
||||||
|
# now the price and order conditions
|
||||||
|
t.column :price, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0.00
|
||||||
|
t.column :tax, :decimal, :precision => 3, :scale => 1,:null => false, :default => 7.0
|
||||||
|
t.column :refund, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0.00
|
||||||
|
t.column :unit_quantity, :decimal, :precision => 4, :scale => 1,:null => false, :default => 1
|
||||||
|
|
||||||
|
# the price-quantity-scale
|
||||||
|
t.column :scale_quantity, :decimal, :precision => 4, :scale => 2
|
||||||
|
t.column :scale_price, :decimal, :precision => 8, :scale => 2
|
||||||
|
|
||||||
|
t.column :created_on, :datetime
|
||||||
|
t.column :updated_on, :datetime
|
||||||
|
|
||||||
|
end
|
||||||
|
add_index(:articles, :name)
|
||||||
|
add_index(:articles, [:number, :supplier_id], :unique => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :articles
|
||||||
|
end
|
||||||
|
end
|
11
db/migrate/003_add_list_to_article.rb
Normal file
11
db/migrate/003_add_list_to_article.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class AddListToArticle < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :articles, :list, :string
|
||||||
|
add_column :suppliers, :lists, :string
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :articles, :list
|
||||||
|
remove_column :suppliers, :lists
|
||||||
|
end
|
||||||
|
end
|
10
db/migrate/004_new_wording.rb
Normal file
10
db/migrate/004_new_wording.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class NewWording < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
rename_column :articles, :refund, :deposit
|
||||||
|
# and make 0.0 deposit the default ...
|
||||||
|
change_column :articles, :deposit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
end
|
||||||
|
end
|
15
db/migrate/20110306172553_add_bnn_sync_to_suppliers.rb
Normal file
15
db/migrate/20110306172553_add_bnn_sync_to_suppliers.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
class AddBnnSyncToSuppliers < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :suppliers, :bnn_sync, :boolean, :default => false
|
||||||
|
add_column :suppliers, :bnn_host, :string
|
||||||
|
add_column :suppliers, :bnn_user, :string
|
||||||
|
add_column :suppliers, :bnn_password, :string
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :suppliers, :bnn_password
|
||||||
|
remove_column :suppliers, :bnn_user
|
||||||
|
remove_column :suppliers, :bnn_host
|
||||||
|
remove_column :suppliers, :bnn_sync
|
||||||
|
end
|
||||||
|
end
|
15
db/migrate/20120312184452_create_users.rb
Normal file
15
db/migrate/20120312184452_create_users.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
class CreateUsers < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table :users do |t|
|
||||||
|
t.string :email
|
||||||
|
t.string :password_hash
|
||||||
|
t.string :password_salt
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :users
|
||||||
|
end
|
||||||
|
end
|
18
db/migrate/20120312190323_create_user_accesses.rb
Normal file
18
db/migrate/20120312190323_create_user_accesses.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
class CreateUserAccesses < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table :user_accesses do |t|
|
||||||
|
t.integer :user_id
|
||||||
|
t.integer :supplier_id
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :user_accesses, :user_id
|
||||||
|
add_index :user_accesses, :supplier_id
|
||||||
|
add_index :user_accesses, [:user_id, :supplier_id]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :user_accesses
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
class RemoveArticleListsFromSuppliers < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
remove_column :suppliers, :lists
|
||||||
|
remove_column :articles, :list
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
add_column :articles, :list, :string
|
||||||
|
add_column :suppliers, :lists, :string
|
||||||
|
end
|
||||||
|
end
|
9
db/migrate/20121017084147_add_admin_flag_to_users.rb
Normal file
9
db/migrate/20121017084147_add_admin_flag_to_users.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class AddAdminFlagToUsers < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :users, :admin, :boolean, :default => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :users, :admin
|
||||||
|
end
|
||||||
|
end
|
9
db/migrate/20130627093146_add_category_to_article.rb
Normal file
9
db/migrate/20130627093146_add_category_to_article.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class AddCategoryToArticle < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :articles, :category, :string
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :articles, :category
|
||||||
|
end
|
||||||
|
end
|
8
db/migrate/20170901183454_add_mail_sync_to_supplier.rb
Normal file
8
db/migrate/20170901183454_add_mail_sync_to_supplier.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class AddMailSyncToSupplier < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :suppliers, :mail_sync, :boolean
|
||||||
|
add_column :suppliers, :mail_from, :string
|
||||||
|
add_column :suppliers, :mail_subject, :string
|
||||||
|
add_column :suppliers, :mail_type, :string
|
||||||
|
end
|
||||||
|
end
|
19
db/migrate/20170901200146_add_salt_to_suppliers.rb
Normal file
19
db/migrate/20170901200146_add_salt_to_suppliers.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
class AddSaltToSuppliers < ActiveRecord::Migration
|
||||||
|
|
||||||
|
class Supplier < ActiveRecord::Base; end
|
||||||
|
|
||||||
|
def up
|
||||||
|
add_column :suppliers, :salt, :string
|
||||||
|
|
||||||
|
Supplier.find_each do |supplier|
|
||||||
|
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
|
||||||
|
supplier.update_attributes! salt: salt
|
||||||
|
end
|
||||||
|
|
||||||
|
change_column_null :suppliers, :salt, false
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :suppliers, :salt
|
||||||
|
end
|
||||||
|
end
|
11
db/migrate/20190811115732_generalize_ftp_sync_beyond_bnn.rb
Normal file
11
db/migrate/20190811115732_generalize_ftp_sync_beyond_bnn.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class GeneralizeFtpSyncBeyondBnn < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :suppliers, :bnn_sync, :ftp_sync
|
||||||
|
rename_column :suppliers, :bnn_host, :ftp_host
|
||||||
|
rename_column :suppliers, :bnn_user, :ftp_user
|
||||||
|
rename_column :suppliers, :bnn_password, :ftp_password
|
||||||
|
|
||||||
|
add_column :suppliers, :ftp_type, :string, default: 'bnn', null: false, after: :ftp_password
|
||||||
|
add_column :suppliers, :ftp_regexp, :string, default: '^([.]/)?PL', after: :ftp_type
|
||||||
|
end
|
||||||
|
end
|
85
db/schema.rb
generated
Normal file
85
db/schema.rb
generated
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
# encoding: UTF-8
|
||||||
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
|
#
|
||||||
|
# Note that this schema.rb definition is the authoritative source for your
|
||||||
|
# database schema. If you need to create the application database on another
|
||||||
|
# system, you should be using db:schema:load, not running all the migrations
|
||||||
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||||
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||||
|
#
|
||||||
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
|
ActiveRecord::Schema.define(:version => 20190811115732) do
|
||||||
|
|
||||||
|
create_table "articles", :force => true do |t|
|
||||||
|
t.string "name", :null => false
|
||||||
|
t.integer "supplier_id", :null => false
|
||||||
|
t.string "number"
|
||||||
|
t.string "note"
|
||||||
|
t.string "manufacturer"
|
||||||
|
t.string "origin"
|
||||||
|
t.string "unit"
|
||||||
|
t.decimal "price", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||||
|
t.decimal "tax", :precision => 3, :scale => 1, :default => 7.0, :null => false
|
||||||
|
t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||||
|
t.decimal "unit_quantity", :precision => 4, :scale => 1, :default => 1.0, :null => false
|
||||||
|
t.decimal "scale_quantity", :precision => 4, :scale => 2
|
||||||
|
t.decimal "scale_price", :precision => 8, :scale => 2
|
||||||
|
t.datetime "created_on"
|
||||||
|
t.datetime "updated_on"
|
||||||
|
t.string "category"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "articles", ["name"], :name => "index_articles_on_name"
|
||||||
|
add_index "articles", ["number", "supplier_id"], :name => "index_articles_on_number_and_supplier_id", :unique => true
|
||||||
|
|
||||||
|
create_table "suppliers", :force => true do |t|
|
||||||
|
t.string "name", :null => false
|
||||||
|
t.string "address", :null => false
|
||||||
|
t.string "phone", :null => false
|
||||||
|
t.string "phone2"
|
||||||
|
t.string "fax"
|
||||||
|
t.string "email"
|
||||||
|
t.string "url"
|
||||||
|
t.string "delivery_days"
|
||||||
|
t.string "note"
|
||||||
|
t.datetime "created_on"
|
||||||
|
t.datetime "updated_on"
|
||||||
|
t.boolean "ftp_sync", :default => false
|
||||||
|
t.string "ftp_host"
|
||||||
|
t.string "ftp_user"
|
||||||
|
t.string "ftp_password"
|
||||||
|
t.string "ftp_type", :default => "bnn", :null => false
|
||||||
|
t.string "ftp_regexp", :default => "^([.]/)?PL"
|
||||||
|
t.boolean "mail_sync"
|
||||||
|
t.string "mail_from"
|
||||||
|
t.string "mail_subject"
|
||||||
|
t.string "mail_type"
|
||||||
|
t.string "salt", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "suppliers", ["name"], :name => "index_suppliers_on_name", :unique => true
|
||||||
|
|
||||||
|
create_table "user_accesses", :force => true do |t|
|
||||||
|
t.integer "user_id"
|
||||||
|
t.integer "supplier_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "user_accesses", ["supplier_id"], :name => "index_user_accesses_on_supplier_id"
|
||||||
|
add_index "user_accesses", ["user_id", "supplier_id"], :name => "index_user_accesses_on_user_id_and_supplier_id"
|
||||||
|
add_index "user_accesses", ["user_id"], :name => "index_user_accesses_on_user_id"
|
||||||
|
|
||||||
|
create_table "users", :force => true do |t|
|
||||||
|
t.string "email"
|
||||||
|
t.string "password_hash"
|
||||||
|
t.string "password_salt"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
t.boolean "admin", :default => false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
# This file should contain all the record creation needed to seed the database with its default values.
|
# This file should contain all the record creation needed to seed the database with its default values.
|
||||||
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
#
|
#
|
||||||
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
||||||
# Character.create(name: 'Luke', movie: movies.first)
|
# Mayor.create(:name => 'Daley', :city => cities.first)
|
||||||
|
|
Loading…
Reference in a new issue