civic311_test3 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
  3. data/app/assets/fonts/glyphicons-halflings-regular.svg +288 -0
  4. data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
  5. data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
  6. data/app/assets/fonts/glyphicons-halflings-regular.woff2 +0 -0
  7. data/app/assets/images/.keep +0 -0
  8. data/app/assets/javascripts/admin.coffee +3 -0
  9. data/app/assets/javascripts/application.js +17 -0
  10. data/app/assets/javascripts/bootstrap.js.coffee +4 -0
  11. data/app/assets/javascripts/custom.js +147 -0
  12. data/app/assets/stylesheets/admin.scss +3 -0
  13. data/app/assets/stylesheets/application.css +72 -0
  14. data/app/assets/stylesheets/bootstrap.min.css +5 -0
  15. data/app/assets/stylesheets/bootstrap_and_overrides.css.less +34 -0
  16. data/app/assets/stylesheets/rails_admin.css +69 -0
  17. data/app/controllers/admin_controller.rb +404 -0
  18. data/app/controllers/application_controller.rb +5 -0
  19. data/app/controllers/concerns/.keep +0 -0
  20. data/app/helpers/admin_helper.rb +2 -0
  21. data/app/helpers/application_helper.rb +16 -0
  22. data/app/mailers/.keep +0 -0
  23. data/app/models/.keep +0 -0
  24. data/app/models/acceptance.rb +13 -0
  25. data/app/models/agent.rb +270 -0
  26. data/app/models/agent_change_info.rb +67 -0
  27. data/app/models/agent_designation.rb +12 -0
  28. data/app/models/agent_language.rb +12 -0
  29. data/app/models/agent_specialty.rb +12 -0
  30. data/app/models/agent_ticket.rb +12 -0
  31. data/app/models/agent_zip_code.rb +16 -0
  32. data/app/models/best_use.rb +4 -0
  33. data/app/models/buying_wishlist.rb +33 -0
  34. data/app/models/concerns/.keep +0 -0
  35. data/app/models/connection.rb +13 -0
  36. data/app/models/customer.rb +76 -0
  37. data/app/models/customer_device.rb +248 -0
  38. data/app/models/customer_location_alert.rb +31 -0
  39. data/app/models/delayed_job.rb +6 -0
  40. data/app/models/designation.rb +29 -0
  41. data/app/models/help.rb +6 -0
  42. data/app/models/investing_wishlist.rb +18 -0
  43. data/app/models/investing_wishlist_type.rb +12 -0
  44. data/app/models/investment_type.rb +13 -0
  45. data/app/models/issue.rb +9 -0
  46. data/app/models/language.rb +39 -0
  47. data/app/models/license.rb +31 -0
  48. data/app/models/payment_transaction.rb +12 -0
  49. data/app/models/promotion_code.rb +10 -0
  50. data/app/models/property_type.rb +15 -0
  51. data/app/models/question.rb +6 -0
  52. data/app/models/rating.rb +13 -0
  53. data/app/models/rating_question.rb +28 -0
  54. data/app/models/rating_request.rb +8 -0
  55. data/app/models/renting_wishlist.rb +31 -0
  56. data/app/models/request_showing.rb +14 -0
  57. data/app/models/schema_migration.rb +6 -0
  58. data/app/models/selling_wishlist.rb +28 -0
  59. data/app/models/setting.rb +6 -0
  60. data/app/models/sharing.rb +15 -0
  61. data/app/models/specialty.rb +25 -0
  62. data/app/models/state.rb +21 -0
  63. data/app/models/suggestion.rb +10 -0
  64. data/app/models/user.rb +107 -0
  65. data/app/models/user_history.rb +6 -0
  66. data/app/models/wishlist.rb +17 -0
  67. data/app/views/admin/_form.html.erb +184 -0
  68. data/app/views/admin/_header.html.erb +58 -0
  69. data/app/views/admin/dashboard.html.erb +142 -0
  70. data/app/views/admin/delete.html.erb +0 -0
  71. data/app/views/admin/edit.html.erb +25 -0
  72. data/app/views/admin/export.html.erb +64 -0
  73. data/app/views/admin/index.html.erb +111 -0
  74. data/app/views/admin/new.html.erb +25 -0
  75. data/app/views/admin/new.js.erb +1 -0
  76. data/app/views/admin/show.html.erb +57 -0
  77. data/app/views/admin/test.html.erb +41 -0
  78. data/app/views/kaminari/_first_page.html.erb +11 -0
  79. data/app/views/kaminari/_gap.html.erb +8 -0
  80. data/app/views/kaminari/_last_page.html.erb +11 -0
  81. data/app/views/kaminari/_next_page.html.erb +11 -0
  82. data/app/views/kaminari/_page.html.erb +12 -0
  83. data/app/views/kaminari/_paginator.html.erb +23 -0
  84. data/app/views/kaminari/_prev_page.html.erb +11 -0
  85. data/app/views/layouts/_sidebar.html.erb +10 -0
  86. data/app/views/layouts/application.html.erb +51 -0
  87. data/civic311_test3-0.0.1.gem +0 -0
  88. data/civic311_test3.gemspec +3 -2
  89. data/config/application.rb +26 -0
  90. data/config/boot.rb +3 -0
  91. data/config/database.yml +54 -0
  92. data/config/environment.rb +5 -0
  93. data/config/environments/development.rb +41 -0
  94. data/config/environments/production.rb +79 -0
  95. data/config/environments/test.rb +42 -0
  96. data/config/initializers/assets.rb +11 -0
  97. data/config/initializers/auto_admin.rb +9 -0
  98. data/config/initializers/backtrace_silencers.rb +7 -0
  99. data/config/initializers/cookies_serializer.rb +3 -0
  100. data/config/initializers/filter_parameter_logging.rb +4 -0
  101. data/config/initializers/inflections.rb +16 -0
  102. data/config/initializers/mime_types.rb +4 -0
  103. data/config/initializers/session_store.rb +3 -0
  104. data/config/initializers/wrap_parameters.rb +14 -0
  105. data/config/locales/en.bootstrap.yml +17 -0
  106. data/config/locales/en.yml +28 -0
  107. data/config/routes.rb +71 -0
  108. data/config/secrets.yml +22 -0
  109. data/lib/civic311_test3/version.rb +1 -1
  110. metadata +123 -3
@@ -0,0 +1,6 @@
1
+ class Help < ActiveRecord::Base
2
+
3
+ self.table_name = "helps"
4
+ self.primary_key = 'id'
5
+
6
+ end
@@ -0,0 +1,18 @@
1
+ class InvestingWishlist < ActiveRecord::Base
2
+
3
+ self.table_name = "investing_wishlists"
4
+ self.primary_key = 'id'
5
+
6
+ has_one :wishlist, foreign_key: "id"
7
+ has_many :investing_wishlist_types, :inverse_of => :investing_wishlist
8
+
9
+ def show_details
10
+ {
11
+ id: self.id,
12
+ name: self.name,
13
+ timeframe: self.timeframe,
14
+ investment_type_id: InvestingWishlistType.where(investing_wishlist_id: self.id).pluck(:investment_type_id)
15
+ }
16
+ end
17
+
18
+ end
@@ -0,0 +1,12 @@
1
+ class InvestingWishlistType < ActiveRecord::Base
2
+
3
+ self.table_name = "investing_wishlist_types"
4
+ self.primary_key = 'id'
5
+
6
+ belongs_to :investing_wishlist, :inverse_of => :investing_wishlist_types
7
+ belongs_to :investment_type, :inverse_of => :investing_wishlist_types
8
+
9
+ def describe_id
10
+ "InvestingWishlistType ##{id}"
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class InvestmentType < ActiveRecord::Base
2
+
3
+ self.table_name = "investment_types"
4
+ self.primary_key = 'id'
5
+
6
+ has_many :investing_wishlist_types, :inverse_of => :investment_type
7
+
8
+ # Get All Investment Type
9
+ def self.get_all_investment_types
10
+ Hash[*InvestmentType.order(:name).pluck(:id, :name).flatten]
11
+ end
12
+
13
+ end
@@ -0,0 +1,9 @@
1
+ class Issue < ActiveRecord::Base
2
+ self.table_name = "issues"
3
+ self.primary_key = 'id'
4
+ belongs_to :user
5
+
6
+ def describe_id
7
+ "Issue ##{id}"
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ class Language < ActiveRecord::Base
2
+
3
+ self.table_name = "languages"
4
+ self.primary_key = 'id'
5
+
6
+ has_one :agent_languages, :inverse_of => :language
7
+ has_one :customers, :class_name => "Language", :foreign_key => "id"
8
+
9
+ # Get All Languages
10
+ def self.get_all_languages
11
+ Hash[*Language.pluck(:id, :name).flatten]
12
+ end
13
+
14
+ # Get Agent's languages
15
+ def self.get_agent_languages(agent)
16
+ Hash[*AgentLanguage.where(agent_id: agent.id).joins(:language).pluck(:language_id, :name).flatten]
17
+ end
18
+
19
+ # def self.to_csv(options = {})
20
+ # CSV.generate(options) do |csv|
21
+ # csv << column_names
22
+ # all.each do |language|
23
+ # csv << language.attributes.values_at(*column_names)
24
+ # end
25
+ # end
26
+ # end
27
+
28
+
29
+
30
+ #rails_admin do
31
+ #configure :customers do
32
+ #visible(false)
33
+ #end
34
+
35
+ #configure :agent_languages do
36
+ #visible(false)
37
+ #end
38
+ #end
39
+ end
@@ -0,0 +1,31 @@
1
+ class License < ActiveRecord::Base
2
+
3
+ self.table_name = "licenses"
4
+ self.primary_key = 'id'
5
+
6
+ validates :license_number, uniqueness: true
7
+
8
+ belongs_to :agent, :inverse_of => :licenses
9
+ belongs_to :state, :class_name => "State", :foreign_key => "license_state_issued"
10
+
11
+ after_save :update_agent_license
12
+
13
+ def describe_id
14
+ "License ##{id}"
15
+ end
16
+ def update_agent_license
17
+ if self.status == "Actived"
18
+
19
+ agent = self.agent
20
+ agent.licenses.where("id != ?",self.id).update_all("status ='Deactived'")
21
+ agent.update_attributes({:license_number => self.license_number, :license_state_issued => self.license_state_issued,:license_issued_date => self.license_issued_date})
22
+ agent.push_notification_change_license("approved")
23
+ UserMailer.delay.send_license_status(agent,"approved")
24
+ elsif self.status =="Deactived"
25
+ agent = self.agent
26
+ agent.push_notification_change_license("rejected")
27
+ UserMailer.delay.send_license_status(agent,"rejected")
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ class PaymentTransaction < ActiveRecord::Base
2
+
3
+ self.table_name = "payment_transactions"
4
+ self.primary_key = 'id'
5
+
6
+ belongs_to :agent, :inverse_of => :payment_transactions
7
+ belongs_to :promotion_code, :inverse_of => :payment_transactions, foreign_key: "promotion_id"
8
+
9
+ def describe_id
10
+ "PaymentTransaction ##{id}"
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class PromotionCode < ActiveRecord::Base
2
+
3
+ self.table_name = "promotion_codes"
4
+ self.primary_key = 'id'
5
+
6
+ validates :promotion_code, uniqueness: true
7
+
8
+ has_many :payment_transactions, :inverse_of => :promotion_code, :foreign_key => "promotion_id"
9
+
10
+ end
@@ -0,0 +1,15 @@
1
+ class PropertyType < ActiveRecord::Base
2
+
3
+ self.table_name = "property_types"
4
+ self.primary_key = 'id'
5
+
6
+ has_many :buying_wishlists, :inverse_of => :property_type
7
+ has_many :selling_wishlists, :inverse_of => :property_type
8
+ has_many :renting_wishlists, :inverse_of => :property_type
9
+
10
+ # Get All Property Types
11
+ def self.get_all_property_types
12
+ Hash[*PropertyType.pluck(:id, :name).flatten]
13
+ end
14
+
15
+ end
@@ -0,0 +1,6 @@
1
+ class Question < ActiveRecord::Base
2
+
3
+ self.table_name = "questions"
4
+ self.primary_key = 'id'
5
+
6
+ end
@@ -0,0 +1,13 @@
1
+ class Rating < ActiveRecord::Base
2
+
3
+ self.table_name = "ratings"
4
+ self.primary_key = 'id'
5
+
6
+ belongs_to :agent, :inverse_of => :ratings
7
+ belongs_to :customer, :inverse_of => :ratings
8
+ belongs_to :rating_question, :inverse_of => :ratings
9
+
10
+ def describe_id
11
+ "Rating ##{id}"
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ class RatingQuestion < ActiveRecord::Base
2
+
3
+ self.table_name = "rating_questions"
4
+ self.primary_key = 'id'
5
+
6
+ has_one :ratings, :inverse_of => :rating_question
7
+
8
+ def name
9
+ question
10
+ end
11
+
12
+ # Get All Rating Question
13
+ def self.get_all_rating_questions
14
+ ratingQuestions = RatingQuestion.pluck(:id, :category, :question).map {|id, category, question| {id: id, category: category, question: question.upcase}}
15
+ ratingQuestions = ratingQuestions.group_by{ |d| d[:category] }.map{|c, q| {category: c, question: q}}.take(3)
16
+ ratingQuestions.each do |rating|
17
+ rating[:question] = rating[:question].take(3)
18
+ end
19
+ end
20
+
21
+ #rails_admin do
22
+
23
+ #configure :ratings do
24
+ #visible(false)
25
+ #end
26
+
27
+ #end
28
+ end
@@ -0,0 +1,8 @@
1
+ class RatingRequest < ActiveRecord::Base
2
+
3
+ self.table_name = "rating_requests"
4
+ self.primary_key = 'id'
5
+
6
+ belongs_to :agent, :inverse_of => :rating_request
7
+
8
+ end
@@ -0,0 +1,31 @@
1
+ class RentingWishlist < ActiveRecord::Base
2
+
3
+ self.table_name = "renting_wishlists"
4
+ self.primary_key = 'id'
5
+
6
+ has_one :wishlist, foreign_key: "id"
7
+ belongs_to :property_type, :inverse_of => :renting_wishlists
8
+
9
+ def show_details
10
+ {
11
+ id: self.id,
12
+ name: self.name,
13
+ price_range_low: self.price_range_low,
14
+ price_range_high: self.price_range_high,
15
+ property_type_id: self.property_type_id,
16
+ beds_number: self.beds_number,
17
+ baths_number: self.baths_number,
18
+ square_footage_low: self.square_footage_low,
19
+ square_footage_high: self.square_footage_high,
20
+ built_year_low: self.built_year_low,
21
+ built_year_high: self.built_year_high,
22
+ lot_size: self.lot_size,
23
+ listing_type: self.listing_type.to_s.split(";").join("; "),
24
+ timeframe: self.timeframe,
25
+ gagrage: self.gagrage,
26
+ pets: self.pets,
27
+ view: self.view
28
+ }
29
+ end
30
+
31
+ end
@@ -0,0 +1,14 @@
1
+ class RequestShowing < ActiveRecord::Base
2
+
3
+ self.table_name = "request_showings"
4
+ self.primary_key = 'id'
5
+
6
+ has_many :sharings, :foreign_key => "request_id"
7
+ belongs_to :customer
8
+
9
+ belongs_to :wishlist, :class_name => "Wishlist", :foreign_key => "attached_wishlist"
10
+
11
+ def describe_id
12
+ "RequestShowing ##{id}"
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ class SchemaMigration < ActiveRecord::Base
2
+
3
+ self.table_name = "schema_migrations"
4
+ self.primary_key = 'id'
5
+
6
+ end
@@ -0,0 +1,28 @@
1
+ class SellingWishlist < ActiveRecord::Base
2
+
3
+ self.table_name = "selling_wishlists"
4
+ self.primary_key = 'id'
5
+
6
+ has_one :wishlist, foreign_key: "id"
7
+ belongs_to :property_type, :inverse_of => :selling_wishlists
8
+
9
+ def show_details
10
+ {
11
+ id: self.id,
12
+ name: self.name,
13
+ property_type_id: self.property_type_id,
14
+ listing_status: self.listing_status,
15
+ relationship: self.relationship,
16
+ planning_to_sell: self.planning_to_sell,
17
+ resident_status: self.resident_status,
18
+ beds_number: self.beds_number,
19
+ baths_number: self.baths_number,
20
+ square_footage: self.square_footage,
21
+ built_year: self.built_year,
22
+ lot_size: self.lot_size,
23
+ timeframe: self.timeframe,
24
+ interested_in: self.interested_in
25
+ }
26
+ end
27
+
28
+ end
@@ -0,0 +1,6 @@
1
+ class Setting < ActiveRecord::Base
2
+
3
+ self.table_name = "settings"
4
+ self.primary_key = 'id'
5
+
6
+ end
@@ -0,0 +1,15 @@
1
+ class Sharing < ActiveRecord::Base
2
+
3
+ self.table_name = "sharings"
4
+ self.primary_key = 'id'
5
+
6
+ has_one :acceptance, :inverse_of => :sharing
7
+ has_many :connections, :dependent => :delete_all, foreign_key: "sharing_id"
8
+ belongs_to :wishlist, :inverse_of => :sharings, foreign_key: "wishlist_id"
9
+ belongs_to :request_showing, :foreign_key => "request_id"
10
+
11
+ def describe_id
12
+ "Sharing ##{id}"
13
+ end
14
+
15
+ end
@@ -0,0 +1,25 @@
1
+ class Specialty < ActiveRecord::Base
2
+
3
+ self.table_name = "specialties"
4
+ self.primary_key = 'id'
5
+
6
+ has_many :agent_specialties, :inverse_of => :specialty
7
+
8
+ # Get All Specialties
9
+ def self.get_all_specialties
10
+ Hash[*Specialty.pluck(:id, :name).flatten]
11
+ end
12
+
13
+ # Get Agent's specialties
14
+ def self.get_agent_specialties(agent)
15
+ Hash[*AgentSpecialty.where(agent_id: agent.id).joins(:specialty).pluck(:specialty_id, :name).flatten]
16
+ end
17
+
18
+ #rails_admin do
19
+
20
+ #configure :agent_specialties do
21
+ #visible(false)
22
+ #end
23
+
24
+ #end
25
+ end
@@ -0,0 +1,21 @@
1
+ class State < ActiveRecord::Base
2
+
3
+ self.table_name = "states"
4
+ self.primary_key = 'id'
5
+ # has_many :licenses, :class_name => "State", :foreign_key => "id"
6
+
7
+ def name
8
+ state_name
9
+ end
10
+
11
+ # Get All States
12
+ def self.get_all_states
13
+ State.pluck(:id, :state_code, :state_name).map{|id, code, name| {id: id, code: code, name: name}}
14
+ end
15
+
16
+ #rails_admin do
17
+ #configure :agents do
18
+ #visible(false)
19
+ #end
20
+ #end
21
+ end
@@ -0,0 +1,10 @@
1
+ class Suggestion < ActiveRecord::Base
2
+
3
+ self.table_name = "suggestions"
4
+ self.primary_key = 'id'
5
+
6
+ belongs_to :user
7
+ def describe_id
8
+ "Suggestion ##{id}"
9
+ end
10
+ end
@@ -0,0 +1,107 @@
1
+ class User < ActiveRecord::Base
2
+ self.table_name = "users"
3
+ self.primary_key = 'id'
4
+
5
+ has_one :agent, :dependent => :destroy, :inverse_of => :user
6
+ has_one :customer, :dependent => :destroy, :inverse_of => :user
7
+ has_many :issues, :inverse_of => :user
8
+ has_many :suggestions, :inverse_of => :user
9
+ has_many :customer_devices, :inverse_of => :user
10
+ has_many :customer_location_alerts, :inverse_of => :user
11
+ has_many :agent_change_info, :inverse_of => :user
12
+
13
+ accepts_nested_attributes_for :customer, :agent
14
+
15
+ #rails_admin do
16
+ #configure :customer do
17
+ #visible(false)
18
+ #end
19
+
20
+ #configure :agent do
21
+ #visible(false)
22
+ #end
23
+ #end
24
+
25
+
26
+ def name
27
+ "#{email}"
28
+ end
29
+
30
+ def role
31
+ if self.customer.present?
32
+ return I18n.t 'customer'
33
+ elsif self.agent.present?
34
+ return I18n.t 'agent'
35
+ else
36
+ return 'admin'
37
+ end
38
+ end
39
+
40
+ def valid_device_token(device_token, device_type)
41
+ device_verified=false;
42
+ #return device_verified;
43
+ if(device_type && device_type && !device_type.blank? && !device_token.blank?)
44
+ customer_devices = self.customer_devices.where(:device_type => device_type, :device_token =>device_token)
45
+ if customer_devices.count > 0
46
+ device_verified=true;
47
+ else
48
+ customer = self.customer;
49
+ #return customer.id;
50
+ customer.update_attributes(:phone_verified => false)
51
+ device_verified =false;
52
+ end
53
+ end
54
+ return device_verified;
55
+ end
56
+
57
+ def generate_endpoint_arn(token, device_type)
58
+ sns = Aws::SNS::Client.new
59
+ begin
60
+ if self.role =='agent'
61
+ if device_type == "Android"
62
+ endpoint = sns.create_platform_endpoint(
63
+ platform_application_arn:'arn:aws:sns:us-west-2:126524593432:app/GCM/Agento_Floortime',
64
+ token:token)
65
+ else
66
+ endpoint = sns.create_platform_endpoint(
67
+ platform_application_arn:'arn:aws:sns:us-west-2:126524593432:app/APNS_SANDBOX/Agento_Floortime_iOS',
68
+ token: token)
69
+ end
70
+ elsif self.role =='customer'
71
+ if device_type == "Android"
72
+ endpoint = sns.create_platform_endpoint(
73
+ platform_application_arn:'arn:aws:sns:us-west-2:126524593432:app/GCM/Agento_Customer',
74
+ token:token)
75
+ else
76
+ endpoint = sns.create_platform_endpoint(
77
+ platform_application_arn:'arn:aws:sns:us-west-2:126524593432:app/APNS_SANDBOX/Agento_Customer_iOS',
78
+ token: token)
79
+ end
80
+ else
81
+ p "unknown"
82
+ end
83
+
84
+
85
+ rescue Exception => e
86
+ p e
87
+ return false
88
+ end
89
+ return endpoint.endpoint_arn
90
+ end
91
+
92
+ def add_device(endpoint_arn, device_type, device_token)
93
+ begin
94
+ customer_device = CustomerDevice.find_or_initialize_by(endpoint_arn: endpoint_arn)
95
+ customer_device.endpoint_arn = endpoint_arn
96
+ customer_device.device_type = device_type
97
+ customer_device.device_token = device_token
98
+ customer_device.user_id = self.id
99
+ customer_device.save
100
+ return true
101
+ rescue Exception => e
102
+
103
+ return false
104
+ end
105
+ end
106
+
107
+ end