usman 0.3.28 → 0.3.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/usman/api/v1/contacts_controller.rb +3 -6
- data/app/controllers/usman/api/v1/docs_controller.rb +2 -4
- data/app/models/usman/contact.rb +8 -11
- data/app/serializers/contact_serializer.rb +1 -1
- data/app/views/usman/api/v1/docs/all_contacts/_pos_case_1.html.erb +2 -8
- data/app/views/usman/api/v1/docs/contacts_sync/_neg_case_1.html.erb +2 -4
- data/app/views/usman/api/v1/docs/contacts_sync/_pos_case_1.html.erb +2 -4
- data/app/views/usman/api/v1/docs/single_contact/_pos_case_1.html.erb +1 -4
- data/db/migrate/20171212094209_correct_contacts.rb +7 -0
- data/lib/usman/version.rb +1 -1
- data/spec/dummy/spec/factories/contact.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9839d730797d07337b7149badcdbf025934f356e
|
4
|
+
data.tar.gz: 73c00478cf0c8caec5ed7f2de7f59badbf33265c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32981f73b6c4fe759f6e15d818b4376749a8c8b3fc9d2a4316bcbf9d403528cf5a1ce3c368ded4f2b4db12217ebc44755759a8574da2b91d09a57ace24f26dfc
|
7
|
+
data.tar.gz: c32f1463a7b3248d2b2cbd39996cc3a545afe2d11b7fb04d6b41437495b92048d294b8f47116d6d7630edef0dfbe7fb293df4c764c922336a6fcfec74e5646ef
|
@@ -21,11 +21,8 @@ module Usman
|
|
21
21
|
contact.name = cnt["name"]
|
22
22
|
contact.account_type = cnt["account_type"]
|
23
23
|
contact.email = cnt["email"]
|
24
|
-
contact.
|
25
|
-
|
26
|
-
contact.contact_number_3 = cnt["contact_number_3"]
|
27
|
-
contact.contact_number_4 = cnt["contact_number_4"]
|
28
|
-
|
24
|
+
contact.contact_number = cnt["contact_number"]
|
25
|
+
|
29
26
|
contact.owner = @current_user
|
30
27
|
contact.done_deal_user = contact.get_done_deal_user
|
31
28
|
contact.registration = @current_registration
|
@@ -106,7 +103,7 @@ module Usman
|
|
106
103
|
private
|
107
104
|
|
108
105
|
def permitted_params
|
109
|
-
params.permit(:name, :account_type, :email, :address, :
|
106
|
+
params.permit(:name, :account_type, :email, :address, :contact_number)
|
110
107
|
end
|
111
108
|
|
112
109
|
end
|
@@ -230,16 +230,14 @@ module Usman
|
|
230
230
|
"account_type": "com.mollywood",
|
231
231
|
"email": "mohanlal@gmail.com",
|
232
232
|
"address": "xyz, str, efg",
|
233
|
-
"
|
234
|
-
"contact_number_2":"9846557465"
|
233
|
+
"contact_number": "87393993884"
|
235
234
|
},
|
236
235
|
{
|
237
236
|
"name": "Mammukka",
|
238
237
|
"account_type": "com.mollywood1",
|
239
238
|
"email": "mammukka@gmail.com",
|
240
239
|
"address": "xyz, str, efg",
|
241
|
-
"
|
242
|
-
"contact_number_2":"8086500502"
|
240
|
+
"contact_number": "7046338475"
|
243
241
|
}
|
244
242
|
]',
|
245
243
|
default: ""
|
data/app/models/usman/contact.rb
CHANGED
@@ -17,10 +17,7 @@ class Usman::Contact < Usman::ApplicationRecord
|
|
17
17
|
format: /\A(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})\z/i
|
18
18
|
validates :address, length: {maximum: 512}
|
19
19
|
|
20
|
-
validates :
|
21
|
-
validates :contact_number_2, length: {maximum: 24}
|
22
|
-
validates :contact_number_3, length: {maximum: 24}
|
23
|
-
validates :contact_number_4, length: {maximum: 24}
|
20
|
+
validates :contact_number, presence: true, length: {maximum: 24}
|
24
21
|
|
25
22
|
# ------------------
|
26
23
|
# Class Methods
|
@@ -32,10 +29,7 @@ class Usman::Contact < Usman::ApplicationRecord
|
|
32
29
|
# >>> Contact.search(query)
|
33
30
|
# => ActiveRecord::Relation object
|
34
31
|
scope :search, lambda {|query| where("LOWER(contacts.name) LIKE LOWER('%#{query}%') OR
|
35
|
-
LOWER(contacts.
|
36
|
-
LOWER(contacts.contact_number_2) LIKE LOWER('%#{query}%') OR
|
37
|
-
LOWER(contacts.contact_number_3) LIKE LOWER('%#{query}%') OR
|
38
|
-
LOWER(contacts.contact_number_4) LIKE LOWER('%#{query}%') OR
|
32
|
+
LOWER(contacts.contact_number) LIKE LOWER('%#{query}%') OR
|
39
33
|
LOWER(contacts.email) LIKE LOWER('%#{query}%') OR
|
40
34
|
LOWER(contacts.account_type) LIKE LOWER('%#{query}%')")}
|
41
35
|
|
@@ -68,10 +62,13 @@ class Usman::Contact < Usman::ApplicationRecord
|
|
68
62
|
"#{self.name}"
|
69
63
|
end
|
70
64
|
|
65
|
+
def parse_phone_number(num)
|
66
|
+
num.gsub(' ','').gsub('(','').gsub(')','').gsub('-','').strip
|
67
|
+
end
|
68
|
+
|
71
69
|
def get_done_deal_user
|
72
|
-
|
73
|
-
|
74
|
-
reg = Registration.where("CONCAT_WS('', dialing_prefix, mobile_number) IN (?)", arr).first
|
70
|
+
formatted_number = parse_phone_number(self.contact_number)
|
71
|
+
reg = Registration.where("CONCAT_WS('', dialing_prefix, mobile_number) = ?", formatted_number).first
|
75
72
|
return reg && reg.user ? reg.user : nil
|
76
73
|
end
|
77
74
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class ContactSerializer < ActiveModel::Serializer
|
2
2
|
include NullAttributeReplacer
|
3
|
-
attributes :id, :name, :account_type, :email, :address, :
|
3
|
+
attributes :id, :name, :account_type, :email, :address, :contact_number, :done_deal_user_id
|
4
4
|
|
5
5
|
has_one :profile_picture, class_name: "Image::ProfilePicture", serializer: ProfilePictureSerializer do
|
6
6
|
if object.done_deal_user && object.done_deal_user.profile_picture
|
@@ -22,10 +22,7 @@ api_output = <<-eos
|
|
22
22
|
"account_type": "com.mollywood",
|
23
23
|
"email": "mohanlal@gmail.com",
|
24
24
|
"address": "",
|
25
|
-
"
|
26
|
-
"contact_number_2": "9846557465",
|
27
|
-
"contact_number_3": "",
|
28
|
-
"contact_number_4": "",
|
25
|
+
"contact_number": "87393993884"
|
29
26
|
"profile_picture": {
|
30
27
|
"id": "",
|
31
28
|
"created_at": "",
|
@@ -40,10 +37,7 @@ api_output = <<-eos
|
|
40
37
|
"account_type": "com.mollywood1",
|
41
38
|
"email": "mammukka@gmail.com",
|
42
39
|
"address": "",
|
43
|
-
"
|
44
|
-
"contact_number_2": "7488374657",
|
45
|
-
"contact_number_3": "",
|
46
|
-
"contact_number_4": "",
|
40
|
+
"contact_number": "808650052"
|
47
41
|
"profile_picture": {
|
48
42
|
"id": "",
|
49
43
|
"created_at": "",
|
@@ -14,16 +14,14 @@ POST #{request.base_url}/api/v1/contacts/sync
|
|
14
14
|
"account_type": "com.mollywood",
|
15
15
|
"email": "san@gmail.com",
|
16
16
|
"address": "xyz, str, efg",
|
17
|
-
"
|
18
|
-
"contact_number_2":"9846557465"
|
17
|
+
"contact_number": "87393993884"
|
19
18
|
},
|
20
19
|
{
|
21
20
|
"name": "arjun",
|
22
21
|
"account_type": "com.mollywood1",
|
23
22
|
"email": "arj@gmail.com",
|
24
23
|
"address": "xyz, str, efg",
|
25
|
-
"
|
26
|
-
"contact_number_2":"999999999"
|
24
|
+
"contact_number": "77777777"
|
27
25
|
}
|
28
26
|
]
|
29
27
|
}
|
@@ -14,16 +14,14 @@ POST #{request.base_url}/api/v1/contacts/sync
|
|
14
14
|
"account_type": "com.mollywood",
|
15
15
|
"email": "san@gmail.com",
|
16
16
|
"address": "xyz, str, efg",
|
17
|
-
"
|
18
|
-
"contact_number_2":"9846557465"
|
17
|
+
"contact_number": "87393993884"
|
19
18
|
},
|
20
19
|
{
|
21
20
|
"name": "arjun",
|
22
21
|
"account_type": "com.mollywood1",
|
23
22
|
"email": "arj@gmail.com",
|
24
23
|
"address": "xyz, str, efg",
|
25
|
-
"
|
26
|
-
"contact_number_2":"999999999"
|
24
|
+
"contact_number": "77777777"
|
27
25
|
}
|
28
26
|
]
|
29
27
|
}
|
@@ -21,10 +21,7 @@ api_output = <<-eos
|
|
21
21
|
"account_type": "com.mollywood",
|
22
22
|
"email": "mohanlal@gmail.com",
|
23
23
|
"address": "",
|
24
|
-
"
|
25
|
-
"contact_number_2": "9846557465",
|
26
|
-
"contact_number_3": "",
|
27
|
-
"contact_number_4": "",
|
24
|
+
"contact_number": "87393993884"
|
28
25
|
"profile_picture": {
|
29
26
|
"id": "",
|
30
27
|
"created_at": "",
|
data/lib/usman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
@@ -604,6 +604,7 @@ files:
|
|
604
604
|
- db/migrate/20170929083235_change_disabled_to_removed_features.rb
|
605
605
|
- db/migrate/20170929083236_add_country_city_to_users.rb
|
606
606
|
- db/migrate/20171124071245_create_contacts.rb
|
607
|
+
- db/migrate/20171212094209_correct_contacts.rb
|
607
608
|
- lib/tasks/usman/data.rake
|
608
609
|
- lib/tasks/usman/master_data.rake
|
609
610
|
- lib/temp/features.rake
|