rollout_admin 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,17 +22,24 @@ To mount the engine within your project add the following line to your routes.rb
22
22
 
23
23
  mount RolloutAdmin::Engine => "/rollout_admin"
24
24
 
25
- You will be asked for a username and password when accessing the page for the first time. This is "foo/bar".
25
+ You will be asked for a username and password when accessing the page. The default username, password is foo/bar. You can configure them to be anything you like with the intializer options:
26
+
27
+ RolloutAdmin.auth_name = "myuser"
28
+ RolloutAdmin.auth_password = "secret"
26
29
 
27
30
  **Special hint when using an API**
28
31
 
29
32
  It turned out that in one of our own projects we wrapped the users object to be accessed via an API. Within our main application controller the API calls got some additional headers for API Key which where not accessable within the rollout_admin engine. Therefor there is an option RolloutAdmin.user_url you can configure to provide the URL used for getting a users list within the RolloutAdmin interface.
30
33
 
34
+ Furthermore if you don't have the fields name and email present in your User Model or if they are named differently. You can override the User Model attributes rollout_admin should use to display user information.
35
+
31
36
  Just define an initializer and paste the following:
32
37
 
33
38
  # Rollout Admin configuration
34
39
  #
35
40
  RolloutAdmin.user_url = "/just/something/boring.json"
41
+ RolloutAdmin.user_name_attribute = "first_name"
42
+ RolloutAdmin.user_email_attribute = "email"
36
43
 
37
44
  ## TODO
38
45
 
@@ -76,7 +76,7 @@ $(function(){
76
76
  $.getJSON('<%= user_url%>', function(json) {
77
77
  userlist='<h5>Select users to add</h5><form id="userlist"><ul class="unstyled">';
78
78
  $.each(json, function() {
79
- userlist += '<li><input type="checkbox", value="'+this.id+'" data-username="'+this.Name+'"> '+this.Name+', '+this.email+'</li>';
79
+ userlist += '<li><input type="checkbox", value="'+this.id+'" data-username="'+this.<%=RolloutAdmin.user_name_attribute%>+'"> '+this.<%=RolloutAdmin.user_name_attribute%>+', '+this.<%=RolloutAdmin.user_email_attribute%>+'</li>';
80
80
  });
81
81
  userlist +='</ul></form>';
82
82
 
@@ -59,7 +59,7 @@ module RolloutAdmin
59
59
 
60
60
  def remove
61
61
  if params[:object_type] == "user"
62
- @user=User.where(:name => params[:user]).first
62
+ @user=User.where(RolloutAdmin.user_name_attribute.to_sym => params[:user]).first
63
63
  if @user
64
64
  $rollout.deactivate_user(params[:feature], @user)
65
65
  end
@@ -86,7 +86,7 @@ module RolloutAdmin
86
86
 
87
87
  def authenticate
88
88
  authenticate_or_request_with_http_basic do |username, password|
89
- username == "foo" && password == "bar"
89
+ username == RolloutAdmin.auth_name && password == RolloutAdmin.auth_password
90
90
  end
91
91
  end
92
92
 
@@ -11,11 +11,11 @@
11
11
  <% if feature.users.count > 0 %>
12
12
  <% feature.users.each {|user| %>
13
13
  <li><i class="icon-minus delete_user"></i>
14
- <%if Object.const_defined?('User') %>
15
- <%=User.find(user.to_i).Name%>
16
- <% else %>
17
- no User model defined
18
- <% end %>
14
+ <% if User.find(user.to_i).nil? %>
15
+ <%= user %>
16
+ <% else %>
17
+ <%=User.find(user.to_i).send(RolloutAdmin.user_name_attribute) %>
18
+ <% end %>
19
19
  </li>
20
20
  <% } %>
21
21
  <% else %>
@@ -1,3 +1,3 @@
1
1
  module RolloutAdmin
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/rollout_admin.rb CHANGED
@@ -3,4 +3,15 @@ require "rollout_admin/engine"
3
3
  module RolloutAdmin
4
4
  mattr_accessor :user_url
5
5
 
6
+ mattr_accessor :user_name_attribute
7
+ @@user_name_attribute = "Name"
8
+
9
+ mattr_accessor :user_email_attribute
10
+ @@user_email_attribute = "email"
11
+
12
+ mattr_accessor :auth_name
13
+ @@auth_name = "foo"
14
+
15
+ mattr_accessor :auth_password
16
+ @@auth_password = "bar"
6
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollout_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: