kirgudu_common 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/kirgudu_common/application.js +13 -0
  6. data/app/assets/stylesheets/kirgudu_common/application.css +15 -0
  7. data/app/helpers/kirgudu_common/application_helper.rb +4 -0
  8. data/app/models/kirgudu_common/concerns/models/administrated_by.rb +27 -0
  9. data/app/models/kirgudu_common/concerns/models/created_at.rb +36 -0
  10. data/app/models/kirgudu_common/concerns/models/created_by.rb +25 -0
  11. data/app/models/kirgudu_common/concerns/models/deletion_status_id.rb +28 -0
  12. data/app/models/kirgudu_common/concerns/models/id.rb +24 -0
  13. data/app/models/kirgudu_common/concerns/models/is_active.rb +24 -0
  14. data/app/models/kirgudu_common/concerns/models/managed_by.rb +25 -0
  15. data/app/models/kirgudu_common/concerns/models/name.rb +36 -0
  16. data/app/models/kirgudu_common/concerns/models/order_by.rb +21 -0
  17. data/app/models/kirgudu_common/concerns/models/owned_by.rb +26 -0
  18. data/app/models/kirgudu_common/concerns/models/person_age.rb +49 -0
  19. data/app/models/kirgudu_common/concerns/models/person_full_name.rb +41 -0
  20. data/app/models/kirgudu_common/concerns/models/portal_id.rb +26 -0
  21. data/app/models/kirgudu_common/concerns/models/portal_user_id.rb +26 -0
  22. data/app/models/kirgudu_common/concerns/models/slug.rb +43 -0
  23. data/app/models/kirgudu_common/concerns/models/status_id.rb +28 -0
  24. data/app/models/kirgudu_common/concerns/models/title.rb +40 -0
  25. data/app/models/kirgudu_common/concerns/models/updated_at.rb +41 -0
  26. data/app/models/kirgudu_common/concerns/models/updated_by.rb +29 -0
  27. data/app/models/kirgudu_common/concerns/models/user_id.rb +35 -0
  28. data/app/models/kirgudu_common/portal.rb +78 -0
  29. data/app/models/kirgudu_common/portal_user.rb +54 -0
  30. data/app/models/kirgudu_common/user.rb +104 -0
  31. data/app/models/kirgudu_common/view_template.rb +6 -0
  32. data/app/models/kirgudu_common/view_template_element.rb +6 -0
  33. data/app/views/layouts/kirgudu_common/application.html.erb +14 -0
  34. data/config/routes.rb +2 -0
  35. data/db/migrate/20130913084129_create_kirgudu_common_users.rb +55 -0
  36. data/db/migrate/20131114161828_create_kirgudu_common_view_templates.rb +30 -0
  37. data/db/migrate/20131114165013_create_kirgudu_common_view_template_elements.rb +34 -0
  38. data/db/migrate/20140208133148_create_kirgudu_common_portals.rb +37 -0
  39. data/db/migrate/20140208134642_create_kirgudu_common_portal_users.rb +23 -0
  40. data/lib/kirgudu_common/engine.rb +5 -0
  41. data/lib/kirgudu_common.rb +4 -0
  42. data/lib/tasks/kirgudu_common_tasks.rake +4 -0
  43. data/test/dummy/README.rdoc +28 -0
  44. data/test/dummy/Rakefile +6 -0
  45. data/test/dummy/app/assets/javascripts/application.js +13 -0
  46. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  47. data/test/dummy/app/controllers/application_controller.rb +5 -0
  48. data/test/dummy/app/helpers/application_helper.rb +2 -0
  49. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  50. data/test/dummy/bin/bundle +3 -0
  51. data/test/dummy/bin/rails +4 -0
  52. data/test/dummy/bin/rake +4 -0
  53. data/test/dummy/config/application.rb +23 -0
  54. data/test/dummy/config/boot.rb +5 -0
  55. data/test/dummy/config/database.yml +25 -0
  56. data/test/dummy/config/environment.rb +5 -0
  57. data/test/dummy/config/environments/development.rb +37 -0
  58. data/test/dummy/config/environments/production.rb +82 -0
  59. data/test/dummy/config/environments/test.rb +39 -0
  60. data/test/dummy/config/initializers/assets.rb +8 -0
  61. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  62. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  63. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  64. data/test/dummy/config/initializers/inflections.rb +16 -0
  65. data/test/dummy/config/initializers/mime_types.rb +4 -0
  66. data/test/dummy/config/initializers/session_store.rb +3 -0
  67. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  68. data/test/dummy/config/locales/en.yml +23 -0
  69. data/test/dummy/config/routes.rb +4 -0
  70. data/test/dummy/config/secrets.yml +22 -0
  71. data/test/dummy/config.ru +4 -0
  72. data/test/dummy/public/404.html +67 -0
  73. data/test/dummy/public/422.html +67 -0
  74. data/test/dummy/public/500.html +66 -0
  75. data/test/dummy/public/favicon.ico +0 -0
  76. data/test/integration/navigation_test.rb +10 -0
  77. data/test/kirgudu_common_test.rb +7 -0
  78. data/test/test_helper.rb +15 -0
  79. metadata +199 -0
@@ -0,0 +1,104 @@
1
+ module KirguduCommon
2
+ class User < ::KirguduBase::BaseModel
3
+
4
+ ##################################### RELATIONS #################################
5
+
6
+
7
+ ##################################### VALIDATIONS #################################
8
+
9
+ validates_presence_of :email
10
+ validates_uniqueness_of :email, case_sensitive: false
11
+ validates_email_format_of :email, allow_blank: true
12
+ validates_length_of :email, maximum: 128, allow_blank: true
13
+
14
+ validates_length_of :phone, maximum: 20, allow_blank: true
15
+
16
+ validates_presence_of :first_name
17
+ validates_length_of :first_name, maximum: 128, allow_blank: true
18
+
19
+ validates_presence_of :password, only: [:create, :password_set]
20
+ validates_confirmation_of :password, only: [:create, :password_set]
21
+
22
+
23
+ validates_length_of :last_name, maximum: 128, allow_blank: true
24
+ validates_length_of :middle_name, maximum: 128, allow_blank: true
25
+
26
+ validates_length_of :city_name, maximum: 128, allow_blank: true
27
+
28
+
29
+ ##################################### SCOPES #################################
30
+
31
+ scope :with_keyword, lambda { |value|
32
+ if value
33
+ value = value.gsub('%', '')
34
+ like_value = "%#{value}%"
35
+ where { (first_name.like like_value) | (last_name.like like_value) }
36
+ end
37
+ }
38
+
39
+
40
+ def self.apply_filters_to_query(query, filters={})
41
+ filters ||= {}
42
+
43
+ filters.merge!({
44
+ order:
45
+ {
46
+ last_name: :asc,
47
+ first_name: :asc
48
+ }
49
+ })
50
+
51
+
52
+ super(query, filters)
53
+ end
54
+
55
+
56
+ ##################################### DATABASE METHODS #################################
57
+
58
+ def self.get_by_email(email)
59
+ self.where(email: email.to_s.strip).first if email
60
+ end
61
+
62
+ def self.get_by_phone(phone)
63
+ self.where(phone: phone.to_s.strip).first if phone
64
+ end
65
+
66
+ def self.get_by_email_or_phone(username)
67
+ if username
68
+ username = username.to_s.strip
69
+ self.where { (phone == username) | (email == username) }.first
70
+ end
71
+ end
72
+
73
+
74
+ ##################################### METHODS #################################
75
+
76
+ def full_name
77
+ nm = self.first_name
78
+ if self.last_name
79
+ nm = "#{self.last_name} #{nm}"
80
+ end
81
+ nm
82
+ end
83
+
84
+ def status_name
85
+ #
86
+ end
87
+
88
+ def name_for_breadcrumbs
89
+ self.full_name
90
+ end
91
+
92
+ def to_s
93
+ self.full_name
94
+ end
95
+
96
+
97
+ def as_json(options = {})
98
+ super(merge_options_for_json(options, {
99
+ :methods => [:full_name],
100
+ except: [:password]
101
+ }))
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,6 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module KirguduCommon
3
+ class ViewTemplate < ::KirguduBase::BaseModel
4
+ #attr_accessible :author, :description, :name, :section_id, :version
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module KirguduCommon
3
+ class ViewTemplateElement < ::KirguduBase::BaseModel
4
+ #attr_accessible :cache_file_path, :content, :description, :element_type_id, :name, :path
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>KirguduCommon</title>
5
+ <%= stylesheet_link_tag "kirgudu_common/application", media: "all" %>
6
+ <%= javascript_include_tag "kirgudu_common/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ KirguduCommon::Engine.routes.draw do
2
+ end
@@ -0,0 +1,55 @@
1
+ class CreateKirguduCommonUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :kirgudu_common_users do |t|
4
+ t.string :email, limit: 128, null: false
5
+ t.string :phone, limit: 20
6
+ t.string :password, limit: 128, null: false
7
+
8
+ t.string :first_name, limit: 128, null: false
9
+ t.string :last_name, limit: 128
10
+ t.string :middle_name, limit: 128
11
+
12
+
13
+ t.date :birth_date
14
+ t.string :country_id, limit: 36
15
+ t.string :state_id, limit: 36
16
+ t.string :city_id, limit: 36
17
+ t.string :city_name, limit: 128
18
+
19
+
20
+ t.datetime :latest_request_at
21
+ t.datetime :previous_login_at
22
+ t.string :previous_login_ip, limit: 15
23
+ t.datetime :current_login_at
24
+ t.string :current_login_ip, limit: 15
25
+
26
+ t.datetime :logoff_all_devices_at
27
+
28
+ t.boolean :is_system, null: false, default: false
29
+ t.integer :deletion_status_id, limit: 8, null: false, default: 1
30
+
31
+ t.boolean :email_verified, null: false, default: false
32
+ t.datetime :email_verified_at
33
+
34
+ t.timestamps
35
+ end
36
+
37
+ add_index :kirgudu_common_users, :phone, name: "idx_kirgudu_common_users_phone"
38
+ add_index :kirgudu_common_users, :email, name: "idx_kirgudu_common_users_email"
39
+
40
+ add_index :kirgudu_common_users, :first_name, name: "idx_kirgudu_common_users_first_name"
41
+ add_index :kirgudu_common_users, :middle_name, name: "idx_kirgudu_common_users_middle_name"
42
+ add_index :kirgudu_common_users, :last_name, name: "idx_kirgudu_common_users_last_name"
43
+ add_index :kirgudu_common_users, :birth_date, name: "idx_kirgudu_common_users_birth_date"
44
+ add_index :kirgudu_common_users, :country_id, name: "idx_kirgudu_common_users_"
45
+ add_index :kirgudu_common_users, :state_id, name: "idx_kirgudu_common_users_state_id"
46
+ add_index :kirgudu_common_users, :city_id, name: "idx_kirgudu_common_users_city_id"
47
+ add_index :kirgudu_common_users, :city_name, name: "idx_kirgudu_common_users_city_name"
48
+
49
+ add_index :kirgudu_common_users, :is_system, name: "idx_kirgudu_common_users_is_system"
50
+ add_index :kirgudu_common_users, :deletion_status_id, name: "idx_kirgudu_common_users_del_sts_id"
51
+
52
+ add_index :kirgudu_common_users, :email_verified, name: "idx_kirgudu_common_users_email_verified"
53
+ add_index :kirgudu_common_users, :email_verified_at, name: "idx_kirgudu_common_users_email_verified_at"
54
+ end
55
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class CreateKirguduCommonViewTemplates < ActiveRecord::Migration
3
+ def change
4
+ create_table :kirgudu_common_view_templates do |t|
5
+ t.integer :portal_id, limit: 8, null: false
6
+ t.string :uin, limit: 36, null: false
7
+ t.integer :created_by, limit: 8, null: false
8
+ t.integer :updated_by, limit: 8, null: false
9
+
10
+ t.string :name, limit: 128, null: false
11
+ t.string :author, limit: 128, null: false
12
+ t.string :version, limit: 20, null: false
13
+ t.string :website, limit: 256
14
+ t.text :description
15
+
16
+ t.integer :deletion_status_id, limit: 8, null: false, default: 0
17
+
18
+ t.timestamps
19
+ end
20
+ add_index :kirgudu_common_view_templates, :name
21
+
22
+ add_index :kirgudu_common_view_templates, :created_by
23
+ add_index :kirgudu_common_view_templates, :created_at
24
+ add_index :kirgudu_common_view_templates, :updated_by
25
+ add_index :kirgudu_common_view_templates, :updated_at
26
+ add_index :kirgudu_common_view_templates, :portal_id
27
+ add_index :kirgudu_common_view_templates, :uin
28
+ add_index :kirgudu_common_view_templates, :deletion_status_id
29
+ end
30
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class CreateKirguduCommonViewTemplateElements < ActiveRecord::Migration
3
+ def change
4
+ create_table :kirgudu_common_view_template_elements do |t|
5
+ t.integer :created_by, limit: 8, null: false
6
+ t.integer :updated_by, limit: 8, null: false
7
+
8
+ t.integer :templates_id, limit: 8, null: false
9
+
10
+ t.string :path, limit: 128, null: false
11
+ t.string :name, limit: 128, null: false
12
+ t.integer :element_type_id, limit: 8, null: false
13
+ t.string :cache_file_path, limit: 256
14
+ t.text :content
15
+ t.text :description
16
+
17
+ t.integer :deletion_status_id, limit: 8, null: false, default: 0
18
+
19
+ t.timestamps
20
+ end
21
+ add_index :kirgudu_common_view_template_elements, :element_type_id
22
+ add_index :kirgudu_common_view_template_elements, :path
23
+ add_index :kirgudu_common_view_template_elements, :name
24
+
25
+ add_index :kirgudu_common_view_template_elements, :created_by
26
+ add_index :kirgudu_common_view_template_elements, :created_at
27
+ add_index :kirgudu_common_view_template_elements, :updated_by
28
+ add_index :kirgudu_common_view_template_elements, :updated_at
29
+
30
+ add_index :kirgudu_common_view_template_elements, :templates_id
31
+
32
+ add_index :kirgudu_common_view_template_elements, :deletion_status_id
33
+ end
34
+ end
@@ -0,0 +1,37 @@
1
+ class CreateKirguduCommonPortals < ActiveRecord::Migration
2
+ def change
3
+ create_table :kirgudu_common_portals do |t|
4
+ t.string :uin, limit: 36, null: false
5
+ t.integer :created_by, limit: 8, null: false
6
+ t.integer :updated_by, limit: 8, null: false
7
+ t.integer :owned_by, limit: 8, null: false
8
+ t.datetime :owned_at
9
+ t.integer :administrated_by, limit: 8, null: false
10
+ t.datetime :administrator_at
11
+
12
+ t.string :dns_name, limit: 180, null: false
13
+ t.string :name, limit: 180, null: false
14
+ t.text :description
15
+
16
+ t.integer :deletion_status_id, limit: 8, null: false, default: 1
17
+
18
+ t.timestamps
19
+ end
20
+
21
+ add_index :kirgudu_common_portals, :dns_name, name: "idx_krgd_bs_cmn_prtls_dns_name"
22
+ add_index :kirgudu_common_portals, :name, name: "idx_krgd_bs_cmn_prtls_name"
23
+
24
+ add_index :kirgudu_common_portals, :created_by, name: "idx_krgd_bs_cmn_prtls_crtd_by"
25
+ add_index :kirgudu_common_portals, :created_at, name: "idx_krgd_bs_cmn_prtls_crtd_at"
26
+ add_index :kirgudu_common_portals, :updated_by, name: "idx_krgd_bs_cmn_prtls_updt_by"
27
+ add_index :kirgudu_common_portals, :updated_at, name: "idx_krgd_bs_cmn_prtls_updt_at"
28
+ add_index :kirgudu_common_portals, :owned_by, name: "idx_krgd_bs_cmn_prtls_ownd_by"
29
+ add_index :kirgudu_common_portals, :owned_at, name: "idx_krgd_bs_cmn_prtls_ownd_at"
30
+ add_index :kirgudu_common_portals, :administrated_by, name: "idx_krgd_bs_cmn_prtls_adm_by"
31
+ add_index :kirgudu_common_portals, :administrator_at, name: "idx_krgd_bs_cmn_prtls_adm_at"
32
+
33
+ add_index :kirgudu_common_portals, :uin, name: "idx_krgd_bs_cmn_prtls_uin"
34
+ add_index :kirgudu_common_portals, :deletion_status_id, name: "idx_krgd_bs_cmn_prtls_dlt_sts_id"
35
+
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ class CreateKirguduCommonPortalUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :kirgudu_common_portal_users do |t|
4
+ t.string :created_by, limit: 8
5
+ t.string :updated_by, limit: 8
6
+ t.string :uin, limit: 36, null: false
7
+ t.integer :portal_id, limit: 8, null: false
8
+ t.integer :user_id, limit: 8, null: false
9
+ t.integer :status_id, limit: 8, null: false, default: 0
10
+ t.integer :deletion_status_id, limit: 8, null: false, default: 1
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :kirgudu_common_portal_users, :uin
16
+ add_index :kirgudu_common_portal_users, :portal_id
17
+ add_index :kirgudu_common_portal_users, :user_id
18
+ add_index :kirgudu_common_portal_users, :status_id
19
+ add_index :kirgudu_common_portal_users, :deletion_status_id
20
+ add_index :kirgudu_common_portal_users, :created_by
21
+ add_index :kirgudu_common_portal_users, :updated_by
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module KirguduCommon
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace KirguduCommon
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require "kirgudu_common/engine"
2
+
3
+ module KirguduCommon
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :kirgudu_common do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>