faalis_contacts 0.4.0 → 0.4.1
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/app/models/contact.rb +6 -1
- data/app/models/contact_details.rb +12 -8
- data/app/models/contact_field.rb +1 -0
- data/app/models/contact_type.rb +1 -0
- data/app/views/api/v1/contacts/index.json.jbuilder +1 -1
- data/db/seeds.rb +5 -6
- data/lib/faalis_contacts/version.rb +1 -1
- metadata +4 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7c4ccd014599f0ab0443dacb77940a9833744754
         | 
| 4 | 
            +
              data.tar.gz: 953e6c9a341de6568b8342d8958362c0c1b37086
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1154b504bce0cf4418ae81bdd1de0c69c797722d967dcb1b9afe7d86b296db7d996069f2184a97709fdc3075602261db74d218ec313e844db3e7fb66dcd31bf5
         | 
| 7 | 
            +
              data.tar.gz: 730e88542a9882414b6693191ae2423709c1ebd2ff3bba57a8b0f395bb9ccc26143c84093c0d11f474a0ddfbf27d9b038665a7f150fe03cbc598344efc00bc01
         | 
    
        data/app/models/contact.rb
    CHANGED
    
    | @@ -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 =>  | 
| 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 | 
            -
                 | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
                   | 
| 30 | 
            -
             | 
| 31 | 
            -
                   | 
| 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
         | 
    
        data/app/models/contact_field.rb
    CHANGED
    
    
    
        data/app/models/contact_type.rb
    CHANGED
    
    
| @@ -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
         | 
    
        data/db/seeds.rb
    CHANGED
    
    | @@ -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")
         | 
    
        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. | 
| 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- | 
| 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:  | 
| 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:  | 
| 97 | 
            +
                    version: 2.1.2
         | 
| 98 98 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 99 99 | 
             
              name: globalize
         | 
| 100 100 | 
             
              requirement: !ruby/object:Gem::Requirement
         |