mobilart_models 1.2.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/models/bundle.rb +39 -0
  6. data/app/models/chosen_deck.rb +76 -0
  7. data/app/models/chosen_furniture.rb +114 -0
  8. data/app/models/chosen_item.rb +187 -0
  9. data/app/models/chosen_room.rb +114 -0
  10. data/app/models/commission.rb +58 -0
  11. data/app/models/deck.rb +25 -0
  12. data/app/models/furniture.rb +45 -0
  13. data/app/models/furniture_item.rb +20 -0
  14. data/app/models/item.rb +25 -0
  15. data/app/models/room.rb +22 -0
  16. data/app/models/timetable.rb +171 -0
  17. data/app/models/workflow.rb +173 -0
  18. data/config/initializers/mobilart_models_after_initialize.rb +7 -0
  19. data/config/locales/en.activerecord.yml +36 -0
  20. data/config/locales/en.yml +38 -0
  21. data/config/locales/it.activerecord.yml +157 -0
  22. data/config/locales/it.yml +33 -0
  23. data/config/routes.rb +2 -0
  24. data/db/migrate/20150825174853_create_items.rb +13 -0
  25. data/db/migrate/20150825175219_create_commissions.rb +14 -0
  26. data/db/migrate/20150825175836_create_decks.rb +13 -0
  27. data/db/migrate/20150825175853_create_rooms.rb +13 -0
  28. data/db/migrate/20150825175952_create_furnitures.rb +13 -0
  29. data/db/migrate/20150825180027_create_furniture_items.rb +10 -0
  30. data/db/migrate/20150825180510_create_bundles.rb +14 -0
  31. data/db/migrate/20150827084511_create_chosen_decks.rb +12 -0
  32. data/db/migrate/20150827084626_create_chosen_rooms.rb +12 -0
  33. data/db/migrate/20150827084745_create_chosen_furnitures.rb +12 -0
  34. data/db/migrate/20150827184845_create_chosen_items.rb +12 -0
  35. data/db/migrate/20150828180910_create_workflows.rb +13 -0
  36. data/db/migrate/20150903152839_create_timetables.rb +17 -0
  37. data/db/migrate/20151201145832_add_external_to_user.rb +5 -0
  38. data/db/migrate/20151202155259_add_external_to_workflow.rb +6 -0
  39. data/db/migrate/20151218145139_add_closed_to_commission.rb +5 -0
  40. data/db/migrate/20151221083612_add_checked_to_chosen_item.rb +5 -0
  41. data/db/migrate/20151221100829_add_bundle_to_chosen_item.rb +5 -0
  42. data/db/migrate/20151221100914_add_checked_in_bundle_to_chosen_item.rb +5 -0
  43. data/db/migrate/20160212155936_remove_chosen_furniture_from_timetable.rb +5 -0
  44. data/db/migrate/20160212160511_add_chosen_item_to_timetable.rb +5 -0
  45. data/db/migrate/20160331101901_add_code_to_user.rb +6 -0
  46. data/db/migrate/20160519144818_save_items_to_make_name_code_the_same.rb +7 -0
  47. data/db/migrate/20160622132452_add_barcode_to_chosen_item.rb +154 -0
  48. data/db/migrate/20160629135548_edit_index_for_furniture.rb +6 -0
  49. data/db/migrate/20170723195528_remove_barcode_from_chosen_items.rb +5 -0
  50. data/lib/mobilart_models.rb +14 -0
  51. data/lib/mobilart_models/engine.rb +12 -0
  52. data/lib/mobilart_models/version.rb +3 -0
  53. data/lib/mobilart_models_abilities.rb +53 -0
  54. data/lib/mobilart_roles.rb +6 -0
  55. data/lib/rails_admin_print_jobs_concern.rb +13 -0
  56. data/lib/rails_admin_printers_concern.rb +13 -0
  57. data/lib/rails_admin_user_main_concern.rb +11 -0
  58. data/lib/tasks/mobilart_models_tasks.rake +4 -0
  59. data/lib/user_model_concerns.rb +13 -0
  60. data/test/dummy/README.rdoc +28 -0
  61. data/test/dummy/Rakefile +6 -0
  62. data/test/dummy/app/assets/javascripts/application.js +13 -0
  63. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  64. data/test/dummy/app/controllers/application_controller.rb +5 -0
  65. data/test/dummy/app/helpers/application_helper.rb +2 -0
  66. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  67. data/test/dummy/bin/bundle +3 -0
  68. data/test/dummy/bin/rails +4 -0
  69. data/test/dummy/bin/rake +4 -0
  70. data/test/dummy/bin/setup +29 -0
  71. data/test/dummy/config.ru +4 -0
  72. data/test/dummy/config/application.rb +25 -0
  73. data/test/dummy/config/boot.rb +5 -0
  74. data/test/dummy/config/database.yml +25 -0
  75. data/test/dummy/config/environment.rb +5 -0
  76. data/test/dummy/config/environments/development.rb +41 -0
  77. data/test/dummy/config/environments/production.rb +79 -0
  78. data/test/dummy/config/environments/test.rb +42 -0
  79. data/test/dummy/config/initializers/assets.rb +11 -0
  80. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  81. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  82. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  83. data/test/dummy/config/initializers/inflections.rb +16 -0
  84. data/test/dummy/config/initializers/mime_types.rb +4 -0
  85. data/test/dummy/config/initializers/session_store.rb +3 -0
  86. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  87. data/test/dummy/config/locales/en.yml +23 -0
  88. data/test/dummy/config/routes.rb +56 -0
  89. data/test/dummy/config/secrets.yml +22 -0
  90. data/test/dummy/log/development.log +1 -0
  91. data/test/dummy/public/404.html +67 -0
  92. data/test/dummy/public/422.html +67 -0
  93. data/test/dummy/public/500.html +66 -0
  94. data/test/dummy/public/favicon.ico +0 -0
  95. data/test/integration/navigation_test.rb +8 -0
  96. data/test/mobilart_models_test.rb +7 -0
  97. data/test/test_helper.rb +20 -0
  98. metadata +206 -0
@@ -0,0 +1,173 @@
1
+ class Workflow < ApplicationRecord
2
+ belongs_to :chosen_item, inverse_of: :workflows
3
+ belongs_to :user, inverse_of: :workflows
4
+ belongs_to :third_party, class_name: 'User', inverse_of: :assigneds
5
+
6
+ validates :statuses, presence: true
7
+ validates :chosen_item, presence: true
8
+ validates :user, presence: true
9
+
10
+ default_scope {
11
+ joins({
12
+ chosen_item: [
13
+ {furniture_item: :item},
14
+ {
15
+ chosen_furniture: [
16
+ :furniture,
17
+ {
18
+ chosen_room: [
19
+ :room,
20
+ {
21
+ chosen_deck: [
22
+ :deck,
23
+ :commission
24
+ ]
25
+ }
26
+ ]
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ })
32
+ }
33
+
34
+ # useful for filters
35
+ def commission
36
+ chosen_item.chosen_furniture.chosen_room.chosen_deck.commission.code rescue "-"
37
+ end
38
+
39
+ def deck
40
+ chosen_item.chosen_furniture.chosen_room.chosen_deck.deck.name rescue "-"
41
+ end
42
+
43
+ def room
44
+ chosen_item.chosen_furniture.chosen_room.room.name rescue "-"
45
+ end
46
+
47
+ def furniture
48
+ chosen_item.chosen_furniture.furniture.name rescue "-"
49
+ end
50
+
51
+ def item
52
+ chosen_item.furniture_item.item.name rescue "-"
53
+ end
54
+
55
+ def barcode
56
+ chosen_item.barcode
57
+ end
58
+
59
+ STAT = %i[
60
+ internal_labour
61
+ external_labour
62
+ internal_paint
63
+ external_paint
64
+ upholstery
65
+ storage
66
+ construction_yard
67
+ ]
68
+
69
+ STAT_TRANSLATED = STAT.each_with_index.map {|a,i| [I18n.t("statuses.#{a.to_sym}"), (i+1).to_s]}
70
+
71
+ def self.stats
72
+ STAT
73
+ end
74
+
75
+ def self.stats_translated
76
+ STAT_TRANSLATED
77
+ end
78
+
79
+ def statuses_enum
80
+ # Array holding all the roles
81
+ # Do not EDIT below this line
82
+ # statuses.map {|s| I18n.t("statuses.#{s.to_sym}")}
83
+ STAT_TRANSLATED
84
+ end
85
+
86
+ def stat
87
+ I18n.t "statuses.#{STAT[(statuses.to_i-1)].to_sym}"
88
+ end
89
+
90
+ def display_name
91
+ # [commission, deck, room, furniture, item].compact.join(" - ")
92
+ chosen_item.barcode
93
+ end
94
+
95
+ rails_admin do
96
+ navigation_label I18n.t("admin.tools.label")
97
+ navigation_icon 'fa fa-code-fork'
98
+ weight 9
99
+
100
+ # field :chosen_item
101
+ field :barcode do
102
+ read_only true
103
+ # This is a very sad hack, leveraging on the hackability of
104
+ # this part of code.
105
+ # I expect to see it explode in a while, trying to search for a solution,
106
+ # a true one, meanwhile... I use the hack (rails_admin just adds a dot
107
+ # between key and value.. thus rebuilding the string as needed)
108
+ searchable [{ "concat(commissions" => "code,decks.code,chosen_decks.code,rooms.code,chosen_rooms.code,furnitures.code,chosen_furnitures.code,items.code,LPAD(chosen_items.code::text, 5, '0'))"}]
109
+ end
110
+ field :statuses
111
+ field :third_party do
112
+ searchable [{User => :username}]
113
+ associated_collection_cache_all false # REQUIRED if you want to SORT the list
114
+ associated_collection_scope do
115
+ # bindings[:object] & bindings[:controller] are available, but not in scope's block!
116
+ workflow = bindings[:object]
117
+ Proc.new { |scope|
118
+ # Looking just for third parties
119
+ scope = scope.where(third_party: true)
120
+ }
121
+ end
122
+ end
123
+ field :user do
124
+ searchable [{User => :username}]
125
+ end
126
+ field :created_at do
127
+ read_only true
128
+ end
129
+ edit do
130
+ field :chosen_item
131
+ field :description
132
+ end
133
+ show do
134
+ field :item
135
+ field :description
136
+ end
137
+ list do
138
+ field :commission do
139
+ #column_width 12
140
+ searchable "commissions.code"
141
+ read_only true
142
+ sortable "commissions.code"
143
+ filterable true
144
+ end
145
+ field :deck do
146
+ #column_width 12
147
+ searchable "decks.name"
148
+ sortable "decks.name"
149
+ read_only true
150
+ filterable true
151
+ end
152
+ field :room do
153
+ searchable "rooms.name"
154
+ sortable "rooms.name"
155
+ read_only true
156
+ filterable true
157
+ end
158
+ field :furniture do
159
+ searchable "furnitures.name"
160
+ sortable "furnitures.name"
161
+ read_only true
162
+ filterable true
163
+ end
164
+ field :item do
165
+ searchable "items.name"
166
+ sortable "items.name"
167
+ read_only true
168
+ filterable true
169
+ end
170
+ end
171
+
172
+ end
173
+ end
@@ -0,0 +1,7 @@
1
+ Rails.application.configure do
2
+ config.after_initialize do
3
+ PrintJob.send(:include, PrintJobsModelConcern)
4
+ Printer.send(:include, PrinterModelConcern)
5
+ User.send(:include, UserModelConcern)
6
+ end
7
+ end
@@ -0,0 +1,36 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ bundle:
5
+ one: Bundle
6
+ other: Bundles
7
+ deck:
8
+ one: Deck
9
+ other: Decks Database
10
+ furniture:
11
+ one: Furniture
12
+ other: Furnitures Database
13
+ item:
14
+ one: Item
15
+ other: Items Database
16
+ commission:
17
+ one: Ship
18
+ other: Ships (Commissions)
19
+ chosen_deck:
20
+ one: Selected Deck
21
+ other: Decks' Choice
22
+ chosen_furniture:
23
+ one: Selected Furniture
24
+ other: Furnitures' Choice
25
+ chosen_item:
26
+ one: Selected Item
27
+ other: Items' Choice
28
+ chosen_room:
29
+ one: Selected Room
30
+ other: Rooms' Choice
31
+ room:
32
+ one: Room
33
+ other: Rooms Database
34
+ workflow:
35
+ one: Workflow
36
+ other: Workflows
@@ -0,0 +1,38 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
24
+ dashboard: "Dashboard"
25
+ contact: "Contact"
26
+ manage: "Manage"
27
+ sign_out: "Sign Out"
28
+ statuses:
29
+ internal_labour: External Labour
30
+ external_labour: Internal Labour
31
+ internal_paint: External Paint
32
+ external_paint: Internal Paint
33
+ upholstery: Upholstery
34
+ storage: Storage
35
+ construction_yard: Construction Yard
36
+ status:
37
+ finished: Finished
38
+ suspended: Suspended
@@ -0,0 +1,157 @@
1
+ it:
2
+ activerecord:
3
+ models:
4
+ bundle:
5
+ one: Sovracollo
6
+ other: Sovracolli
7
+ deck:
8
+ one: Ponte
9
+ other: Anagrafica Ponti
10
+ furniture:
11
+ one: Mobile
12
+ other: Anagrafica Mobili
13
+ furniture_item:
14
+ one: Particolare
15
+ other: Particolari
16
+ item:
17
+ one: Particolare
18
+ other: Anagrafica Particolari
19
+ commission:
20
+ one: Barca (Commessa)
21
+ other: Barche (Commesse)
22
+ chosen_deck:
23
+ one: Ponte Inserito
24
+ other: Configurazione dei Ponti
25
+ chosen_furniture:
26
+ one: Mobile Inserito
27
+ other: Mobili Inseriti
28
+ chosen_item:
29
+ one: Particolare Inserito
30
+ other: Particolari Scelti
31
+ chosen_room:
32
+ one: Locale Inserito
33
+ other: Configurazione dei Locali
34
+ room:
35
+ one: Locale
36
+ other: Anagrafica Locali
37
+ workflow:
38
+ one: Movimento Lavorazione
39
+ other: Movimenti Lavorazione
40
+ timetable:
41
+ one: Ora Lavorata
42
+ other: Ore Lavorate
43
+ attributes:
44
+ chosen_item:
45
+ commission: Barca
46
+ deck: Ponte
47
+ room: Locale
48
+ chosen_furniture: Mobile
49
+ furniture_item: Particolare
50
+ user: Operaio
51
+ times: Tempo
52
+ status: Stato
53
+ furniture: Mobile
54
+ item: Particolare
55
+ bundle:
56
+ title: Titolo
57
+ description: Descrizione
58
+ code: Codice
59
+ commission: Commessa
60
+ chosen_items: Particolari Scelti
61
+ item:
62
+ name: Nome
63
+ description: Descrizione
64
+ code: Codice
65
+ created_at: Data di Creazione
66
+ updated_at: Data di Aggiornamento
67
+ furniture:
68
+ name: Nome
69
+ description: Descrizione
70
+ code: Codice
71
+ items: Particolari
72
+ furniture_items: Particolari
73
+ created_at: Data di Creazione
74
+ updated_at: Data di Aggiornamento
75
+ furniture_item:
76
+ item: Particolare
77
+ created_at: Data di Creazione
78
+ updated_at: Data di Aggiornamento
79
+ room:
80
+ name: Nome
81
+ description: Descrizione
82
+ code: Codice
83
+ created_at: Data di Creazione
84
+ updated_at: Data di Aggiornamento
85
+ deck:
86
+ name: Nome
87
+ description: Descrizione
88
+ code: Codice
89
+ created_at: Data di Creazione
90
+ updated_at: Data di Aggiornamento
91
+ commission:
92
+ name: Nome
93
+ issued_on: Emesso il
94
+ description: Descrizione
95
+ code: Codice
96
+ decks: Ponti
97
+ chosen_decks: Ponti Selezionati
98
+ closed: Cantiere terminato
99
+ created_at: Data di Creazione
100
+ updated_at: Data di Aggiornamento
101
+ chosen_deck:
102
+ deck: Ponte
103
+ commission: Barca (Commessa)
104
+ code: Codice
105
+ rooms: Locali
106
+ chosen_rooms: Locali Selezionati
107
+ created_at: Data di Creazione
108
+ updated_at: Data di Aggiornamento
109
+ chosen_room:
110
+ commission: Barca (Commessa)
111
+ chosen_deck: Ponte
112
+ furnitures: Mobili
113
+ code: Codice
114
+ room: Locale
115
+ chosen_furnitures: Mobili Selezionati
116
+ created_at: Data di Creazione
117
+ updated_at: Data di Aggiornamento
118
+ deck: Ponte
119
+ chosen_furniture:
120
+ chosen_room: Locale
121
+ furniture: Mobile
122
+ code: Codice
123
+ chosen_items: Parti Selezionate
124
+ created_at: Data di Creazione
125
+ updated_at: Data di Aggiornamento
126
+ location: Posizione
127
+ furniture_items: Particolari Scelti
128
+ commission: Barca (Commessa)
129
+ deck: Ponte
130
+ workflow:
131
+ statuses:
132
+ one: Stato Corrente
133
+ other: Stati
134
+ chosen_item: Particolare
135
+ user: Utente
136
+ description: Descrizione
137
+ third_party: Conto Terzi
138
+ created_at: Registrato alle
139
+ commission: Barca (Commessa)
140
+ deck: Ponte
141
+ room: Locale
142
+ furniture: Mobile
143
+ item: Particolare
144
+ timetable:
145
+ user: Utente
146
+ commission: Barca (Commessa)
147
+ deck: Ponte
148
+ room: Locale
149
+ furniture: Mobile
150
+ item: Nome del Particolare
151
+ chosen_item: Particolare
152
+ job_type: Tipo
153
+ status: Stato
154
+ hours: H
155
+ minutes: M
156
+ notes: Note
157
+ created_at: Data
@@ -0,0 +1,33 @@
1
+ it:
2
+ operative_section: Commesse
3
+ roles:
4
+ one: "Ruolo Uno"
5
+ two: "Ruolo Due"
6
+ three: "Ruolo Tre"
7
+ administratives: "Amministrativi"
8
+ production_managers: "Responsabili di Produzione"
9
+ site_manager: "Responsabili di Cantiere"
10
+ warehouse_worker: "Magazzinieri"
11
+ drivers: "Autisti"
12
+ workers: "Operai"
13
+ thirds: "Terzi"
14
+ statuses:
15
+ internal_labour: Lavorazione Interna
16
+ external_labour: Lavorazione Esterna
17
+ internal_paint: Verniciatura Interna
18
+ external_paint: Verniciatura Esterna
19
+ upholstery: Tappezzeria
20
+ storage: Stoccaggio
21
+ construction_yard: Cantiere
22
+ status:
23
+ finished: Finita
24
+ suspended: Sospesa
25
+ admin:
26
+ scopes:
27
+ commission:
28
+ _all: Tutte le Commesse
29
+ is_opened: Commesse Aperte
30
+ is_closed: Commesse Chiuse
31
+ timetable:
32
+ _all: Tutte le Ore
33
+ last_two_days: Ore degli ultimi due giorni