wordjelly-auth 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/payumoney.png +0 -0
- data/app/assets/javascripts/auth/auth_dependencies.js +20 -1
- data/app/assets/stylesheets/auth/common-styles.scss +15 -0
- data/app/controllers/auth/concerns/shopping/cart_controller_concern.rb +2 -2
- data/app/controllers/auth/concerns/shopping/cart_item_controller_concern.rb +24 -0
- data/app/controllers/auth/concerns/shopping/discount_controller_concern.rb +2 -2
- data/app/controllers/auth/concerns/shopping/payment_controller_concern.rb +5 -2
- data/app/controllers/auth/concerns/shopping/personality_controller_concern.rb +88 -0
- data/app/controllers/auth/concerns/shopping/place_controller_concern.rb +96 -0
- data/app/controllers/auth/concerns/shopping/product_controller_concern.rb +53 -42
- data/app/controllers/auth/concerns/token_concern.rb +3 -1
- data/app/controllers/auth/search_controller.rb +3 -3
- data/app/controllers/auth/shopping/personalities_controller.rb +14 -0
- data/app/controllers/auth/shopping/places_controller.rb +11 -0
- data/app/controllers/auth/shopping/shopping_controller.rb +26 -0
- data/app/helpers/auth/shopping/payments/pay_u_money_helper.rb +1 -1
- data/app/helpers/auth/shopping/personalities/personalities_helper.rb +26 -0
- data/app/helpers/auth/shopping/places/places_helper.rb +26 -0
- data/app/helpers/auth/shopping/products/products_helper.rb +2 -2
- data/app/models/auth/concerns/chief_model_concern.rb +0 -4
- data/app/models/auth/concerns/shopping/cart_concern.rb +31 -4
- data/app/models/auth/concerns/shopping/cart_item_concern.rb +4 -7
- data/app/models/auth/concerns/shopping/discount_concern.rb +0 -7
- data/app/models/auth/concerns/shopping/pay_u_money_concern.rb +2 -2
- data/app/models/auth/concerns/shopping/payment_concern.rb +25 -8
- data/app/models/auth/concerns/shopping/personality_concern.rb +91 -0
- data/app/models/auth/concerns/shopping/place_concern.rb +134 -0
- data/app/models/auth/concerns/shopping/product_concern.rb +57 -1
- data/app/models/auth/shopping/personality.rb +3 -0
- data/app/models/auth/shopping/place.rb +3 -0
- data/app/views/auth/search/authenticated_user_search.js.erb +5 -31
- data/app/views/auth/shopping/personalities/_form.html.erb +32 -0
- data/app/views/auth/shopping/personalities/_search.html.erb +6 -0
- data/app/views/auth/shopping/personalities/_search_results_holder.html.erb +3 -0
- data/app/views/auth/shopping/personalities/new.html.erb +1 -0
- data/app/views/auth/shopping/places/_form.html.erb +62 -0
- data/app/views/auth/shopping/places/_search.html.erb +6 -0
- data/app/views/auth/shopping/places/_search_results_holder.html.erb +3 -0
- data/app/views/auth/shopping/places/new.html.erb +1 -0
- data/app/views/auth/shopping/products/index/_show.html.erb +1 -1
- data/app/views/auth/shopping/products/show/_content.html.erb +2 -1
- data/lib/assets/javascripts/search.js +0 -2
- data/lib/auth/engine.rb +15 -0
- data/lib/auth/rails/routes.rb +7 -1
- data/lib/auth/search/main.rb +20 -8
- data/lib/auth/version.rb +1 -1
- data/lib/wordjelly-auth.rb +1 -0
- data/spec/dummy/app/assets/time_hashes.json +1 -1
- data/spec/dummy/config/initializers/preinitializer.rb +8 -1
- data/spec/dummy/config/routes.rb +1 -1
- metadata +37 -4
@@ -0,0 +1,91 @@
|
|
1
|
+
module Auth::Concerns::Shopping::PersonalityConcern
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include Auth::Concerns::OwnerConcern
|
5
|
+
include Auth::Concerns::EsConcern
|
6
|
+
|
7
|
+
included do
|
8
|
+
|
9
|
+
INDEX_DEFINITION = {
|
10
|
+
index_options: {
|
11
|
+
settings: {
|
12
|
+
index: {
|
13
|
+
analysis: {
|
14
|
+
filter: {
|
15
|
+
nGram_filter: {
|
16
|
+
type: "nGram",
|
17
|
+
min_gram: 2,
|
18
|
+
max_gram: 20,
|
19
|
+
token_chars: [
|
20
|
+
"letter",
|
21
|
+
"digit",
|
22
|
+
"punctuation",
|
23
|
+
"symbol"
|
24
|
+
]
|
25
|
+
}
|
26
|
+
},
|
27
|
+
analyzer: {
|
28
|
+
nGram_analyzer: {
|
29
|
+
type: "custom",
|
30
|
+
tokenizer: "whitespace",
|
31
|
+
filter: [
|
32
|
+
"lowercase",
|
33
|
+
"asciifolding",
|
34
|
+
"nGram_filter"
|
35
|
+
]
|
36
|
+
},
|
37
|
+
whitespace_analyzer: {
|
38
|
+
type: "custom",
|
39
|
+
tokenizer: "whitespace",
|
40
|
+
filter: [
|
41
|
+
"lowercase",
|
42
|
+
"asciifolding"
|
43
|
+
]
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
},
|
49
|
+
mappings: {
|
50
|
+
Auth::OmniAuth::Path.pathify(Auth.configuration.personality_class) => {
|
51
|
+
properties: {
|
52
|
+
_all_fields: {
|
53
|
+
type: "text",
|
54
|
+
analyzer: "nGram_analyzer",
|
55
|
+
search_analyzer: "whitespace_analyzer"
|
56
|
+
},
|
57
|
+
fullname: {
|
58
|
+
type: "keyword",
|
59
|
+
copy_to: "_all_fields"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
before_save do |document|
|
68
|
+
document.public = "no"
|
69
|
+
end
|
70
|
+
|
71
|
+
## this will get stored as an epoch.
|
72
|
+
field :date_of_birth, type: Integer
|
73
|
+
|
74
|
+
## full name
|
75
|
+
field :fullname, type: String
|
76
|
+
|
77
|
+
|
78
|
+
field :sex, type: String
|
79
|
+
end
|
80
|
+
|
81
|
+
## @param[Hash] options : can contain a :resource key. which should be the resource(user) to which all the personalities belong.
|
82
|
+
module ClassMethods
|
83
|
+
def find_personalities(options)
|
84
|
+
conditions = {:resource_id => nil, :parent_id => nil}
|
85
|
+
conditions[:resource_id] = options[:resource].id.to_s if options[:resource]
|
86
|
+
puts "conditions are:"
|
87
|
+
puts conditions.to_s
|
88
|
+
Auth.configuration.personality_class.constantize.where(conditions)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Auth::Concerns::Shopping::PlaceConcern
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include Auth::Concerns::OwnerConcern
|
5
|
+
|
6
|
+
|
7
|
+
included do
|
8
|
+
|
9
|
+
INDEX_DEFINITION = {
|
10
|
+
index_options: {
|
11
|
+
settings: {
|
12
|
+
index: {
|
13
|
+
analysis: {
|
14
|
+
filter: {
|
15
|
+
nGram_filter: {
|
16
|
+
type: "nGram",
|
17
|
+
min_gram: 2,
|
18
|
+
max_gram: 20,
|
19
|
+
token_chars: [
|
20
|
+
"letter",
|
21
|
+
"digit",
|
22
|
+
"punctuation",
|
23
|
+
"symbol"
|
24
|
+
]
|
25
|
+
}
|
26
|
+
},
|
27
|
+
analyzer: {
|
28
|
+
nGram_analyzer: {
|
29
|
+
type: "custom",
|
30
|
+
tokenizer: "whitespace",
|
31
|
+
filter: [
|
32
|
+
"lowercase",
|
33
|
+
"asciifolding",
|
34
|
+
"nGram_filter"
|
35
|
+
]
|
36
|
+
},
|
37
|
+
whitespace_analyzer: {
|
38
|
+
type: "custom",
|
39
|
+
tokenizer: "whitespace",
|
40
|
+
filter: [
|
41
|
+
"lowercase",
|
42
|
+
"asciifolding"
|
43
|
+
]
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
},
|
49
|
+
mappings: {
|
50
|
+
Auth::OmniAuth::Path.pathify(Auth.configuration.place_class) => {
|
51
|
+
properties: {
|
52
|
+
_all_fields: {
|
53
|
+
type: "text",
|
54
|
+
analyzer: "nGram_analyzer",
|
55
|
+
search_analyzer: "whitespace_analyzer"
|
56
|
+
},
|
57
|
+
nearest_address: {
|
58
|
+
type: "keyword",
|
59
|
+
copy_to: "_all_fields"
|
60
|
+
},
|
61
|
+
unit_number: {
|
62
|
+
type: "keyword",
|
63
|
+
copy_to: "_all_fields"
|
64
|
+
},
|
65
|
+
building: {
|
66
|
+
type: "keyword",
|
67
|
+
copy_to: "_all_fields"
|
68
|
+
},
|
69
|
+
street: {
|
70
|
+
type: "keyword",
|
71
|
+
copy_to: "_all_fields"
|
72
|
+
},
|
73
|
+
city: {
|
74
|
+
type: "keyword",
|
75
|
+
copy_to: "_all_fields"
|
76
|
+
},
|
77
|
+
country_state: {
|
78
|
+
type: "keyword",
|
79
|
+
copy_to: "_all_fields"
|
80
|
+
},
|
81
|
+
country: {
|
82
|
+
type: "keyword",
|
83
|
+
copy_to: "_all_fields"
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
before_save do |document|
|
92
|
+
document.public = "no"
|
93
|
+
end
|
94
|
+
|
95
|
+
field :nearest_address, type: String
|
96
|
+
|
97
|
+
field :latitude, type: String
|
98
|
+
|
99
|
+
field :longitude, type: String
|
100
|
+
|
101
|
+
field :unit_number, type: String
|
102
|
+
|
103
|
+
field :building, type: String
|
104
|
+
|
105
|
+
field :street, type: String
|
106
|
+
|
107
|
+
field :pin_code, type: Integer
|
108
|
+
|
109
|
+
field :city, type: String
|
110
|
+
|
111
|
+
field :country_state, type: String
|
112
|
+
|
113
|
+
field :country, type: String
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
def get_address_from_details
|
118
|
+
address = ""
|
119
|
+
[:unit_number,:building,:street,:city,:country_state,:country,:pin_code].each do |component|
|
120
|
+
address += (" " + self.send(component).to_s) unless self.send(component).nil?
|
121
|
+
end
|
122
|
+
address
|
123
|
+
end
|
124
|
+
|
125
|
+
module ClassMethods
|
126
|
+
def find_places(options)
|
127
|
+
conditions = {:resource_id => nil, :parent_id => nil}
|
128
|
+
conditions[:resource_id] = options[:resource].id.to_s if options[:resource]
|
129
|
+
Auth.configuration.place_class.constantize.where(conditions)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
@@ -77,6 +77,15 @@ module Auth::Concerns::Shopping::ProductConcern
|
|
77
77
|
resource_id: {
|
78
78
|
type: "keyword",
|
79
79
|
copy_to: "_all_fields"
|
80
|
+
},
|
81
|
+
bundle_name: {
|
82
|
+
type: "text",
|
83
|
+
copy_to: "_all_fields",
|
84
|
+
fields: {
|
85
|
+
raw: {
|
86
|
+
type: "keyword"
|
87
|
+
}
|
88
|
+
}
|
80
89
|
}
|
81
90
|
}
|
82
91
|
}
|
@@ -103,20 +112,29 @@ module Auth::Concerns::Shopping::ProductConcern
|
|
103
112
|
|
104
113
|
field :badge_class, type: String, default: "new badge"
|
105
114
|
|
115
|
+
## so i create a bundle and add 5 products to it,
|
116
|
+
## and then modify their prices ?
|
117
|
+
## what about all the notifications and everythign ?
|
118
|
+
## will have to replicate all that ?
|
119
|
+
##
|
120
|
+
field :bundle_name, type: String
|
121
|
+
|
106
122
|
## all products are public to be searched.
|
107
123
|
before_save do |document|
|
108
124
|
self.public = "yes"
|
109
125
|
end
|
110
126
|
|
111
|
-
##
|
127
|
+
## forget it.
|
112
128
|
|
113
129
|
end
|
114
130
|
|
131
|
+
|
115
132
|
|
116
133
|
|
117
134
|
def as_indexed_json(options={})
|
118
135
|
{
|
119
136
|
name: name,
|
137
|
+
bundle_name: bundle_name,
|
120
138
|
price: price,
|
121
139
|
resource_id: resource_id,
|
122
140
|
public: public
|
@@ -126,6 +144,44 @@ module Auth::Concerns::Shopping::ProductConcern
|
|
126
144
|
|
127
145
|
module ClassMethods
|
128
146
|
|
147
|
+
## @return[SearchResult]
|
148
|
+
def bundle_autocomplete_aggregation(query)
|
149
|
+
query[:body][:aggregations] = {
|
150
|
+
bundle_names: {
|
151
|
+
terms: {
|
152
|
+
field: "bundle_name.raw"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
result = Auth.configuration.product_class.constantize.es.search query
|
158
|
+
|
159
|
+
puts "these are the aggs."
|
160
|
+
puts result.raw_response.to_s
|
161
|
+
#mash = Hashie::Mash.new result
|
162
|
+
#has_more_results = false if mash.aggregations.bundle_names["buckets"].size == 0
|
163
|
+
#mash.aggregations.bundle_names["buckets"].each do |bucket|
|
164
|
+
# puts "this is the bucket: "
|
165
|
+
# puts bucket.to_s
|
166
|
+
#after = bucket["key"]["symptom_thing"]
|
167
|
+
#doc_count = bucket["doc_count"]
|
168
|
+
#create_symptom(after,doc_count)
|
169
|
+
#puts "created #{counter} symptoms"
|
170
|
+
#counter+=1
|
171
|
+
#end
|
172
|
+
=begin
|
173
|
+
mash = Hashie::Mash.new symptom_co_occurrence_query
|
174
|
+
has_more_results = false if mash.aggregations.my_buckets["buckets"].size == 0
|
175
|
+
mash.aggregations.my_buckets["buckets"].each do |bucket|
|
176
|
+
after = bucket["key"]["symptom_thing"]
|
177
|
+
doc_count = bucket["doc_count"]
|
178
|
+
create_symptom(after,doc_count)
|
179
|
+
puts "created #{counter} symptoms"
|
180
|
+
counter+=1
|
181
|
+
end
|
182
|
+
=end
|
183
|
+
end
|
184
|
+
|
129
185
|
## so we have completed the rolling n minutes.
|
130
186
|
def add_to_previous_rolling_n_minutes(minutes,origin_epoch,cycle_to_add)
|
131
187
|
|
@@ -1,38 +1,12 @@
|
|
1
1
|
<% @search_results.each do |result|
|
2
2
|
_partial = "auth/search/search_result.html.erb"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
## if that doesnt exist, try the auth class
|
8
|
-
## if that also doesnt exist, then render the base
|
9
|
-
## search result view.
|
10
|
-
search_path = Auth::OmniAuth::Path.model_to_path(result.class) + "/_search_result.html.erb"
|
11
|
-
|
12
|
-
if lookup_context.find_all(search_path).any?
|
13
|
-
|
14
|
-
_partial = search_path
|
15
|
-
|
16
|
-
else
|
17
|
-
search_path = Auth::OmniAuth::Path.model_to_path(result_superclass) + "/_search_result.html.erb"
|
18
|
-
|
19
|
-
|
20
|
-
if lookup_context.find_all(search_path).any?
|
21
|
-
_partial = search_path
|
22
|
-
else
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
else
|
27
|
-
|
28
|
-
end
|
29
|
-
else
|
30
|
-
|
3
|
+
search_path = Auth::OmniAuth::Path.model_to_path(result.class) + "/_search_result.html.erb"
|
4
|
+
if lookup_context.find_all(search_path).any?
|
5
|
+
puts "found in lookup context."
|
6
|
+
_partial = search_path
|
31
7
|
end
|
32
|
-
|
33
|
-
|
34
8
|
_partial = _partial.gsub(/\/_search/,"/search")
|
35
|
-
|
9
|
+
puts "partial is: #{_partial}"
|
36
10
|
%>
|
37
11
|
|
38
12
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<%= form_for(@auth_shopping_personality, url: @auth_shopping_personality.new_record? ? personalities_path : personality_path(@auth_shopping_personality), method: @auth_shopping_personality.new_record? ? :post : :put, namespace: @auth_shopping_personality.id.to_s, as: :personality, remote: true) do |f| %>
|
2
|
+
|
3
|
+
<% if @auth_shopping_personality.errors.any? %>
|
4
|
+
<div id="error_explanation">
|
5
|
+
<h2><%= pluralize(@auth_shopping_personality.errors.count, "error") %> prohibited this auth_shopping_personality from being saved:</h2>
|
6
|
+
|
7
|
+
<ul>
|
8
|
+
<% @auth_shopping_personality.errors.full_messages.each do |message| %>
|
9
|
+
<li><%= message %></li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
<div class="row">
|
15
|
+
<div class="form_fields col l6 m6 s6 offset-l3 offset-m3 offset-s3">
|
16
|
+
<%= f.text_field :fullname %>
|
17
|
+
<%= f.label :fullname %>
|
18
|
+
|
19
|
+
<%= f.text_field :date_of_birth, :class => "datepicker" %>
|
20
|
+
<%= f.label :date_of_birth %>
|
21
|
+
|
22
|
+
<%= f.text_field :sex %>
|
23
|
+
<%= f.label :sex %>
|
24
|
+
<div class="actions center m-30-top">
|
25
|
+
<%= f.button :submit, {:class => "waves-effect waves-light btn-small blue-grey"} do %>
|
26
|
+
Create
|
27
|
+
<% end %>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "form" %>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<%= form_for(@auth_shopping_place, url: @auth_shopping_place.new_record? ? places_path : place_path(@auth_shopping_place), method: @auth_shopping_place.new_record? ? :post : :put, as: :place, remote: true) do |f| %>
|
2
|
+
|
3
|
+
<% if @auth_shopping_place.errors.any? %>
|
4
|
+
<div id="error_explanation">
|
5
|
+
<h2><%= pluralize(@auth_shopping_place.errors.count, "error") %> prohibited this auth_shopping_place from being saved:</h2>
|
6
|
+
|
7
|
+
<ul>
|
8
|
+
<% @auth_shopping_place.errors.full_messages.each do |message| %>
|
9
|
+
<li><%= message %></li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
<div class="row">
|
15
|
+
<div class="form_fields col l6 m6 s6 offset-l3 offset-m3 offset-s3">
|
16
|
+
|
17
|
+
<%= f.text_field :nearest_address %>
|
18
|
+
<%= f.label :nearest_address %>
|
19
|
+
|
20
|
+
<div id="google_places_autocomplete_results">
|
21
|
+
<ul class="collection" style="border:none !important;"></ul>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<!-- okay so now we have to autopopulate, so first let me get all the fields of the country , city etc -->
|
25
|
+
<!-- is that necessary ? -->
|
26
|
+
|
27
|
+
<div id="address_details" style="display:none;">
|
28
|
+
<%= f.hidden_field :latitude %>
|
29
|
+
|
30
|
+
<%= f.hidden_field :longitude %>
|
31
|
+
|
32
|
+
<%= f.text_field :unit_number %>
|
33
|
+
<%= f.label :unit_number %>
|
34
|
+
|
35
|
+
<%= f.text_field :building %>
|
36
|
+
<%= f.label :building %>
|
37
|
+
|
38
|
+
<%= f.text_field :street %>
|
39
|
+
<%= f.label :street %>
|
40
|
+
|
41
|
+
<%= f.text_field :pin_code %>
|
42
|
+
<%= f.label :pin_code %>
|
43
|
+
|
44
|
+
<%= f.text_field :city %>
|
45
|
+
<%= f.label :city %>
|
46
|
+
|
47
|
+
<%= f.text_field :country_state %>
|
48
|
+
<%= f.label :country_state %>
|
49
|
+
|
50
|
+
<%= f.text_field :country %>
|
51
|
+
<%= f.label :country %>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<div class="actions center m-30-top">
|
55
|
+
<%= f.button :submit, {:class => "waves-effect waves-light btn-small blue-grey"} do %>
|
56
|
+
Create
|
57
|
+
<% end %>
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
62
|
+
|