リビジョン | 2f5f78baba91a15f9c7bbf20293bbdaf062daf2a (tree) |
---|---|
日時 | 2012-01-14 13:51:26 |
作者 | ![]() |
コミッター | yasushiito |
approve complated
@@ -16,11 +16,37 @@ class SystemController < ApplicationController | ||
16 | 16 | def auth_token |
17 | 17 | end |
18 | 18 | |
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 | |
20 | 46 | end |
21 | 47 | |
22 | 48 | def waiting_list |
23 | - @newadmins = Admin.find(:all, :conditions => ['activate = 0']) | |
49 | + @waits = Admin.find(:all, :conditions => ['approve = 0']) | |
24 | 50 | end |
25 | 51 | |
26 | 52 | def accept_admin |
@@ -6,14 +6,34 @@ class Admin < ActiveRecord::Base | ||
6 | 6 | |
7 | 7 | # Setup accessible (or protected) attributes for your model |
8 | 8 | attr_accessible :email, :password, :password_confirmation, :remember_me |
9 | - before_save :ensure_authentication_token | |
10 | 9 | |
11 | 10 | def active_for_authentication? |
12 | - super && (self.approve == 1) | |
11 | + super && (self.approve == 1) | |
13 | 12 | end |
14 | 13 | |
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 | + | |
15 | 29 | 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 | |
17 | 37 | a.approve = 1 |
18 | 38 | a.save! |
19 | 39 | end |
@@ -31,7 +31,7 @@ | ||
31 | 31 | </div> |
32 | 32 | <div> |
33 | 33 | <%= link_to "browse", :controller => '/system', :action => :browse%> |
34 | - <%= link_to "approbe", :controller => '/system', :action => :approbe%> | |
34 | + <%= link_to "approve", :controller => '/system', :action => :waiting_list%> | |
35 | 35 | <%= link_to "token", :controller => '/system', :action => :auth_token%> |
36 | 36 | </div> |
37 | 37 | <%= yield %> |
@@ -2,7 +2,14 @@ | ||
2 | 2 | <p class="notice"><%= notice %></p> |
3 | 3 | <p class="alert"><%= alert %></p> |
4 | 4 | </div> |
5 | +<div> | |
5 | 6 | authentication_token:<%= current_admin.authentication_token %> |
7 | +</div> | |
6 | 8 | |
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> |
@@ -6,6 +6,9 @@ | ||
6 | 6 | <%= link_to 'browse', :action => :browse %> |
7 | 7 | </div> |
8 | 8 | <div> |
9 | + <%= link_to 'approve', :action => :waiting_list %> | |
10 | +</div> | |
11 | +<div> | |
9 | 12 | <%= link_to 'auth token', :action => :auth_token %> |
10 | 13 | </div> |
11 | 14 | <div> |
@@ -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> | |
2 | 6 | |
3 | 7 | <table> |
4 | 8 | <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> | |
7 | 18 | </tr> |
8 | 19 | |
9 | -<% @artists.each do |artist| %> | |
20 | +<% @waits.each do |admin| %> | |
10 | 21 | <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> | |
13 | 32 | </tr> |
14 | 33 | <% end %> |
15 | 34 | </table> |