OSDN Git Service

iroiro
[pettanr/pettanr.git] / app / controllers / system_controller.rb
1 class SystemController < ApplicationController
2   before_filter :authenticate_admin!, :except => [:start]
3   
4   #layout :system
5   
6   def start
7     OriginalPicture.all.each do |a|
8       a.lisence_id = 1 if a.lisence_id.blank?
9       a.save
10     end
11     ResourcePicture.all.each do |a|
12       a.lisence_id = 1 if a.lisence_id.blank?
13       a.artist_id = 1 if a.artist_id.blank?
14       a.save
15     end
16     Artist.all.each do |a|
17       a.default_lisence_id = 1 if a.default_lisence_id.blank?
18       a.save
19     end
20   end
21   
22   def index
23   end
24   
25   def browse
26   end
27   
28   def auth_token
29   end
30   
31   def create_token
32     @admin = current_admin
33     respond_to do |format|
34       if @admin.create_token
35         format.html { redirect_to({:action => :auth_token}, {:notice => 'admin token was successfully created.'}) }
36       else
37         format.html { render action: "auth_token" }
38       end
39     end
40   end
41   
42   def delete_token
43     current_admin.delete_token
44     respond_to do |format|
45       format.html { redirect_to :action => :auth_token}
46     end
47   end
48   
49   def approve
50     @admin = Admin.find params[:id]
51     respond_to do |format|
52       if @admin.apv
53         format.html { redirect_to({:action => :waiting_list}, {:notice => 'admin was successfully approved.'}) }
54       else
55         format.html { render action: "waiting_list" }
56       end
57     end
58   end
59   
60   def waiting_list
61     @waits = Admin.find(:all, :conditions => ['approve = 0'])
62   end
63   
64   def accept_admin
65     @newadmin = Admin.find params[:id]
66     if admin_signed_in? and current_admin.activate
67       @newadmin.activate = 1
68       @newadmin.save
69     else
70     end
71   end
72   
73 end