citygate 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/README.rdoc +11 -0
  2. data/app/assets/javascripts/citygate/admin_users.coffee +1 -1
  3. data/app/assets/javascripts/citygate/jquery.pjax.js +4 -2
  4. data/app/assets/javascripts/citygate.js +16 -0
  5. data/app/assets/stylesheets/citygate/{application.css.scss → application.css} +0 -0
  6. data/app/assets/stylesheets/citygate/main.sass +0 -9
  7. data/app/controllers/citygate/admin/application_controller.rb +3 -1
  8. data/app/controllers/citygate/admin/users_controller.rb +4 -4
  9. data/app/controllers/citygate/application_controller.rb +4 -2
  10. data/app/controllers/citygate/users/omniauth_callbacks_controller.rb +13 -12
  11. data/app/models/citygate/permission.rb +7 -0
  12. data/app/models/citygate/role.rb +2 -1
  13. data/app/models/citygate/user.rb +24 -4
  14. data/app/views/citygate/admin/users/index.html.erb +3 -3
  15. data/app/views/citygate/admin/users/show.html.erb +12 -3
  16. data/app/views/citygate/home/index.html.erb +4 -5
  17. data/app/views/citygate/shared/_navigation.html.erb +18 -18
  18. data/app/views/citygate/users/show.html.erb +6 -4
  19. data/app/views/devise/confirmations/new.html.erb +12 -0
  20. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  21. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  22. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  23. data/app/views/devise/passwords/edit.html.erb +16 -0
  24. data/app/views/devise/passwords/new.html.erb +12 -0
  25. data/app/views/devise/registrations/edit.html.erb +33 -30
  26. data/app/views/devise/registrations/new.html.erb +10 -10
  27. data/app/views/devise/sessions/new.html.erb +18 -0
  28. data/app/views/devise/{_links.erb → shared/_links.erb} +7 -7
  29. data/app/views/devise/unlocks/new.html.erb +12 -0
  30. data/app/views/layouts/admin/application.html.erb +2 -2
  31. data/config/accounts.yml +1 -3
  32. data/config/initializers/devise.rb +1 -1
  33. data/config/locales/defaults/en.yml +2 -0
  34. data/config/locales/models/user/en.yml +4 -0
  35. data/config/locales/navigation/en.yml +12 -0
  36. data/config/locales/shared/cancan/en.yml +3 -0
  37. data/config/locales/{devise.en.yml → shared/devise/devise.en.yml} +0 -0
  38. data/config/locales/{devise_invitable.en.yml → shared/devise/devise_invitable.en.yml} +0 -0
  39. data/config/locales/views/admin/users/en.yml +32 -0
  40. data/db/migrate/20120303195103_add_name_to_users.rb +2 -1
  41. data/db/migrate/20120727143920_create_permissions_table.rb +12 -0
  42. data/db/seeds.rb +14 -0
  43. data/lib/ability.rb +53 -0
  44. data/lib/citygate/engine.rb +10 -0
  45. data/lib/citygate/version.rb +1 -1
  46. data/spec/dummy/README.rdoc +261 -0
  47. data/spec/dummy/Rakefile +30 -0
  48. data/{app/assets/javascripts/citygate → spec/dummy/app/assets/javascripts}/application.js +2 -3
  49. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  50. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  51. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  52. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  53. data/spec/dummy/config/application.rb +61 -0
  54. data/spec/dummy/config/boot.rb +10 -0
  55. data/spec/dummy/config/database.yml +25 -0
  56. data/spec/dummy/config/environment.rb +5 -0
  57. data/spec/dummy/config/environments/development.rb +39 -0
  58. data/spec/dummy/config/environments/production.rb +67 -0
  59. data/spec/dummy/config/environments/test.rb +39 -0
  60. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/spec/dummy/config/initializers/inflections.rb +15 -0
  62. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  63. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  64. data/spec/dummy/config/initializers/session_store.rb +8 -0
  65. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/{config → spec/dummy/config}/locales/en.yml +0 -0
  67. data/spec/dummy/config/routes.rb +3 -0
  68. data/spec/dummy/config.ru +4 -0
  69. data/spec/dummy/db/development.sqlite3 +0 -0
  70. data/spec/dummy/db/migrate/20120706095546_devise_create_users.citygate.rb +50 -0
  71. data/spec/dummy/db/migrate/20120706095547_add_name_to_users.citygate.rb +7 -0
  72. data/spec/dummy/db/migrate/20120706095548_add_confirmable_to_users.citygate.rb +12 -0
  73. data/spec/dummy/db/migrate/20120706095549_devise_invitable_add_to_users.citygate.rb +24 -0
  74. data/spec/dummy/db/migrate/20120706095550_add_omniauth_to_devise.citygate.rb +20 -0
  75. data/spec/dummy/db/migrate/20120706095551_create_roles.citygate.rb +11 -0
  76. data/spec/dummy/db/migrate/20120727145840_create_permissions_table.citygate.rb +13 -0
  77. data/spec/dummy/db/production.sqlite3 +0 -0
  78. data/spec/dummy/db/schema.rb +79 -0
  79. data/spec/dummy/db/seeds.rb +1 -0
  80. data/spec/dummy/db/test.sqlite3 +0 -0
  81. data/spec/dummy/features/step_definitions/email_steps.rb +206 -0
  82. data/spec/dummy/features/step_definitions/user_steps.rb +249 -0
  83. data/spec/dummy/features/support/email_spec.rb +1 -0
  84. data/spec/dummy/features/support/env.rb +107 -0
  85. data/spec/dummy/features/support/hooks.rb +0 -0
  86. data/spec/dummy/features/support/paths.rb +46 -0
  87. data/spec/dummy/features/users/login_omniauth.feature +19 -0
  88. data/spec/dummy/features/users/sign_in.feature +40 -0
  89. data/spec/dummy/features/users/sign_out.feature +11 -0
  90. data/spec/dummy/features/users/sign_up.feature +27 -0
  91. data/spec/dummy/features/users/user_edit.feature +9 -0
  92. data/spec/dummy/features/users/users_admin.feature +44 -0
  93. data/spec/dummy/log/development.log +18417 -0
  94. data/spec/dummy/log/test.log +59087 -0
  95. data/spec/dummy/public/404.html +26 -0
  96. data/spec/dummy/public/422.html +26 -0
  97. data/spec/dummy/public/500.html +25 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/dummy/script/rails +6 -0
  100. data/spec/dummy/spec/controllers/admin/admin_controller_spec.rb +10 -0
  101. data/spec/dummy/spec/controllers/admin/users_spec.rb +15 -0
  102. data/spec/dummy/spec/controllers/home_controller_spec.rb +12 -0
  103. data/spec/dummy/spec/controllers/omniauth_spec.rb +73 -0
  104. data/spec/dummy/spec/factories.rb +33 -0
  105. data/spec/dummy/spec/javascripts/UserSpec.js +14 -0
  106. data/spec/dummy/spec/javascripts/fixtures/user_listing.html +20 -0
  107. data/spec/dummy/spec/javascripts/helpers/SpecHelper.js +9 -0
  108. data/spec/dummy/spec/javascripts/helpers/jasmine-jquery.js +306 -0
  109. data/spec/dummy/spec/javascripts/helpers/jquery.min.js +4 -0
  110. data/spec/dummy/spec/javascripts/support/jasmine.yml +19 -0
  111. data/spec/dummy/spec/models/user_spec.rb +100 -0
  112. data/spec/dummy/spec/routing/routing_spec.rb +22 -0
  113. data/spec/dummy/spec/spec_helper.rb +79 -0
  114. data/spec/dummy/spec/support/devise.rb +3 -0
  115. data/spec/dummy/tmp/cache/assets/C63/E40/sprockets%2F36a675f52eb281488964b58be8971051 +0 -0
  116. data/spec/dummy/tmp/cache/assets/C79/FC0/sprockets%2F76c2f8ffd1175afd6274640057134300 +0 -0
  117. data/spec/dummy/tmp/cache/assets/C7A/CE0/sprockets%2F9124c83a02e7332a90b2883b69f81d04 +0 -0
  118. data/spec/dummy/tmp/cache/assets/C89/540/sprockets%2F606a455261f8f047c994c4b9a582f126 +0 -0
  119. data/spec/dummy/tmp/cache/assets/CC5/020/sprockets%2Ffa39f3f719158fea829829617391b42c +0 -0
  120. data/spec/dummy/tmp/cache/assets/CD6/2B0/sprockets%2F08e01b4122e606428c6de7234d87bee1 +0 -0
  121. data/spec/dummy/tmp/cache/assets/CD8/070/sprockets%2F3afc9406d6d06c238a33603363af8a66 +0 -0
  122. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  123. data/spec/dummy/tmp/cache/assets/CE2/7D0/sprockets%2Fe69b8c4ca0800c940d1d9785f1a92327 +0 -0
  124. data/spec/dummy/tmp/cache/assets/CE8/510/sprockets%2F0d85ab6e3972f70636a990e91fec8301 +0 -0
  125. data/spec/dummy/tmp/cache/assets/CF6/500/sprockets%2Fe48376f3339fc2f84ac25d713936ea99 +0 -0
  126. data/spec/dummy/tmp/cache/assets/D0D/DE0/sprockets%2Fa35442f02b0b2479f22d83d639d8c4fd +0 -0
  127. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  128. data/spec/dummy/tmp/cache/assets/D3E/710/sprockets%2F93251497334cafddb54ecc36a332f5b9 +0 -0
  129. data/spec/dummy/tmp/cache/assets/D48/410/sprockets%2Fa18aa9c28f587c76e162489eb19f2a2a +0 -0
  130. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  131. data/spec/dummy/tmp/cache/assets/D53/840/sprockets%2Ff753499d8cefbb5a8450ca97540ff275 +0 -0
  132. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  133. data/spec/dummy/tmp/cache/assets/D72/580/sprockets%2F02aed4ae7c633d6d577280de93c4c7c6 +0 -0
  134. data/spec/dummy/tmp/cache/assets/D73/010/sprockets%2F834fa37dfa7f28148e125baf3f9d91b0 +0 -0
  135. data/spec/dummy/tmp/cache/assets/D75/530/sprockets%2F6a480d7952fbe8ce5c2eaad0369f7271 +0 -0
  136. data/spec/dummy/tmp/cache/assets/D78/BD0/sprockets%2Fd0c9ac69560ea197444b7f759ecd06da +0 -0
  137. data/spec/dummy/tmp/cache/assets/D9B/0B0/sprockets%2F609a6d0b06eb3752679f6e1f0adcb4fc +0 -0
  138. data/spec/dummy/tmp/cache/assets/D9E/F10/sprockets%2F9ab223df888d724dcad09eb1163cc5f4 +0 -0
  139. data/spec/dummy/tmp/cache/assets/D9E/F70/sprockets%2Fc5d4a6e7d907804c52cbf910339dafdb +0 -0
  140. data/spec/dummy/tmp/cache/assets/DB9/2A0/sprockets%2F0a7332e4e1420de7165bd13ecffca4cc +0 -0
  141. data/spec/dummy/tmp/cache/assets/DC2/210/sprockets%2Ff0049a44fff3a6ea3a55283aceb06fb4 +0 -0
  142. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  143. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  144. data/spec/dummy/tmp/cache/assets/E0B/AF0/sprockets%2Ff71f3afdedf8ab892f147a5facc07488 +0 -0
  145. data/spec/dummy/tmp/cache/assets/E2B/670/sprockets%2Feac21904ecb266ce92aecadb8681b7fe +0 -0
  146. data/spec/spec_helper.rb +33 -0
  147. metadata +267 -41
  148. data/app/models/citygate/ability.rb +0 -31
data/README.rdoc CHANGED
@@ -46,6 +46,16 @@ In case of development add this to +config/environments/development.rb+
46
46
 
47
47
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
48
48
 
49
+ == OmniAuth Configuration
50
+
51
+ Citygate needs your facebook apps identifiers which are loaded from a file you must create called +config/accounts.yml+ and has the following format:
52
+
53
+ facebook:
54
+ app_id: "your app id from https://developers.facebook.com/apps"
55
+ app_secret: "your app secret from https://developers.facebook.com/apps"
56
+
57
+ In case you are wondering, the reason it is not required for you to add your google OAuth identifier is because it is the same for everyone. It then redirects you to a authentication service within google servers.
58
+
49
59
  == Citygate Options
50
60
 
51
61
  You can change citygate's defaults by editing your +config/application.rb+ file like so
@@ -60,6 +70,7 @@ The available options are:
60
70
 
61
71
  will_paginate_options:: an hash with any option supported by paginate[https://github.com/mislav/will_paginate/wiki]
62
72
  mount_path:: if you mount the engine in any other path than "/", must define it here as well so that omniauth can be aware of it
73
+ no_of_users:: limit the number of users allowed in your system
63
74
 
64
75
  == Running Citygate
65
76
 
@@ -1,2 +1,2 @@
1
1
  $ ->
2
- $("a").pjax("[data-pjax-container]")
2
+ $("a").pjax("#container").on 'click'
@@ -154,6 +154,8 @@ var pjax = $.pjax = function( options ) {
154
154
 
155
155
  xhr.setRequestHeader('X-PJAX', 'true')
156
156
  xhr.setRequestHeader('X-PJAX-Container', context.selector)
157
+ if(!settings.push)
158
+ xhr.setRequestHeader('X-PJAX-layout','true')
157
159
 
158
160
  var result
159
161
 
@@ -600,7 +602,7 @@ $(window).bind('popstate', function(event){
600
602
  id: state.id,
601
603
  url: state.url,
602
604
  container: container,
603
- push: true,
605
+ push: false,
604
606
  fragment: state.fragment,
605
607
  timeout: state.timeout,
606
608
  scrollTo: false
@@ -685,4 +687,4 @@ if ( !$.support.pjax ) {
685
687
  $.fn.pjax = function() { return this }
686
688
  }
687
689
 
688
- })(jQuery);
690
+ })(jQuery);
@@ -0,0 +1,16 @@
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
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require ./citygate/jquery.pjax
16
+ //= require ./citygate/admin_users
@@ -1,12 +1,3 @@
1
- body
2
- background-color: #FFF
3
-
4
-
5
- h1
6
- color: #000
7
- font-size: 15em
8
-
9
-
10
1
  #flash_notice, #flash_alert
11
2
  padding: 5px 8px
12
3
  margin: 10px 0
@@ -4,7 +4,9 @@ class Citygate::Admin::ApplicationController < Citygate::ApplicationController
4
4
 
5
5
  private
6
6
  def set_layout
7
- if request.headers['X-PJAX']
7
+ if request.headers['X-PJAX-layout']
8
+ "admin/application"
9
+ elsif request.headers['X-PJAX']
8
10
  false
9
11
  else
10
12
  "admin/application"
@@ -4,14 +4,14 @@ class Citygate::Admin::UsersController < Citygate::Admin::ApplicationController
4
4
 
5
5
  def index
6
6
  @users = Citygate::User.paginate({page: params[:page]}.merge(Citygate::Engine.will_paginate_options))
7
-
7
+
8
8
  respond_with @users
9
9
  end
10
-
10
+
11
11
  def show
12
12
  @user = Citygate::User.find(params[:id])
13
-
13
+
14
14
  respond_with @user
15
15
  end
16
-
16
+
17
17
  end
@@ -8,12 +8,12 @@ class Citygate::ApplicationController < ::ApplicationController
8
8
  protect_from_forgery
9
9
 
10
10
  rescue_from CanCan::AccessDenied do |exception|
11
- redirect_to root_url, :alert => exception.message
11
+ redirect_to root_url, :alert => t('cancan.access_denied')
12
12
  end unless ::ApplicationController.rescue_handlers.assoc "CanCan::AccessDenied"
13
13
 
14
14
  # Gets or creates an Ability instance for usage with CanCan
15
15
  def current_ability
16
- @current_ability ||= Citygate::Ability.new(current_user)
16
+ @current_ability ||= Ability.new(current_user)
17
17
  end
18
18
 
19
19
  # Change Devise's redirect after sign in url
@@ -22,5 +22,7 @@ class Citygate::ApplicationController < ::ApplicationController
22
22
  root_url
23
23
  end
24
24
 
25
+ # Defines the omniauth prefix so that citygate can be
26
+ # mounted in anywhere
25
27
  Devise.omniauth_path_prefix = "#{Citygate::Engine.mount_path}/users/auth".squeeze "/"
26
28
  end
@@ -27,7 +27,8 @@ class Citygate::Users::OmniauthCallbacksController < Devise::OmniauthCallbacksCo
27
27
  session["devise.#{kind.downcase}_data"] = request.env["omniauth.auth"]
28
28
  sign_in_and_redirect @user, :event => :authentication
29
29
  else
30
- session["devise.#{kind.downcase}_data"] = request.env["omniauth.auth"]
30
+ @user.authorizations.map(&:destroy)
31
+ flash[:error] = @user.errors.full_messages.first
31
32
  redirect_to new_user_registration_url
32
33
  end
33
34
  end
@@ -40,20 +41,20 @@ class Citygate::Users::OmniauthCallbacksController < Devise::OmniauthCallbacksCo
40
41
  email = access_token['extra']['raw_info']['email']
41
42
  auth_attr = {
42
43
  :uid => uid,
43
- :token => access_token['credentials']['token'],
44
- :secret => nil,
45
- :name => access_token['extra']['raw_info']['name'],
46
- :link => access_token['extra']['raw_info']['link'],
44
+ :token => access_token['credentials']['token'],
45
+ :secret => nil,
46
+ :name => access_token['extra']['raw_info']['name'],
47
+ :link => access_token['extra']['raw_info']['link'],
47
48
  :image_url => access_token['info']['image']
48
49
  }
49
50
  when "Google"
50
51
  uid = access_token['uid']
51
52
  email = access_token['info']['email']
52
- auth_attr = {
53
+ auth_attr = {
53
54
  :uid => uid,
54
55
  :token => access_token['credentials']['token'],
55
- :secret => nil,
56
- :name => access_token['info']['name'],
56
+ :secret => nil,
57
+ :name => access_token['info']['name'],
57
58
  }
58
59
  else
59
60
  raise "Provider #{provider} not handled"
@@ -89,17 +90,17 @@ class Citygate::Users::OmniauthCallbacksController < Devise::OmniauthCallbacksCo
89
90
  if user = Citygate::User.find_by_email(email)
90
91
  user
91
92
  else
92
- user = Citygate::User.new(:email => email, :password => Devise.friendly_token[0,20])
93
+ user = Citygate::User.new(:email => email, :password => Devise.friendly_token[0,20])
93
94
  user.save
94
95
  end
95
96
  return user
96
97
  end
97
-
98
+
98
99
  def find_for_oauth_by_name(name, resource=nil)
99
- if user = Citygate::User.find_by_name(name)
100
+ if user = Citygate::User.find_by_first_name(name)
100
101
  user
101
102
  else
102
- user = Citygate::User.new(:name => name, :password => Devise.friendly_token[0,20], :email => "#{UUIDTools::UUID.random_create}@host")
103
+ user = Citygate::User.new(:first_name => name, :password => Devise.friendly_token[0,20], :email => "#{UUIDTools::UUID.random_create}@host")
103
104
  user.save false
104
105
  end
105
106
  return user
@@ -0,0 +1,7 @@
1
+ module Citygate
2
+ # @author Zamith
3
+ class Permission < ActiveRecord::Base
4
+ attr_accessible :action, :subject_class, :subject_id, :role_id
5
+ belongs_to :role
6
+ end
7
+ end
@@ -1,6 +1,7 @@
1
1
  module Citygate
2
2
  # @author Zamith
3
3
  class Role < ActiveRecord::Base
4
-
4
+ attr_accessible :name
5
+ has_many :permissions
5
6
  end
6
7
  end
@@ -15,10 +15,12 @@ module Citygate
15
15
  devise :encryptor => :sha1
16
16
  # @!endgroup
17
17
 
18
- attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :confirmed_at
18
+ attr_accessible :first_name, :last_name, :email, :password, :password_confirmation, :remember_me, :confirmed_at
19
19
 
20
20
  has_many :authorizations, :dependent => :destroy
21
21
  belongs_to :role
22
+
23
+ before_create :check_no_of_users
22
24
 
23
25
  # Get the json object for an user. Used by to_json.
24
26
  # @example
@@ -33,16 +35,34 @@ module Citygate
33
35
  authorization = self.authorizations.first
34
36
  {
35
37
  email: email,
36
- name: name || (authorization.name if authorization),
38
+ name: first_name || (authorization.name if authorization),
37
39
  link: (authorization.link if authorization),
38
40
  image: (authorization.image_url if authorization) || self.gravatar_url
39
41
  }
40
42
  end
41
-
43
+
42
44
  # Get the name if it is present or else get the email
43
45
  # @return [String] the name or email of the user
44
46
  def name_or_email
45
- self.name || self.email
47
+ self.full_name || self.email
48
+ end
49
+
50
+ # Get the user's full name (the concatenation of his first and last names)
51
+ # @return [String] the user's full name
52
+ def full_name
53
+ "#{self.first_name} #{self.last_name}".strip
54
+ end
55
+
56
+
57
+ protected
58
+
59
+ def check_no_of_users
60
+ if Citygate::Engine.no_of_users > 0 && Citygate::User.count >= Citygate::Engine.no_of_users
61
+ self.errors.add(:base,I18n::t('users.errors.too_many'))
62
+ return false
63
+ else
64
+ return true
65
+ end
46
66
  end
47
67
  end
48
68
  end
@@ -2,10 +2,10 @@
2
2
  <% @users.each do |user| %>
3
3
  <div class="user">
4
4
  <span class="email"><%= user.email %></span>
5
- <%= content_tag(:span, user.name) if user.name %>
5
+ <%= content_tag(:span, user.full_name) if user.full_name %>
6
6
  <div class="user-links">
7
- <%= link_to "Show", admin_user_path(user), :class => "show-link" %>
8
- <%= link_to "Edit", edit_admin_user_path(user), :class => "edit-link" if can? :update, user %>
7
+ <%= link_to t('admin.users.index.show_link'), admin_user_path(user), :class => "show-link" %>
8
+ <%= link_to t('admin.users.index.edit_link'), edit_admin_user_path(user), :class => "edit-link" if can? :update, user %>
9
9
  </div>
10
10
  </div>
11
11
  <% end %>
@@ -1,4 +1,13 @@
1
1
  <div id="user">
2
- <p>User: <%= @user.name %></p>
3
- <p>Email: <%= @user.email if @user.email %></p>
4
- </div>
2
+ <p>
3
+ <span class="label"><%= t('admin.users.show.labels.name') %>:</span>
4
+ <span class="value"><%= @user.full_name %></span>
5
+ </p>
6
+
7
+ <% if @user.email %>
8
+ <p>
9
+ <span class="label"><%= t('admin.users.show.labels.email') %>:</span>
10
+ <span class="value"><%= @user.email %></span>
11
+ </p>
12
+ <% end %>
13
+ </div>
@@ -1,6 +1,5 @@
1
1
  <header>
2
- <h1>NORMAL PANEL</h1>
3
- <nav>
4
- <%= render 'citygate/shared/navigation' %>
5
- </nav>
6
- </header>
2
+ <h1>Welcome to CityGate!</h1>
3
+
4
+ <%= render 'citygate/shared/navigation' %>
5
+ </header>
@@ -1,20 +1,20 @@
1
- <ul id="citygate-navigation">
2
- <% if user_signed_in? %>
3
- <li><%= link_to('Profile', profile_path) %></li>
4
- <li><%= link_to('Edit account', edit_user_registration_path) %></li>
1
+ <nav>
2
+ <ul>
3
+ <% if user_signed_in? %>
4
+ <li><%= link_to t('navigation.links.profile'), profile_path %></li>
5
+ <li><%= link_to t('navigation.links.edit'), edit_user_registration_path %></li>
6
+ <li><%= link_to t('navigation.links.log_out'), destroy_user_session_path, :method => 'delete' %></li>
7
+ <% else %>
8
+ <li><%= link_to t('navigation.links.log_in'), new_user_session_path %></li>
9
+ <li><%= link_to t('navigation.links.sign_up'), new_user_registration_path %></li>
5
10
 
6
- <li><%= link_to('Log out', destroy_user_session_path, :method=>'delete') %></li>
7
- <% else %>
8
- <li><%= link_to('Log in', new_user_session_path) %></li>
11
+ <% Citygate::User.omniauth_providers.each do |provider| %>
12
+ <li><%= link_to t('navigation.links.omniauth', provider: provider.to_s.titleize), omniauth_authorize_path(Citygate::User.new, provider), :id => "#{provider.to_s}" %></li>
13
+ <% end -%>
14
+ <% end %>
9
15
 
10
- <li><%= link_to('Sign up', new_user_registration_path) %></li>
11
-
12
- <% Citygate::User.omniauth_providers.each do |provider| %>
13
- <li><%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(Citygate::User.new, provider), :id => "#{provider.to_s}" %></li>
14
- <% end -%>
15
- <% end %>
16
-
17
- <% if can?(:read, Citygate::User) && !params[:controller]["admin"] %>
18
- <li><%= link_to("Admin", admin_users_path) %></li>
19
- <% end %>
20
- </ul>
16
+ <% if can?(:manage, Citygate::User) and !params[:controller]["admin"] %>
17
+ <li><%= link_to t('navigation.links.admin'), admin_users_path %></li>
18
+ <% end %>
19
+ </ul>
20
+ </nav>
@@ -1,14 +1,16 @@
1
- <h2 class="name"><%= current_user.name_or_email %></h2>
1
+ <h2><%= current_user.name_or_email %></h2>
2
2
 
3
3
  <div id="social-accounts">
4
4
  <% connected_providers = current_user.authorizations.map(&:provider) %>
5
5
 
6
6
  <%= connected_providers %>
7
+
7
8
  <% @providers.each do |provider| %>
8
9
  <% class_str = "#{provider}-connect " %>
9
10
  <% class_str += (connected_providers.include? provider.to_s.capitalize) ? "connected" : "can-connect" %>
10
- <div class="<%= class_str %>" >
11
- <%= link_to "#{provider.to_s.capitalize}", user_omniauth_authorize_path(provider,{user: current_user}) %>
11
+
12
+ <div class="<%= class_str %>">
13
+ <%= link_to "#{provider.to_s.capitalize}", user_omniauth_authorize_path(provider, {user: current_user}) %>
12
14
  </div>
13
15
  <% end %>
14
- </div>
16
+ </div>
@@ -0,0 +1,12 @@
1
+ <h2>Resend confirmation instructions</h2>
2
+
3
+ <%= form_for resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post } do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <%= f.label :email %>
7
+ <%= f.email_field :email %>
8
+
9
+ <%= f.submit "Resend confirmation instructions" %>
10
+ <% end %>
11
+
12
+ <%= render "devise/shared/links" %>
@@ -0,0 +1,5 @@
1
+ <p>Welcome <%= @resource.email %>!</p>
2
+
3
+ <p>You can confirm your account email through the link below:</p>
4
+
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
@@ -0,0 +1,8 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Someone has requested a link to change your password, and you can do this through the link below.</p>
4
+
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
6
+
7
+ <p>If you didn't request this, please ignore this email.</p>
8
+ <p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,7 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
4
+
5
+ <p>Click the link below to unlock your account:</p>
6
+
7
+ <p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
@@ -0,0 +1,16 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <%= form_for resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put } do |f| %>
4
+ <%= devise_error_messages! %>
5
+ <%= f.hidden_field :reset_password_token %>
6
+
7
+ <%= f.label :password, "New password" %>
8
+ <%= f.password_field :password %>
9
+
10
+ <%= f.label :password_confirmation, "Confirm new password" %>
11
+ <%= f.password_field :password_confirmation %>
12
+
13
+ <%= f.submit "Change my password" %>
14
+ <% end %>
15
+
16
+ <%= render "devise/shared/links" %>
@@ -0,0 +1,12 @@
1
+ <h2>Forgot your password?</h2>
2
+
3
+ <%= form_for resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post } do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <%= f.label :email %>
7
+ <%= f.email_field :email %>
8
+
9
+ <%= f.submit "Send me reset password instructions" %>
10
+ <% end %>
11
+
12
+ <%= render "devise/shared/links" %>
@@ -1,32 +1,35 @@
1
- <h2>Edit Profile</h2>
2
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
1
+ <h2><%= t('admin.users.edit.title') %></h2>
2
+
3
+ <%= form_for resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put } do |f| %>
3
4
  <%= devise_error_messages! %>
4
- <p>
5
- <%= f.label :name %>
6
- <%= f.text_field :name %>
7
- </p>
8
- <p>
9
- <%= f.label :email %>
10
- <%= f.email_field :email %>
11
- </p>
12
- <p>
13
- <%= f.label :password %>
14
- <%= f.password_field :password %>
15
- <p class="hint">(leave blank if you don't want to change it)</p>
16
- </p>
17
- <p>
18
- <%= f.label :password_confirmation %>
19
- <%= f.password_field :password_confirmation %>
20
- </p>
21
- <p>
22
- <%= f.label :current_password %>
23
- <%= f.password_field :current_password %>
24
- <p class="hint">(we need your current password to confirm your changes)</p>
25
- </p>
26
- <p><%= f.submit "Update" %></p>
5
+
6
+ <%= f.label :first_name %>
7
+ <%= f.text_field :first_name %>
8
+
9
+ <%= f.label :last_name %>
10
+ <%= f.text_field :last_name %>
11
+
12
+ <%= f.label :email %>
13
+ <%= f.email_field :email %>
14
+
15
+ <%= f.label :password %>
16
+ <%= f.password_field :password %>
17
+
18
+ <%= f.label :password_confirmation %>
19
+ <%= f.password_field :password_confirmation %>
20
+
21
+ <%= f.label :current_password %>
22
+ <%= f.password_field :current_password, :required => true %>
23
+
24
+ <%= f.submit t('admin.users.edit.update_link') %>
27
25
  <% end %>
28
- <h3>Cancel my account</h3>
29
- <p>
30
- Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.
31
- </p>
32
- <%= link_to "Back", :back %>
26
+
27
+ <h3><%= t('admin.users.edit.cancel_account.title') %></h3>
28
+
29
+ <span><%= t('admin.users.edit.cancel_account.question') %></span>
30
+
31
+ <%= link_to t('admin.users.edit.cancel_account.link'), registration_path(resource_name),
32
+ :data => { :confirm => t('admin.users.edit.cancel_account.confirm') },
33
+ :method => :delete %>
34
+
35
+ <%= link_to t('admin.users.edit.back_link'), :back %>
@@ -1,18 +1,18 @@
1
- <h2>Sign up</h2>
1
+ <h2><%= t('admin.users.new.title') %></h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
3
+ <%= form_for resource, :as => resource_name, :url => registration_path(resource_name) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email %></div>
6
+ <%= f.label :email %>
7
+ <%= f.email_field :email, :required => true %>
8
8
 
9
- <div><%= f.label :password %><br />
10
- <%= f.password_field :password %></div>
9
+ <%= f.label :password %>
10
+ <%= f.password_field :password, :required => true %>
11
11
 
12
- <div><%= f.label :password_confirmation %><br />
13
- <%= f.password_field :password_confirmation %></div>
12
+ <%= f.label :password_confirmation %>
13
+ <%= f.password_field :password_confirmation, :required => true %>
14
14
 
15
- <div><%= f.submit "Sign up" %></div>
15
+ <%= f.submit t('admin.users.new.create_link') %>
16
16
  <% end %>
17
17
 
18
- <%= render :partial => "devise/shared/links" %>
18
+ <%= render :partial => "citygate/shared/navigation" %>
@@ -0,0 +1,18 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <%= form_for resource, :as => resource_name, :url => session_path(resource_name) do |f| %>
4
+ <%= f.label :email %>
5
+ <%= f.email_field :email, :required => true %>
6
+
7
+ <%= f.label :password %>
8
+ <%= f.password_field :password, :required => true %>
9
+
10
+ <% if devise_mapping.rememberable? -%>
11
+ <%= f.check_box :remember_me %>
12
+ <%= f.label :remember_me %>
13
+ <% end -%>
14
+
15
+ <%= f.submit "Sign in" %>
16
+ <% end %>
17
+
18
+ <%= render "devise/shared/links" %>
@@ -1,25 +1,25 @@
1
1
  <%- if controller_name != 'sessions' %>
2
- <%= link_to "Sign in", new_session_path(resource_name) %><br />
2
+ <%= link_to "Sign in", new_session_path(resource_name) %>
3
3
  <% end -%>
4
4
 
5
5
  <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6
- <%= link_to "Sign up", new_registration_path(resource_name) %><br />
6
+ <%= link_to "Sign up", new_registration_path(resource_name) %>
7
7
  <% end -%>
8
8
 
9
9
  <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
10
- <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
10
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %>
11
11
  <% end -%>
12
12
 
13
13
  <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14
- <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
14
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
15
15
  <% end -%>
16
16
 
17
17
  <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18
- <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
18
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
19
19
  <% end -%>
20
20
 
21
21
  <%- if devise_mapping.omniauthable? %>
22
22
  <%- resource_class.omniauth_providers.each do |provider| %>
23
- <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
23
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
24
24
  <% end -%>
25
- <% end -%>
25
+ <% end -%>
@@ -0,0 +1,12 @@
1
+ <h2>Resend unlock instructions</h2>
2
+
3
+ <%= form_for resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post } do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <%= f.label :email %>
7
+ <%= f.email_field :email %>
8
+
9
+ <%= f.submit "Resend unlock instructions" %>
10
+ <% end %>
11
+
12
+ <%= render "devise/shared/links" %>
@@ -2,11 +2,11 @@
2
2
  <html>
3
3
  <head>
4
4
  <%= stylesheet_link_tag "citygate/application", :media => "all" %>
5
- <%= javascript_include_tag "citygate/application" %>
5
+ <%= javascript_include_tag "citygate" %>
6
6
  <%= csrf_meta_tags %>
7
7
  <%= yield :head %>
8
8
  </head>
9
- <body>
9
+ <body data-pjax-container>
10
10
  <%= render 'citygate/shared/navigation' %>
11
11
 
12
12
  <% flash.each do |name, msg| %>
data/config/accounts.yml CHANGED
@@ -1,5 +1,3 @@
1
1
  facebook:
2
2
  app_id: "387891007905465"
3
- app_secret: "0cb143f301a74968289daf606b29dbec"
4
- google:
5
- identifier: "https://www.google.com/accounts/o8/id"
3
+ app_secret: "0cb143f301a74968289daf606b29dbec"