unidom-party 1.2 → 1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/app/models/unidom/party/collaborating.rb +17 -0
- data/app/models/unidom/party/concerns/as_source_party.rb +3 -3
- data/app/models/unidom/party/concerns/as_target_party.rb +3 -3
- data/db/migrate/20010111000000_create_unidom_collaboratings.rb +36 -0
- data/lib/unidom/party/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: da6a352066a2a8cbd63b3ac270db33368977474a
|
4
|
+
data.tar.gz: 6c1cf67ae25275213333777c8ed84b1a702386be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49762cc91346d650622ebf88e8c802113fcf5f3515c6b9aa9aa742383c417e6fd7c1db6f0d7e094b284d482e66ac17575437553627a6108ba25026ab794b44bb
|
7
|
+
data.tar.gz: 3898dd908599567741c0964b31517bce7827b85177496102b0e4b3df90d7c04cfdabda04f0bde92ba84b32b7dce83d154c9a052c1c104d6b70e2440fa5517dda
|
data/README.md
CHANGED
@@ -40,6 +40,8 @@ relation = Unidom::Party::PartyRelation.relate! source_party: company, target_pa
|
|
40
40
|
|
41
41
|
Unidom::Party::PartyRelation.source_party_is(company).target_party_is(person).valid_at.alive
|
42
42
|
# Find all relationships from the company & the person, like employment
|
43
|
+
|
44
|
+
Unidom::Party::Collaborating.create! collaboration: project, collaborator: person, role_code: 'PJMG', name: 'Project Manager'
|
43
45
|
```
|
44
46
|
|
45
47
|
|
@@ -54,8 +56,10 @@ include Unidom::Party::Concerns::AsTargetParty
|
|
54
56
|
The As Source Party concern do the following tasks for the includer automatically:
|
55
57
|
1. Define the has_many :target_party_relations macro as: ``has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party``
|
56
58
|
2. Define the #relate! method as: ``relate!(to: nil, due_to: nil, at: Time.now)``
|
59
|
+
3. Define the #relate? method as: ``relate?(to: nil, due_to: nil, at: Time.now)``
|
57
60
|
|
58
61
|
### As Target Party concern
|
59
62
|
The As Target Party concern do the following tasks for the includer automatically:
|
60
63
|
1. Define the has_many :source_party_relations macro as: ``has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party``
|
61
64
|
2. Define the #is_related! method as: ``is_related!(to: nil, due_to: nil, at: Time.now)``
|
65
|
+
3. Define the #is_related? method as: ``is_related?(to: nil, due_to: nil, at: Time.now)``
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Collaborating 是参与者以特定的角色进行协作。
|
2
|
+
|
3
|
+
class Unidom::Party::Collaborating < ActiveRecord::Base
|
4
|
+
|
5
|
+
self.table_name = 'unidom_collaboratings'
|
6
|
+
|
7
|
+
include Unidom::Common::Concerns::ModelExtension
|
8
|
+
|
9
|
+
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
10
|
+
|
11
|
+
belongs_to :collaboration, polymorphic: true
|
12
|
+
belongs_to :collaborator, polymorphic: true
|
13
|
+
|
14
|
+
scope :collaboration_is, ->(collaboration) { where collaboration: collaboration }
|
15
|
+
scope :collaborated_by, ->(collaborator) { where collaborator: collaborator }
|
16
|
+
|
17
|
+
end
|
@@ -10,9 +10,9 @@ module Unidom::Party::Concerns::AsSourceParty
|
|
10
10
|
target_party_relations.create! target_party: to, linkage_code: due_to, opened_at: at
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def relate?(to: nil, due_to: nil, at: Time.now)
|
14
|
+
target_party_relations.target_party_is(to).linkage_coded_as(due_to).valid_at(now: at).alive.exists?
|
15
|
+
end
|
16
16
|
|
17
17
|
end
|
18
18
|
|
@@ -10,9 +10,9 @@ module Unidom::Party::Concerns::AsTargetParty
|
|
10
10
|
source_party_relations.create! source_party: to, linkage_code: due_to, opened_at: at
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def is_related?(to: nil, due_to: nil, at: Time.now)
|
14
|
+
source_party_relations.source_party_is(to).linkage_coded_as(due_to).valid_at(now: at).alive.exists?
|
15
|
+
end
|
16
16
|
|
17
17
|
end
|
18
18
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class CreateUnidomCollaboratings < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :unidom_collaboratings, id: :uuid do |t|
|
6
|
+
|
7
|
+
t.references :collaboration, type: :uuid, null: false,
|
8
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
9
|
+
t.references :collaborator, type: :uuid, null: false,
|
10
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
11
|
+
|
12
|
+
t.column :role_code, 'char(4)', null: false, default: 'ZZZZ'
|
13
|
+
|
14
|
+
t.string :name, null: false, default: '', limit: 200
|
15
|
+
t.integer :priority, null: false, default: 0
|
16
|
+
t.integer :grade, null: false, default: 0
|
17
|
+
|
18
|
+
t.text :description
|
19
|
+
t.text :instruction
|
20
|
+
|
21
|
+
t.column :state, 'char(1)', null: false, default: 'C'
|
22
|
+
t.datetime :opened_at, null: false, default: ::Time.utc(1970)
|
23
|
+
t.datetime :closed_at, null: false, default: ::Time.utc(3000)
|
24
|
+
t.boolean :defunct, null: false, default: false
|
25
|
+
t.jsonb :notation, null: false, default: {}
|
26
|
+
|
27
|
+
t.timestamps null: false
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
add_index :unidom_collaboratings, :collaboration_id
|
32
|
+
add_index :unidom_collaboratings, :collaborator_id
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/unidom/party/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.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-
|
11
|
+
date: 2016-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- app/assets/stylesheets/unidom/party/application.css
|
41
41
|
- app/controllers/unidom/party/application_controller.rb
|
42
42
|
- app/helpers/unidom/party/application_helper.rb
|
43
|
+
- app/models/unidom/party/collaborating.rb
|
43
44
|
- app/models/unidom/party/company.rb
|
44
45
|
- app/models/unidom/party/concerns/as_source_party.rb
|
45
46
|
- app/models/unidom/party/concerns/as_target_party.rb
|
@@ -54,6 +55,7 @@ files:
|
|
54
55
|
- db/migrate/20010103000000_create_unidom_shops.rb
|
55
56
|
- db/migrate/20010104000000_create_unidom_government_agencies.rb
|
56
57
|
- db/migrate/20010105000000_create_unidom_companies.rb
|
58
|
+
- db/migrate/20010111000000_create_unidom_collaboratings.rb
|
57
59
|
- lib/tasks/party_tasks.rake
|
58
60
|
- lib/unidom/party.rb
|
59
61
|
- lib/unidom/party/engine.rb
|