jobshop 0.0.157 → 0.0.163
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/app/email_handlers/jobshop/rfq_handler.rb +43 -0
- data/app/models/jobshop/collection.rb +6 -11
- data/app/models/jobshop/company.rb +25 -12
- data/app/models/jobshop/company/type.rb +17 -0
- data/app/models/jobshop/company_person.rb +15 -0
- data/app/models/jobshop/inspection.rb +2 -0
- data/app/models/jobshop/inspection/boolean_criterion.rb +13 -10
- data/app/models/jobshop/inspection/criterion.rb +8 -11
- data/app/models/jobshop/inspection/deviation_criterion.rb +13 -10
- data/app/models/jobshop/inspection/limit_criterion.rb +9 -7
- data/app/models/jobshop/inspection/report.rb +11 -15
- data/app/models/jobshop/inspection/result.rb +9 -5
- data/app/models/jobshop/inspection/tuple.rb +7 -3
- data/app/models/jobshop/mailman.rb +11 -0
- data/app/models/jobshop/order.rb +12 -14
- data/app/models/jobshop/order_line.rb +10 -5
- data/app/models/jobshop/organization.rb +35 -8
- data/app/models/jobshop/person.rb +30 -0
- data/app/models/jobshop/place.rb +3 -1
- data/app/models/jobshop/product.rb +10 -12
- data/app/models/jobshop/rfq.rb +22 -0
- data/app/models/jobshop/rfq_line.rb +12 -0
- data/app/models/jobshop/role.rb +6 -13
- data/app/models/jobshop/role_assignment.rb +4 -2
- data/app/models/jobshop/routing_process.rb +8 -11
- data/app/models/jobshop/routing_step.rb +4 -2
- data/app/models/jobshop/thing.rb +6 -11
- data/app/models/jobshop/user.rb +10 -17
- data/db/migrate/20170311194758_initialize_jobshop.rb +3 -1
- data/db/migrate/20171216021339_create_organizations.rb +4 -2
- data/db/migrate/20171216021554_create_people.rb +48 -0
- data/db/migrate/20171216021853_create_companies.rb +47 -8
- data/db/migrate/20171216022020_create_places.rb +3 -3
- data/db/migrate/20171216022135_create_products.rb +5 -3
- data/db/migrate/20171216022605_create_orders.rb +9 -7
- data/db/migrate/20171216023018_create_roles.rb +18 -16
- data/db/migrate/20171216023022_create_sessions.rb +9 -7
- data/db/migrate/20171216035357_create_things.rb +7 -5
- data/db/migrate/20171219022118_create_routing_processes.rb +10 -8
- data/db/migrate/{20180107203241_create_inspection.rb → 20180107203241_create_inspections.rb} +21 -16
- data/db/migrate/20181117023949_create_rfqs.rb +40 -0
- data/db/migrate/20181118014603_create_mailmen.rb +29 -0
- data/exe/jobshop +1 -1
- data/lib/generators/jobshop/app/app_generator.rb +12 -23
- data/lib/generators/jobshop/app/templates/Procfile.tt +1 -0
- data/lib/generators/jobshop/config/templates/config/initializers/jobshop.rb.tt +5 -0
- data/lib/generators/jobshop/dummy/dummy_generator.rb +4 -5
- data/lib/jobshop.rb +8 -4
- data/lib/jobshop/cli.rb +58 -47
- data/lib/jobshop/configuration.rb +17 -5
- data/lib/jobshop/dummy_app.rb +27 -15
- data/lib/jobshop/engine.rb +28 -15
- data/lib/jobshop/helpers/migration.rb +6 -2
- data/lib/jobshop/postmaster.rb +89 -0
- data/lib/jobshop/version.rb +2 -2
- data/lib/tasks/jobshop_tasks.rake +11 -0
- metadata +83 -16
- data/db/migrate/20171216021717_create_users.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72d9c251b2bcc65848a33510d25bdee8d14ca55b
|
4
|
+
data.tar.gz: b0e53706a8d59d0824affb1a416fb519786a520b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a442988c2fcc8dc15e7bca171754a7d1ef608cf55a1021354b0be3c189ec1eadac472ffbb33c69371a8a9caceff0513dde3d7624aadf69f07fa5c6cbfe15c53
|
7
|
+
data.tar.gz: 1aff3bac63832e1f71be8cb40ae5949b8f45966d9752a78f0c2e7a89e8f1e3b01c70b5c58c02ab2b4d034ee419a49fe72f7f562da98bd863046d728e0886fc2b
|
data/README.md
CHANGED
@@ -6,7 +6,6 @@ Real-time production tracking and process evaluation, under your own roof.
|
|
6
6
|
[![Code Climate](https://codeclimate.com/github/jobshop/jobshop/badges/gpa.svg)](https://codeclimate.com/github/jobshop/jobshop)
|
7
7
|
[![Build Status](https://semaphoreci.com/api/v1/frankjmattia/jobshop/branches/master/shields_badge.svg)](https://semaphoreci.com/frankjmattia/jobshop)
|
8
8
|
[![Test Coverage](https://codeclimate.com/github/jobshop/jobshop/badges/coverage.svg)](https://codeclimate.com/github/jobshop/jobshop/coverage)
|
9
|
-
[![Dependency Status](https://gemnasium.com/badges/github.com/jobshop/jobshop.svg)](https://gemnasium.com/github.com/jobshop/jobshop)
|
10
9
|
|
11
10
|
## TL;DR
|
12
11
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
3
|
+
module Jobshop
|
4
|
+
class RFQHandler
|
5
|
+
def initialize(message, organization:)
|
6
|
+
@from = message.from.first
|
7
|
+
@subject = message.subject
|
8
|
+
@content = message.text_part.decoded
|
9
|
+
@organization = organization
|
10
|
+
end
|
11
|
+
|
12
|
+
def process
|
13
|
+
new_rfq = @organization.rfqs.create({
|
14
|
+
from: @from,
|
15
|
+
subject: @subject,
|
16
|
+
content: @content
|
17
|
+
})
|
18
|
+
|
19
|
+
if new_rfq.persisted?
|
20
|
+
# TODO: Send response email to customer
|
21
|
+
# TODO: Send rfq to quoting queue.
|
22
|
+
return new_rfq
|
23
|
+
else
|
24
|
+
# TODO: There was some kind of failure which should be logged.
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Whether or not to copy the original to a new location after processing.
|
30
|
+
def copy_after_processing?
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
# Whether or not to delete the original item after processing.
|
35
|
+
def delete_after_processing?
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
def processed_copy_prefix
|
40
|
+
"rfqs/processed"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,20 +1,15 @@
|
|
1
|
+
# frozen_string_literals
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Collection < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
5
|
+
self.primary_keys = %i[ organization_id collection_id ]
|
4
6
|
|
5
|
-
|
6
|
-
self.class.connection.clear_query_cache
|
7
|
-
fresh_collection = self.class.unscoped {
|
8
|
-
self.class.find_by!(organization: organization, name: name)
|
9
|
-
}
|
10
|
-
@attributes = fresh_collection.instance_variable_get(:@attributes)
|
11
|
-
@new_record = false
|
12
|
-
self
|
13
|
-
end
|
7
|
+
after_initialize { self.collection_id ||= SecureRandom.uuid if new_record? }
|
14
8
|
|
15
9
|
belongs_to :organization, inverse_of: :collections
|
10
|
+
|
16
11
|
has_many :things, inverse_of: :collection,
|
17
|
-
foreign_key: [
|
12
|
+
foreign_key: %i[ organization_id collection_id ]
|
18
13
|
|
19
14
|
validates :name, presence: true,
|
20
15
|
uniqueness: { scope: :organization_id, case_sensitive: false }
|
@@ -1,21 +1,34 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Company < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
5
|
+
self.primary_keys = %i[ organization_id company_id ]
|
6
|
+
|
7
|
+
# Because we have a column named +type+, Rails wants to activate STI
|
8
|
+
# Disable it manually
|
9
|
+
self.inheritance_column = nil
|
4
10
|
|
5
|
-
|
6
|
-
self.class.connection.clear_query_cache
|
7
|
-
@attributes = self.class.unscoped {
|
8
|
-
self.class.find_by!(organization: organization, name: name)
|
9
|
-
}.instance_variable_get(:@attributes)
|
10
|
-
@new_record = false
|
11
|
-
self
|
12
|
-
end
|
11
|
+
after_initialize { self.company_id ||= SecureRandom.uuid if new_record? }
|
13
12
|
|
14
13
|
belongs_to :organization, inverse_of: :companies
|
15
|
-
|
16
|
-
|
14
|
+
|
15
|
+
has_many :company_people, inverse_of: :company,
|
16
|
+
foreign_key: %i[ organization_id company_id ]
|
17
|
+
|
18
|
+
belongs_to :created_by, class_name: "Jobshop::Person",
|
19
|
+
foreign_key: %i[ organization_id created_by_id ]
|
20
|
+
|
17
21
|
has_many :orders, inverse_of: :company,
|
18
|
-
foreign_key: [
|
22
|
+
foreign_key: %i[ organization_id company_id ]
|
23
|
+
|
24
|
+
has_many :people, through: :company_people,
|
25
|
+
foreign_key: %i[ organization_id person_id ]
|
26
|
+
|
27
|
+
has_many :rfqs, inverse_of: :company,
|
28
|
+
foreign_key: %i[ organization_id company_id ]
|
29
|
+
|
30
|
+
belongs_to :type, class_name: "Jobshop::Company::Type",
|
31
|
+
foreign_key: %i[ organization_id type_id ], inverse_of: :companies
|
19
32
|
|
20
33
|
validates :name, presence: true
|
21
34
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
3
|
+
module Jobshop
|
4
|
+
class Company::Type < ApplicationRecord
|
5
|
+
self.primary_keys = %i[ organization_id type_id ]
|
6
|
+
|
7
|
+
after_initialize { self.type_id ||= SecureRandom.uuid if new_record? }
|
8
|
+
|
9
|
+
belongs_to :organization, inverse_of: :company_types
|
10
|
+
|
11
|
+
has_many :companies, inverse_of: :type,
|
12
|
+
foreign_key: %i[ organization_id type_id ]
|
13
|
+
|
14
|
+
validates :name,
|
15
|
+
uniqueness: { scope: :organization_id, case_sensitive: false }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
3
|
+
module Jobshop
|
4
|
+
class CompanyPerson < ApplicationRecord
|
5
|
+
self.primary_keys = %i[ organization_id company_id person_id ]
|
6
|
+
|
7
|
+
belongs_to :organization
|
8
|
+
|
9
|
+
belongs_to :company, inverse_of: :company_people,
|
10
|
+
foreign_key: %i[ organization_id company_id ]
|
11
|
+
|
12
|
+
belongs_to :person, inverse_of: :company_person,
|
13
|
+
foreign_key: %i[ organization_id person_id ]
|
14
|
+
end
|
15
|
+
end
|
@@ -1,21 +1,24 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Inspection::BooleanCriterion < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
5
|
+
self.primary_keys = %i[ organization_id report_id criterion_id criterion_type ]
|
4
6
|
|
5
|
-
after_initialize
|
6
|
-
|
7
|
-
end
|
7
|
+
after_initialize { self.criterion_id ||= SecureRandom.uuid if new_record? }
|
8
|
+
before_save(on: :create) { criterion.save unless criterion.persisted? }
|
8
9
|
|
9
10
|
belongs_to :organization
|
11
|
+
|
10
12
|
has_one :criterion, as: :criterion, autosave: true, dependent: :destroy,
|
11
|
-
foreign_key: [
|
13
|
+
foreign_key: %i[ organization_id report_id criterion_id criterion_type ],
|
14
|
+
inverse_of: :criterion
|
15
|
+
|
12
16
|
belongs_to :report, class_name: "Jobshop::Inspection::Report",
|
13
|
-
foreign_key: [
|
17
|
+
foreign_key: %i[ organization_id report_id ]
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end; alias_method :criterion, :criterion_with_build
|
19
|
+
def criterion
|
20
|
+
super || build_criterion
|
21
|
+
end
|
19
22
|
|
20
23
|
delegate :name, :name=, :position, :position=, to: :criterion
|
21
24
|
|
@@ -1,21 +1,18 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Inspection::Criterion < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
5
|
+
self.primary_keys = %i[ organization_id report_id criterion_id criterion_type ]
|
4
6
|
|
5
|
-
|
6
|
-
self.class.connection.clear_query_cache
|
7
|
-
@attributes = self.class.unscoped {
|
8
|
-
self.class.find_by!(organization: organization, criterion_id: criterion_id)
|
9
|
-
}.instance_variable_get(:@attributes)
|
10
|
-
@new_record = false
|
11
|
-
self
|
12
|
-
end
|
7
|
+
after_initialize { self.criterion_id ||= SecureRandom.uuid if new_record? }
|
13
8
|
|
14
9
|
belongs_to :organization
|
10
|
+
|
15
11
|
belongs_to :criterion, polymorphic: true, optional: true, dependent: :destroy,
|
16
|
-
foreign_key: [
|
12
|
+
foreign_key: %i[ organization_id report_id criterion_id criterion_type ]
|
13
|
+
|
17
14
|
belongs_to :report, class_name: "Jobshop::Inspection::Report",
|
18
|
-
foreign_key: [
|
15
|
+
foreign_key: %i[ organization_id report_id ], inverse_of: :criteria
|
19
16
|
|
20
17
|
delegate :ascii, :pass?, :random, :unit, to: :criterion
|
21
18
|
end
|
@@ -1,21 +1,24 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Inspection::DeviationCriterion < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
5
|
+
self.primary_keys = %i[ organization_id report_id criterion_id criterion_type ]
|
4
6
|
|
5
|
-
after_initialize
|
6
|
-
|
7
|
-
end
|
7
|
+
after_initialize { self.criterion_id ||= SecureRandom.uuid if new_record? }
|
8
|
+
before_save(on: :create) { criterion.save unless criterion.persisted? }
|
8
9
|
|
9
10
|
belongs_to :organization
|
11
|
+
|
10
12
|
belongs_to :report, class_name: "Jobshop::Inspection::Report",
|
11
|
-
foreign_key: [
|
13
|
+
foreign_key: %i[ organization_id report_id ]
|
14
|
+
|
12
15
|
has_one :criterion, as: :criterion, autosave: true, dependent: :destroy,
|
13
|
-
foreign_key: [
|
16
|
+
foreign_key: %i[ organization_id report_id criterion_id criterion_type ],
|
17
|
+
inverse_of: :criterion
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end; alias_method :criterion, :criterion_with_build
|
19
|
+
def criterion
|
20
|
+
super || build_criterion
|
21
|
+
end
|
19
22
|
|
20
23
|
delegate :name, :name=, :position, :position=, to: :criterion
|
21
24
|
|
@@ -1,16 +1,18 @@
|
|
1
1
|
module Jobshop
|
2
2
|
class Inspection::LimitCriterion < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
3
|
+
self.primary_keys = %i[ organization_id report_id criterion_id criterion_type ]
|
4
4
|
|
5
|
-
after_initialize
|
6
|
-
|
7
|
-
end
|
5
|
+
after_initialize { self.criterion_id ||= SecureRandom.uuid if new_record? }
|
6
|
+
before_save(on: :create) { criterion.save unless criterion.persisted? }
|
8
7
|
|
9
8
|
belongs_to :organization
|
10
|
-
|
11
|
-
|
9
|
+
|
10
|
+
has_one :criterion, as: :criterion, autosave: true, dependent: :destroy,
|
11
|
+
foreign_key: %i[ organization_id report_id criterion_id criterion_type ],
|
12
|
+
inverse_of: :criterion
|
13
|
+
|
12
14
|
belongs_to :report, class_name: "Jobshop::Inspection::Report",
|
13
|
-
foreign_key: [
|
15
|
+
foreign_key: %i[ organization_id report_id ]
|
14
16
|
|
15
17
|
def criterion
|
16
18
|
super || build_criterion
|
@@ -1,25 +1,21 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Inspection::Report < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
5
|
+
self.primary_keys = %i[ organization_id report_id ]
|
4
6
|
|
5
|
-
after_initialize
|
6
|
-
self.report_id ||= SecureRandom.uuid if new_record?
|
7
|
-
end
|
7
|
+
after_initialize { self.report_id ||= SecureRandom.uuid if new_record? }
|
8
8
|
|
9
|
-
|
10
|
-
self.class.connection.clear_query_cache
|
11
|
-
@attributes = self.class.unscoped {
|
12
|
-
self.class.find_by!(organization: organization, report_id: report_id)
|
13
|
-
}.instance_variable_get(:@attributes)
|
14
|
-
@new_record = false
|
15
|
-
self
|
16
|
-
end
|
9
|
+
belongs_to :organization, inverse_of: :inspection_reports
|
17
10
|
|
18
|
-
belongs_to :organization
|
19
11
|
has_many :criteria, -> { includes(:criterion).order(:position) },
|
20
|
-
foreign_key: [
|
12
|
+
foreign_key: %i[ organization_id report_id ], inverse_of: :report
|
13
|
+
|
14
|
+
has_many :limit_criteria, inverse_of: :report,
|
15
|
+
foreign_key: %i[ organization_id report_id ]
|
16
|
+
|
21
17
|
has_many :tuples, -> { order(:position) }, inverse_of: :report,
|
22
|
-
foreign_key: [
|
18
|
+
foreign_key: %i[ organization_id report_id ]
|
23
19
|
|
24
20
|
def ascii
|
25
21
|
require "terminal-table"
|
@@ -1,22 +1,26 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Inspection::Result < ApplicationRecord
|
3
5
|
FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"]
|
4
6
|
|
5
|
-
self.primary_keys = [
|
7
|
+
self.primary_keys = %i[ organization_id report_id criterion_id criterion_type position ]
|
6
8
|
|
7
9
|
belongs_to :organization
|
10
|
+
|
8
11
|
belongs_to :report, class_name: "Jobshop::Inspection::Report",
|
9
|
-
foreign_key: [
|
12
|
+
foreign_key: %i[ organization_id report_id ]
|
13
|
+
|
10
14
|
belongs_to :criterion, polymorphic: true, optional: true, dependent: :destroy,
|
11
|
-
foreign_key: [
|
15
|
+
foreign_key: %i[ organization_id report_id criterion_id criterion_type ]
|
16
|
+
|
12
17
|
belongs_to :tuple, class_name: "Jobshop::Inspection::Tuple",
|
13
|
-
foreign_key: [
|
18
|
+
foreign_key: %i[ organization_id report_id position ]
|
14
19
|
|
15
20
|
def value
|
16
21
|
if self[:unit] == "boolean"
|
17
22
|
!!self[:value]
|
18
23
|
else
|
19
|
-
# binding.pry
|
20
24
|
self[:value] && Unitwise(self[:value].truncate(4), self[:unit])
|
21
25
|
end
|
22
26
|
end
|
@@ -1,12 +1,16 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Inspection::Tuple < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
5
|
+
self.primary_keys = %i[ organization_id report_id position ]
|
4
6
|
|
5
7
|
belongs_to :organization
|
8
|
+
|
6
9
|
belongs_to :report, class_name: "Jobshop::Inspection::Report", inverse_of: :tuples,
|
7
|
-
foreign_key: [
|
10
|
+
foreign_key: %i[ organization_id report_id ]
|
11
|
+
|
8
12
|
has_many :results, class_name: "Jobshop::Inspection::Result", inverse_of: :tuple,
|
9
|
-
foreign_key: [
|
13
|
+
foreign_key: %i[ organization_id report_id position ]
|
10
14
|
|
11
15
|
has_many :criteria, through: :results
|
12
16
|
end
|
data/app/models/jobshop/order.rb
CHANGED
@@ -1,23 +1,21 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
class Order < ApplicationRecord
|
3
|
-
self.primary_keys = [
|
4
|
-
|
5
|
-
|
6
|
-
self.class.connection.clear_query_cache
|
7
|
-
@attributes = self.class.unscoped {
|
8
|
-
self.class.find_by!(organization: organization, number: number)
|
9
|
-
}.instance_variable_get(:@attributes)
|
10
|
-
@new_record = false
|
11
|
-
self
|
12
|
-
end
|
5
|
+
self.primary_keys = %i[ organization_id order_id ]
|
6
|
+
|
7
|
+
after_initialize { self.order_id ||= SecureRandom.uuid if new_record? }
|
13
8
|
|
14
9
|
belongs_to :organization, inverse_of: :orders
|
15
|
-
|
16
|
-
|
10
|
+
|
11
|
+
belongs_to :created_by, class_name: "Jobshop::Person",
|
12
|
+
foreign_key: %i[ organization_id created_by_id ]
|
13
|
+
|
17
14
|
belongs_to :company, inverse_of: :orders,
|
18
|
-
foreign_key: [
|
15
|
+
foreign_key: %i[ organization_id company_id ]
|
16
|
+
|
19
17
|
has_many :order_lines, inverse_of: :order,
|
20
|
-
foreign_key: [
|
18
|
+
foreign_key: %i[ organization_id order_id ]
|
21
19
|
|
22
20
|
around_save :notify_on_save
|
23
21
|
|