unidom-action 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/app/models/unidom/action/acting.rb +17 -0
- data/db/migrate/20000510000000_create_unidom_actings.rb +37 -0
- data/lib/unidom/action/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 380407c921dd3d237c8a7c398f30d444996dd869
|
4
|
+
data.tar.gz: 10ee02a67e68a196af14a6ac391b25c21266ade5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90c25d3596aaf81d443bb7129242db938ed502e9dc628e7be8394567801d9d7f2bf21520b756b7366404f5e68ebb4b3554ff9721a31202353b7d297f6b2f7d60
|
7
|
+
data.tar.gz: 8d3f620b72ecc02567d220469a56ae4295a28b30bcf5efc8631a4d2badc3b8c3efe49a465d048adb9a70447ed48827319eab492741dd397ba1ca4463ee35ef54
|
data/README.md
CHANGED
@@ -27,9 +27,18 @@ reason = Unidom::Action::Reason.create! activity_code: 'SRRR', name: 'broken', d
|
|
27
27
|
# SRRR = Shipment Receipt Rejection Reason
|
28
28
|
|
29
29
|
user = Unidom::Visitor::User.create!
|
30
|
+
|
31
|
+
# Create/Update/Delete the person
|
30
32
|
person = Unidom::Party::Person.create! name: 'Tim'
|
33
|
+
acting = Unidom::Action::Acting.create! actor_visitor: user, actor_party: person, reason: reason, acted: person, from_value: {}, thru_value: { name: 'Time' }
|
31
34
|
|
35
|
+
# Update the state of the person
|
36
|
+
person.state = 'R'
|
37
|
+
person.save!
|
32
38
|
transition = Unidom::Action::StateTransition.create! transitor_visitor: user, transitor_party: person, reason: reason, subject: person, from_state: 'C', thru_state: 'R'
|
39
|
+
|
40
|
+
# Soft destroy the person
|
41
|
+
person.soft_destroy
|
33
42
|
obsolescence = Unidom::Action::Obsolescence.create! obsolescer_visitor: user, obsolescer_party: person, reason: reason, obsolesced: person
|
34
43
|
# The reason could be nil.
|
35
44
|
```
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Acting 是行为记录。
|
2
|
+
# #reason 是原因。
|
3
|
+
# #acted 是被操作的对象。
|
4
|
+
# #action_code 是行为代码,C: create, R: read, U: update, D: destroy。
|
5
|
+
|
6
|
+
class Unidom::Action::Acting < Unidom::Action::ApplicationRecord
|
7
|
+
|
8
|
+
self.table_name = 'unidom_actings'
|
9
|
+
|
10
|
+
include Unidom::Common::Concerns::ModelExtension
|
11
|
+
|
12
|
+
belongs_to :actor_visitor, polymorphic: true
|
13
|
+
belongs_to :actor_party, polymorphic: true
|
14
|
+
belongs_to :acted, polymorphic: true
|
15
|
+
belongs_to :reason, class_name: 'Unidom::Action::Reason'
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class CreateUnidomActings < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :unidom_actings, id: :uuid do |t|
|
6
|
+
|
7
|
+
t.references :actor_visitor, type: :uuid, null: false,
|
8
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
9
|
+
t.references :actor_party, type: :uuid, null: false,
|
10
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
11
|
+
t.references :acted, type: :uuid, null: false,
|
12
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
13
|
+
t.references :reason, type: :uuid, null: true
|
14
|
+
|
15
|
+
t.column :action_code, 'char(1)', null: false, default: 'C'
|
16
|
+
|
17
|
+
t.jsonb :from_value, null: false, default: {}
|
18
|
+
t.jsonb :thru_value, null: false, default: {}
|
19
|
+
|
20
|
+
t.column :state, 'char(1)', null: false, default: 'C'
|
21
|
+
t.datetime :opened_at, null: false, default: Time.utc(1970)
|
22
|
+
t.datetime :closed_at, null: false, default: Time.utc(3000)
|
23
|
+
t.boolean :defunct, null: false, default: false
|
24
|
+
t.jsonb :notation, null: false, default: {}
|
25
|
+
|
26
|
+
t.timestamps null: false
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
add_index :unidom_actings, :actor_visitor_id
|
31
|
+
add_index :unidom_actings, :actor_party_id
|
32
|
+
add_index :unidom_actings, :acted_id
|
33
|
+
add_index :unidom_actings, :reason_id
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- app/helpers/unidom/action/application_helper.rb
|
44
44
|
- app/jobs/unidom/action/application_job.rb
|
45
45
|
- app/mailers/unidom/action/application_mailer.rb
|
46
|
+
- app/models/unidom/action/acting.rb
|
46
47
|
- app/models/unidom/action/application_record.rb
|
47
48
|
- app/models/unidom/action/obsolescence.rb
|
48
49
|
- app/models/unidom/action/reason.rb
|
@@ -50,6 +51,7 @@ files:
|
|
50
51
|
- app/views/layouts/unidom/action/application.html.erb
|
51
52
|
- config/routes.rb
|
52
53
|
- db/migrate/20000501000000_create_unidom_reasons.rb
|
54
|
+
- db/migrate/20000510000000_create_unidom_actings.rb
|
53
55
|
- db/migrate/20000511000000_create_unidom_state_transitions.rb
|
54
56
|
- db/migrate/20000512000000_create_unidom_obsolescences.rb
|
55
57
|
- lib/tasks/action_tasks.rake
|