unknown_admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +57 -0
  3. data/Rakefile +38 -0
  4. data/app/controllers/admin/admin_controller.rb +60 -0
  5. data/app/controllers/admin/resources_controller.rb +44 -0
  6. data/app/controllers/admin/users_controller.rb +52 -0
  7. data/app/helpers/admin/resources_helper.rb +41 -0
  8. data/app/models/user.rb +4 -0
  9. data/app/views/admin/admin/index.html.erb +36 -0
  10. data/app/views/admin/resources/_breadcrumb.html.erb +6 -0
  11. data/app/views/admin/resources/_condition_fields.html.erb +10 -0
  12. data/app/views/admin/resources/_form.html.erb +4 -0
  13. data/app/views/admin/resources/_form_actions.html.erb +5 -0
  14. data/app/views/admin/resources/_form_fields.html.erb +4 -0
  15. data/app/views/admin/resources/_list.html.erb +13 -0
  16. data/app/views/admin/resources/_list_actions.html.erb +5 -0
  17. data/app/views/admin/resources/_list_header.html.erb +6 -0
  18. data/app/views/admin/resources/_list_item.html.erb +12 -0
  19. data/app/views/admin/resources/_list_item_actions.html.erb +11 -0
  20. data/app/views/admin/resources/_search_field.html.erb +31 -0
  21. data/app/views/admin/resources/edit.html.erb +19 -0
  22. data/app/views/admin/resources/index.html.erb +11 -0
  23. data/app/views/admin/resources/new.html.erb +19 -0
  24. data/app/views/admin/resources/show.html.erb +23 -0
  25. data/app/views/admin/users/_form.html.erb +102 -0
  26. data/app/views/admin/users/_form_new.html.erb +66 -0
  27. data/app/views/admin/users/token_fields.json.rabl +2 -0
  28. data/app/views/devise/confirmations/new.html.erb +12 -0
  29. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  30. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  31. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  32. data/app/views/devise/passwords/edit.html.erb +16 -0
  33. data/app/views/devise/passwords/new.html.erb +12 -0
  34. data/app/views/devise/registrations/edit.html.erb +25 -0
  35. data/app/views/devise/registrations/new.html.erb +18 -0
  36. data/app/views/devise/sessions/new.html.erb +17 -0
  37. data/app/views/devise/shared/_links.erb +25 -0
  38. data/app/views/devise/unlocks/new.html.erb +12 -0
  39. data/app/views/layouts/admin/application.html.erb +31 -0
  40. data/config/routes.rb +8 -0
  41. data/lib/generators/unknown_admin/controller/controller_generator.rb +68 -0
  42. data/lib/generators/unknown_admin/controller/templates/standard_controller.rb +12 -0
  43. data/lib/generators/unknown_admin/install/install_generator.rb +36 -0
  44. data/lib/generators/unknown_admin/install/templates/admin.css +17 -0
  45. data/lib/generators/unknown_admin/install/templates/admin.js +20 -0
  46. data/lib/generators/unknown_admin/install/templates/admin_controller.rb +63 -0
  47. data/lib/generators/unknown_admin/install/templates/application.html.erb +39 -0
  48. data/lib/generators/unknown_admin/install/templates/resources_controller.rb +44 -0
  49. data/lib/tasks/unknown_admin_tasks.rake +4 -0
  50. data/lib/unknown_admin.rb +17 -0
  51. data/lib/unknown_admin/version.rb +3 -0
  52. data/test/dummy/README.rdoc +261 -0
  53. data/test/dummy/Rakefile +7 -0
  54. data/test/dummy/app/assets/javascripts/application.js +15 -0
  55. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  56. data/test/dummy/app/controllers/application_controller.rb +3 -0
  57. data/test/dummy/app/helpers/application_helper.rb +2 -0
  58. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  59. data/test/dummy/config.ru +4 -0
  60. data/test/dummy/config/application.rb +59 -0
  61. data/test/dummy/config/boot.rb +10 -0
  62. data/test/dummy/config/database.yml +25 -0
  63. data/test/dummy/config/environment.rb +5 -0
  64. data/test/dummy/config/environments/development.rb +37 -0
  65. data/test/dummy/config/environments/production.rb +67 -0
  66. data/test/dummy/config/environments/test.rb +37 -0
  67. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  68. data/test/dummy/config/initializers/inflections.rb +15 -0
  69. data/test/dummy/config/initializers/mime_types.rb +5 -0
  70. data/test/dummy/config/initializers/secret_token.rb +7 -0
  71. data/test/dummy/config/initializers/session_store.rb +8 -0
  72. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  73. data/test/dummy/config/locales/en.yml +5 -0
  74. data/test/dummy/config/routes.rb +58 -0
  75. data/test/dummy/public/404.html +26 -0
  76. data/test/dummy/public/422.html +26 -0
  77. data/test/dummy/public/500.html +25 -0
  78. data/test/dummy/public/favicon.ico +0 -0
  79. data/test/dummy/script/rails +6 -0
  80. data/test/test_helper.rb +15 -0
  81. data/test/unknown_admin_test.rb +7 -0
  82. metadata +290 -0
@@ -0,0 +1,11 @@
1
+ <% if allow? "admin/#{resource_class.model_name.pluralize.underscore}","edit" %>
2
+ <%= link_to t('.edit', :default => t("helpers.links.edit")),
3
+ edit_resource_url(resource), :class => 'btn btn-mini' %>
4
+ <% end %>
5
+ <% if allow? "admin/#{resource_class.model_name.pluralize.underscore}","destroy" %>
6
+ <%= link_to t('.destroy', :default => t("helpers.links.destroy")),
7
+ resource_path(resource),
8
+ :method => :delete,
9
+ :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
10
+ :class => 'btn btn-mini btn-danger' %>
11
+ <% end %>
@@ -0,0 +1,31 @@
1
+ <% if search_fields.count > 0 %>
2
+ <div class="row">
3
+ <div class="span9 well">
4
+ <%= search_form_for [:admin,@search] do |f| %>
5
+ <div class="controls">
6
+ <label for="search">Search:
7
+ <div class="input-append">
8
+ <% search_fields.each do |search_field| %>
9
+ <%= f.text_field search_field,class:"span4" %>
10
+ <%= f.submit "Search",class:"btn" %>
11
+ <% end %>
12
+ </div>
13
+ </label>
14
+ </div>
15
+ <% if false %>
16
+
17
+ <%= f.condition_fields do |c| %>
18
+ <%= render "condition_fields", f: c %>
19
+ <% end %>
20
+ <p><%= link_to_add_fields "Add Conditions", f, :condition %></p>
21
+ <div class="field">
22
+ Sort:
23
+ <%= f.sort_fields do |s| %>
24
+ <%= s.sort_select %>
25
+ <% end %>
26
+ </div>
27
+ <% end %>
28
+ <% end %>
29
+ </div>
30
+ </div>
31
+ <% end %>
@@ -0,0 +1,19 @@
1
+ <%= render :partial=>"breadcrumb" %>
2
+ <div class="page-header">
3
+ <h1><%=t '.title', :default => t('helpers.titles.edit', :model => resource_class.model_name.human,
4
+ :default => "Edit #{resource_class.model_name.human}") %></h1>
5
+ </div>
6
+ <% if resource.errors.any? %>
7
+ <div id="error_explanation" class="alert">
8
+ <button type="button" class="close" data-dismiss="alert">×</button>
9
+ <h3><%= "#{pluralize(resource.errors.count, "error")} prohibited this #{resource_class.model_name.human} from being saved:" %></h3>
10
+ <ul>
11
+ <% resource.errors.full_messages.each do |msg| %>
12
+ <li>
13
+ <%= msg %>
14
+ </li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
18
+ <% end %>
19
+ <%= render :partial => 'form' %>
@@ -0,0 +1,11 @@
1
+ <%= render :partial=>"breadcrumb" %>
2
+ <div class="page-header">
3
+ <h1><%=t '.title', :default => resource_class.model_name.human.pluralize %></h1>
4
+ </div>
5
+
6
+ <%= render :partial=>"search_field" %>
7
+ <div id="list" >
8
+ <%= render :partial=>"list" %>
9
+ </div>
10
+ <%= will_paginate collection %>
11
+ <%= render :partial=>"list_actions" %>
@@ -0,0 +1,19 @@
1
+ <%= render :partial=>"breadcrumb" %>
2
+ <div class="page-header">
3
+ <h1><%=t '.title', :default => t('helpers.titles.new', :model => resource_class.model_name.human,
4
+ :default => "New #{resource_class.model_name.human}") %></h1>
5
+ </div>
6
+ <% if resource.errors.any? %>
7
+ <div id="error_explanation" class="alert">
8
+ <button type="button" class="close" data-dismiss="alert">×</button>
9
+ <h3><%= "#{pluralize(resource.errors.count, "error")} prohibited this #{resource_class.model_name.human} from being saved:" %></h3>
10
+ <ul>
11
+ <% resource.errors.full_messages.each do |msg| %>
12
+ <li>
13
+ <%= msg %>
14
+ </li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
18
+ <% end %>
19
+ <%= render :partial => 'form' %>
@@ -0,0 +1,23 @@
1
+ <%= render :partial=>"breadcrumb" %>
2
+ <div class="page-header">
3
+ <h1><%=t '.title', :default => resource_class.model_name.human %></h1>
4
+ </div>
5
+
6
+ <dl class="dl-horizontal">
7
+ <% show_fields.each do |field| %>
8
+ <dt><strong><%= resource_class.human_attribute_name(field) %>:</strong></dt>
9
+ <dd><%= resource.send(field) %></dd>
10
+ <% end %>
11
+ </dl>
12
+
13
+ <div class="form-actions">
14
+ <%= link_to t('.back', :default => t("helpers.links.back")),
15
+ collection_url, :class => 'btn' %>
16
+ <%= link_to t('.edit', :default => t("helpers.links.edit")),
17
+ edit_resource_url , :class => 'btn' %>
18
+ <%= link_to t('.destroy', :default => t("helpers.links.destroy")),
19
+ resource_url,
20
+ :method => 'delete',
21
+ :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
22
+ :class => 'btn btn-danger' %>
23
+ </div>
@@ -0,0 +1,102 @@
1
+ <%= form_for([:admin,@user]) do |f| %>
2
+ <ul id="myTab" class="nav nav-tabs">
3
+ <li class="active">
4
+ <a href="#main" data-toggle="tab">Main Setup</a>
5
+ </li>
6
+ <li>
7
+ <a href="#roles" data-toggle="tab">Roles</a>
8
+ </li>
9
+ </ul>
10
+ <div id="userTabContent" class="tab-content">
11
+ <div class="tab-pane fade in active" id="main">
12
+ <div class="control-group">
13
+ <%= f.label :id,:class=>"control-label"%>
14
+ <div class="controls">
15
+ <%= f.text_field :id,disabled:true %>
16
+ </div>
17
+ </div>
18
+ <div class="control-group">
19
+ <%= f.label :email,:class=>"control-label"%>
20
+ <div class="controls">
21
+ <%= f.text_field :email %>
22
+ </div>
23
+ </div>
24
+ <div class="control-group">
25
+ <%= f.label :username,:class=>"control-label"%>
26
+ <div class="controls">
27
+ <%= f.text_field :username %>
28
+ </div>
29
+ </div>
30
+ <div class="control-group">
31
+ <%= f.label :gender,:class=>"control-label" %>
32
+ <div class="controls">
33
+ <%= f.select(:gender,[[:male,:male],[:female,:female]]) %>
34
+ </div>
35
+ </div>
36
+ <div class="control-group">
37
+ <%= f.label :preferred_locale,:class=>"control-label" %>
38
+ <div class="controls">
39
+ <%= f.select(:preferred_locale_id,Locale.localizations.map { |locale| [locale.language_name, locale.id] }) %>
40
+ </div>
41
+ </div>
42
+ <div class="control-group">
43
+ <%= f.label :active,:class=>"control-label" %>
44
+ <div class="controls">
45
+ <%= f.check_box :active %>
46
+ </div>
47
+ </div>
48
+ <div class="control-group">
49
+ <%= f.label :first_name,:class=>"control-label" %>
50
+ <div class="controls">
51
+ <%= f.text_field :first_name %>
52
+ </div>
53
+ </div>
54
+ <div class="control-group">
55
+ <%= f.label :last_name,:class=>"control-label" %>
56
+ <div class="controls">
57
+ <%= f.text_field :last_name %>
58
+ </div>
59
+ </div>
60
+ <% if params[:action]=="new" %>
61
+ <div class="control-group">
62
+ <%= f.label :password,:class=>"control-label" %>
63
+ <div class="controls">
64
+ <%= f.password_field :password %>
65
+ </div>
66
+ </div>
67
+ <div class="control-group">
68
+ <%= f.label :password_confirmation,:class=>"control-label" %>
69
+ <div class="controls">
70
+ <%= f.password_field :password_confirmation %>
71
+ </div>
72
+ </div>
73
+ <% end %>
74
+ <div class="control-group">
75
+ <%= f.label :country, :class => 'control-label' %>
76
+ <div class="controls">
77
+ <%= f.collection_select :country_id, Country.order(:name), :id, :name, {}, {class:"chosen_field"} %>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ <div class="tab-pane fade" id="membership">
82
+
83
+ <div class="control-group">
84
+
85
+ </div>
86
+ </div>
87
+ <div class="tab-pane fade" id="roles">
88
+ <h1>System Roles</h1>
89
+ <div class="control-group">
90
+ <%= f.label :roles,:class=>"control-label" %>
91
+ <div class="controls">
92
+ <%= f.collection_select :role_ids, Role.order(:name), :id, :name, {}, {multiple: true,class:"chosen_field"} %>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ </div>
97
+ <%= change_info_for @user %>
98
+ <%= form_actions f,@user %>
99
+
100
+
101
+
102
+ <% end %>
@@ -0,0 +1,66 @@
1
+ <%= form_for(@user,:html=>{:class=>"form-inline"}) do |f| %>
2
+ <% if @user.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
+ <ul>
6
+ <% @user.errors.full_messages.each do |msg| %>
7
+ <li>
8
+ <%= msg %>
9
+ </li>
10
+ <% end %>
11
+ </ul>
12
+ </div>
13
+ <% end %>
14
+ <ul id="myTab" class="nav nav-tabs">
15
+ <li class="active">
16
+ <a href="#main" data-toggle="tab">Main Setup</a>
17
+ </li>
18
+
19
+ </ul>
20
+ <div id="userTabContent" class="tab-content">
21
+ <div class="tab-pane fade in active" id="main">
22
+ <div class="control-group">
23
+ <%= f.label :login_id,:class=>"control-label"%>
24
+ <div class="controls">
25
+ <%= f.text_field :login_id %>
26
+ </div>
27
+ </div>
28
+ <div class="control-group">
29
+ <%= f.label :locale,:class=>"control-label" %>
30
+ <div class="controls">
31
+ <%= f.select(:pref_locale,Locale.active.map { |locale| [locale.language_name, locale.locale_id] }) %>
32
+ </div>
33
+ </div>
34
+ <div class="control-group">
35
+ <%= f.label :status,:class=>"control-label" %>
36
+ <div class="controls">
37
+ <%= f.select(:status,[["active",'A'],["inactive",'I']]) %>
38
+ </div>
39
+ </div>
40
+ <div class="control-group">
41
+ <%= f.label :salutation,:class=>"control-label" %>
42
+ <div class="controls">
43
+ <%= f.select(:salutation,Salutation.all.map { |sal| [sal.title, sal.id] })%>
44
+ </div>
45
+ </div>
46
+ <div class="control-group">
47
+ <%= f.label :first_name,:class=>"control-label" %>
48
+ <div class="controls">
49
+ <%= f.text_field :first_name %>
50
+ </div>
51
+ </div>
52
+ <div class="control-group">
53
+ <%= f.label :last_name,:class=>"control-label" %>
54
+ <div class="controls">
55
+ <%= f.text_field :last_name %>
56
+ </div>
57
+ </div>
58
+
59
+ </div>
60
+
61
+ </div>
62
+ <%= form_actions f,@user%>
63
+
64
+
65
+
66
+ <% end %>
@@ -0,0 +1,2 @@
1
+ collection @users
2
+ attributes :id,:user_email, :first_name, :last_name,:token_text
@@ -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
+ <div><%= f.label :email %><br />
7
+ <%= f.email_field :email %></div>
8
+
9
+ <div><%= f.submit "Resend confirmation instructions" %></div>
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
+ <div><%= f.label :password, "New password" %><br />
8
+ <%= f.password_field :password %></div>
9
+
10
+ <div><%= f.label :password_confirmation, "Confirm new password" %><br />
11
+ <%= f.password_field :password_confirmation %></div>
12
+
13
+ <div><%= f.submit "Change my password" %></div>
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
+ <div><%= f.label :email %><br />
7
+ <%= f.email_field :email %></div>
8
+
9
+ <div><%= f.submit "Send me reset password instructions" %></div>
10
+ <% end %>
11
+
12
+ <%= render "devise/shared/links" %>
@@ -0,0 +1,25 @@
1
+ <h2>Edit <%= resource_name.to_s.humanize %></h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div><%= f.label :email %><br />
7
+ <%= f.email_field :email %></div>
8
+
9
+ <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
10
+ <%= f.password_field :password, :autocomplete => "off" %></div>
11
+
12
+ <div><%= f.label :password_confirmation %><br />
13
+ <%= f.password_field :password_confirmation %></div>
14
+
15
+ <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
16
+ <%= f.password_field :current_password %></div>
17
+
18
+ <div><%= f.submit "Update" %></div>
19
+ <% end %>
20
+
21
+ <h3>Cancel my account</h3>
22
+
23
+ <p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>
24
+
25
+ <%= link_to "Back", :back %>
@@ -0,0 +1,18 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div><%= f.label :email %><br />
7
+ <%= f.email_field :email %></div>
8
+
9
+ <div><%= f.label :password %><br />
10
+ <%= f.password_field :password %></div>
11
+
12
+ <div><%= f.label :password_confirmation %><br />
13
+ <%= f.password_field :password_confirmation %></div>
14
+
15
+ <div><%= f.submit "Sign up" %></div>
16
+ <% end %>
17
+
18
+ <%= render "devise/shared/links" %>
@@ -0,0 +1,17 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4
+ <div><%= f.label :email %><br />
5
+ <%= f.email_field :email %></div>
6
+
7
+ <div><%= f.label :password %><br />
8
+ <%= f.password_field :password %></div>
9
+
10
+ <% if false && devise_mapping.rememberable? -%>
11
+ <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
12
+ <% end -%>
13
+
14
+ <div><%= f.submit "Sign in" %></div>
15
+ <% end %>
16
+
17
+ <%= render "devise/shared/links" %>
@@ -0,0 +1,25 @@
1
+ <%- if controller_name != 'sessions' %>
2
+ <%= link_to "Sign in", new_session_path(resource_name) %><br />
3
+ <% end -%>
4
+
5
+ <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
7
+ <% end -%>
8
+
9
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
10
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
11
+ <% end -%>
12
+
13
+ <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
15
+ <% end -%>
16
+
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 />
19
+ <% end -%>
20
+
21
+ <%- if devise_mapping.omniauthable? %>
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 />
24
+ <% end -%>
25
+ <% end -%>