• R/O
  • HTTP
  • SSH
  • HTTPS

pettanr: コミット

サーバ側、Railsシステム本体


コミットメタ情報

リビジョン2f5f78baba91a15f9c7bbf20293bbdaf062daf2a (tree)
日時2012-01-14 13:51:26
作者yasushiito <yas@pen-...>
コミッターyasushiito

ログメッセージ

approve complated

変更サマリ

差分

--- a/app/controllers/system_controller.rb
+++ b/app/controllers/system_controller.rb
@@ -16,11 +16,37 @@ class SystemController < ApplicationController
1616 def auth_token
1717 end
1818
19- def approbe
19+ def create_token
20+ @admin = current_admin
21+ respond_to do |format|
22+ if @admin.create_token
23+ format.html { redirect_to({:action => :auth_token}, {:notice => 'admin token was successfully created.'}) }
24+ else
25+ format.html { render action: "auth_token" }
26+ end
27+ end
28+ end
29+
30+ def delete_token
31+ current_admin.delete_token
32+ respond_to do |format|
33+ format.html { redirect_to :action => :auth_token}
34+ end
35+ end
36+
37+ def approve
38+ @admin = Admin.find params[:id]
39+ respond_to do |format|
40+ if @admin.apv
41+ format.html { redirect_to({:action => :waiting_list}, {:notice => 'admin was successfully approved.'}) }
42+ else
43+ format.html { render action: "waiting_list" }
44+ end
45+ end
2046 end
2147
2248 def waiting_list
23- @newadmins = Admin.find(:all, :conditions => ['activate = 0'])
49+ @waits = Admin.find(:all, :conditions => ['approve = 0'])
2450 end
2551
2652 def accept_admin
--- a/app/models/admin.rb
+++ b/app/models/admin.rb
@@ -6,14 +6,34 @@ class Admin < ActiveRecord::Base
66
77 # Setup accessible (or protected) attributes for your model
88 attr_accessible :email, :password, :password_confirmation, :remember_me
9- before_save :ensure_authentication_token
109
1110 def active_for_authentication?
12- super && (self.approve == 1)
11+ super && (self.approve == 1)
1312 end
1413
14+ def create_token
15+ self.ensure_authentication_token
16+ self.save
17+ end
18+
19+ def delete_token
20+ self.authentication_token = nil
21+ self.save
22+ end
23+
24+ def apv
25+ self.approve = 1
26+ self.save
27+ end
28+
1529 def self.start(email, passwd)
16- a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd
30+ a = Admin.find(:first, :conditions => ['email = ?', email])
31+ if a
32+ a.password = passwd
33+ a.password_confirmation = passwd
34+ else
35+ a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd
36+ end
1737 a.approve = 1
1838 a.save!
1939 end
--- a/app/views/layouts/system.html.erb
+++ b/app/views/layouts/system.html.erb
@@ -31,7 +31,7 @@
3131 </div>
3232 <div>
3333 <%= link_to "browse", :controller => '/system', :action => :browse%>
34- <%= link_to "approbe", :controller => '/system', :action => :approbe%>
34+ <%= link_to "approve", :controller => '/system', :action => :waiting_list%>
3535 <%= link_to "token", :controller => '/system', :action => :auth_token%>
3636 </div>
3737 <%= yield %>
--- a/app/views/system/auth_token.html.erb
+++ b/app/views/system/auth_token.html.erb
@@ -2,7 +2,14 @@
22 <p class="notice"><%= notice %></p>
33 <p class="alert"><%= alert %></p>
44 </div>
5+<div>
56 authentication_token:<%= current_admin.authentication_token %>
7+</div>
68
7-<%= link_to 'generate token', :action => :create_token %>
8-<%= link_to 'delete token', :action => :delete_token %>
9+<div>
10+ <% if current_admin.authentication_token %>
11+ <%= link_to 'delete token', :action => :delete_token %>
12+ <% else %>
13+ <%= link_to 'generate token', :action => :create_token %>
14+ <% end %>
15+</div>
--- a/app/views/system/index.html.erb
+++ b/app/views/system/index.html.erb
@@ -6,6 +6,9 @@
66 <%= link_to 'browse', :action => :browse %>
77 </div>
88 <div>
9+ <%= link_to 'approve', :action => :waiting_list %>
10+</div>
11+<div>
912 <%= link_to 'auth token', :action => :auth_token %>
1013 </div>
1114 <div>
--- a/app/views/system/waiting_list.html.erb
+++ b/app/views/system/waiting_list.html.erb
@@ -1,15 +1,34 @@
1-<h1>Listing artists</h1>
1+<div>
2+ <p class="notice"><%= notice %></p>
3+ <p class="alert"><%= alert %></p>
4+</div>
5+<h1>Listing waiting admins</h1>
26
37 <table>
48 <tr>
5- <th>author</th>
6- <th></th>
9+ <th>id</th>
10+ <th>email</th>
11+ <th>sign_in_count</th>
12+ <th>current_sign_in_at</th>
13+ <th>last_sign_in_at</th>
14+ <th>current_sign_in_ip</th>
15+ <th>last_sign_in_ip</th>
16+ <th>created_at</th>
17+ <th>updated_at</th>
718 </tr>
819
9-<% @artists.each do |artist| %>
20+<% @waits.each do |admin| %>
1021 <tr>
11- <td><%= artist.author_id %></td>
12- <td><%= link_to 'Show', artist %></td>
22+ <td><%= admin.id %></td>
23+ <td><%= h(admin.email) %></td>
24+ <td><%= admin.sign_in_count %></td>
25+ <td><%= admin.current_sign_in_at %></td>
26+ <td><%= admin.last_sign_in_at %></td>
27+ <td><%= admin.current_sign_in_ip %></td>
28+ <td><%= admin.last_sign_in_ip %></td>
29+ <td><%= admin.created_at %></td>
30+ <td><%= admin.updated_at %></td>
31+ <td><%= link_to 'approve', :controller => '/system', :action => :approve, :id => admin.id %></td>
1332 </tr>
1433 <% end %>
1534 </table>
旧リポジトリブラウザで表示