faalis_contacts 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d224ce4b37d4b8df41a23b1e2e7aafdad200663
4
- data.tar.gz: 8f47cbe0aff692e50e3b117aba180eb94fcdd34e
3
+ metadata.gz: 7c4ccd014599f0ab0443dacb77940a9833744754
4
+ data.tar.gz: 953e6c9a341de6568b8342d8958362c0c1b37086
5
5
  SHA512:
6
- metadata.gz: d64066f74f6e01eccb5c65a6010324b9151b959cdfa876d3a94783611541123feec8858758efd8f738f9ace5700bad05704ba94c53aaa2f9dce5a7e46b5e2d46
7
- data.tar.gz: 256288cc11e45fdc845785ad466511696fd49a1cbbf0ee66aa70f65ad9031f89a158996c66ecb1c7c1e27c37e7c1bfc92d6e3a48f2c660a7402062774923310b
6
+ metadata.gz: 1154b504bce0cf4418ae81bdd1de0c69c797722d967dcb1b9afe7d86b296db7d996069f2184a97709fdc3075602261db74d218ec313e844db3e7fb66dcd31bf5
7
+ data.tar.gz: 730e88542a9882414b6693191ae2423709c1ebd2ff3bba57a8b0f395bb9ccc26143c84093c0d11f474a0ddfbf27d9b038665a7f150fe03cbc598344efc00bc01
@@ -1,7 +1,12 @@
1
1
  class Contact < ActiveRecord::Base
2
+ include Faalis::Concerns::Authorizable
2
3
  has_many :details, :class_name => "ContactDetails"
3
-
4
4
  validates :first_name, :presence => true
5
5
  validates :last_name, :presence => true
6
6
  #validates_with ValueValidator
7
+
8
+ def name
9
+ "#{organization} - #{first_name} #{last_name}"
10
+
11
+ end
7
12
  end
@@ -1,8 +1,9 @@
1
1
  class ContactDetails < ActiveRecord::Base
2
+ include Faalis::Concerns::Authorizable
2
3
  @already_validate = false
3
4
 
4
5
  belongs_to :contact
5
- belongs_to :field, :class_name => "ContactField"
6
+ belongs_to :field, :class_name => 'ContactField'
6
7
 
7
8
  validates :detail_field_id, :presence => true
8
9
  validates :detail_type, :presence => true
@@ -17,18 +18,21 @@ class ContactDetails < ActiveRecord::Base
17
18
  return
18
19
  end
19
20
 
20
- print "----" * 1000
21
21
  if detail_field_id.nil?
22
22
  errors[:detail_field] = _("Field can not be empty.")
23
23
  return
24
24
  end
25
25
  rules = ContactField.find(detail_field_id).validation_rules
26
- params = JSON.parse(rules).deep_symbolize_keys
27
- @already_validate = true
28
- begin
29
- self.class.validates :detail_value, **params
30
- rescue ArgumentError => e
31
- errors[:error] = _("Field validation rules is not valid!")
26
+ unless rules.nil?
27
+ params = JSON.parse(rules).deep_symbolize_keys
28
+ @already_validate = true
29
+ begin
30
+ self.class.validates :detail_value, **params
31
+ rescue ArgumentError => e
32
+ errors[:error] = _("Field validation rules is not valid!")
33
+ end
34
+ else
35
+ @already_validate = true
32
36
  end
33
37
  end
34
38
  end
@@ -1,4 +1,5 @@
1
1
  class ContactField < ActiveRecord::Base
2
+ include Faalis::Concerns::Authorizable
2
3
  validates :name, :presence => true
3
4
  validates :value_type, :presence => true
4
5
  end
@@ -1,2 +1,3 @@
1
1
  class ContactType < ActiveRecord::Base
2
+ include Faalis::Concerns::Authorizable
2
3
  end
@@ -1,5 +1,5 @@
1
1
  json.array! @contacts do |contact|
2
- json.extract! contact, :id, :prefix, :first_name, :middle_name, :last_name, :suffix, :organization, :is_organization
2
+ json.extract! contact, :name, :id, :prefix, :first_name, :middle_name, :last_name, :suffix, :organization, :is_organization
3
3
  json.details contact.details do |detail|
4
4
  json.id detail.id
5
5
  json.type detail.detail_type
@@ -1,9 +1,8 @@
1
- ContactField.create(name: "Phone")
2
- ContactField.create(name: "Email")
3
- ContactField.create(name: "IM")
4
- ContactField.create(name: "Address")
5
- ContactField.create(name: "Zip Code")
6
-
1
+ ContactField.create(name: "Phone", value_type: "string")
2
+ ContactField.create(name: "Email", value_type: "email")
3
+ ContactField.create(name: "IM", value_type: "string")
4
+ ContactField.create(name: "Address", value_type: "string")
5
+ ContactField.create(name: "Zip Code", value_type: "string")
7
6
 
8
7
  ContactType.create(name: "Home")
9
8
  ContactType.create(name: "Office")
@@ -1,3 +1,3 @@
1
1
  module FaalisContacts
2
- VERSION = "0.4.0"
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faalis_contacts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sameer Rahmani
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-24 00:00:00.000000000 Z
12
+ date: 2014-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '1.2'
90
+ version: 2.1.2
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '1.2'
97
+ version: 2.1.2
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: globalize
100
100
  requirement: !ruby/object:Gem::Requirement