cats_core 1.2.11 → 1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/cats/core/transport_request.rb +25 -1
- data/lib/cats/core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d9c981d6dfe00647462832e97d47af7fc677b5e092a5f675366ae1e49ac8dc
|
4
|
+
data.tar.gz: b24adf0ed11330190cfd57050c94ead1f871e183339351d2caebcc2b09597536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56857803a15398dadccd2396e3a2d1b4124b392258ecc180f678d70ddca5a3dafa7b222774b34a9b2d93e8d23aa928622de3d78772017020c7c67f7996ede95c
|
7
|
+
data.tar.gz: f7b0c9cdbacfec2c9836a80560b2c93a69281e4be503e850ee433ca64917d1703c4bf83d2d59c668495f93fa4371350e9573569ce87ea5207b45a54a18d8b8ac
|
@@ -3,7 +3,9 @@ module Cats
|
|
3
3
|
class TransportRequest < ApplicationRecord
|
4
4
|
DRAFT = 'Draft'.freeze
|
5
5
|
APPROVED = 'Approved'.freeze
|
6
|
-
|
6
|
+
OPEN = 'Open'.freeze
|
7
|
+
CLOSED = 'Closed'.freeze
|
8
|
+
STATUSES = [DRAFT, APPROVED, OPEN, CLOSED].freeze
|
7
9
|
|
8
10
|
belongs_to :requested_by, class_name: 'Cats::Core::User'
|
9
11
|
belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
|
@@ -15,6 +17,28 @@ module Cats
|
|
15
17
|
|
16
18
|
delegate(:full_name, to: :requested_by, prefix: true, allow_nil: true)
|
17
19
|
delegate(:full_name, to: :approved_by, prefix: true, allow_nil: true)
|
20
|
+
|
21
|
+
def approve(approver)
|
22
|
+
raise(StandardError, 'Request is not open for approval.') unless status == DRAFT
|
23
|
+
|
24
|
+
self.approved_by = approver
|
25
|
+
self.status = APPROVED
|
26
|
+
save!
|
27
|
+
end
|
28
|
+
|
29
|
+
def open
|
30
|
+
raise(StandardError, 'Request is not approved for opening.') unless status == APPROVED
|
31
|
+
|
32
|
+
self.status = OPEN
|
33
|
+
save!
|
34
|
+
end
|
35
|
+
|
36
|
+
def close
|
37
|
+
raise(StandardError, 'Request is not open.') unless status == OPEN
|
38
|
+
|
39
|
+
self.status = CLOSED
|
40
|
+
save!
|
41
|
+
end
|
18
42
|
end
|
19
43
|
end
|
20
44
|
end
|
data/lib/cats/core/version.rb
CHANGED