OSDN Git Service

03d3595149a64110d44c5f6dd97aed0abc6eec81
[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   end
8   
9   def index
10   end
11   
12   def import
13   end
14   
15   def reload_manifest
16     Manifest::load JSON.parse(open(Rails.root + 'public/manifest.json').read)
17     Manifest.manifest.init
18     respond_to do |format|
19       format.html { redirect_to({:action => :index}) }
20     end
21   end
22   
23   def auth_token
24   end
25   
26   def create_token
27     @admin = current_admin
28     respond_to do |format|
29       if @admin.create_token
30         flash[:notice] = I18n.t('flash.notice.created', :model => Admin.human_attribute_name(:authentication_token))
31         format.html { redirect_to({:action => :auth_token}) }
32       else
33         flash[:notice] = I18n.t('flash.notice.not_created', :model => Admin.human_attribute_name(:authentication_token))
34         format.html { render action: "auth_token" }
35       end
36     end
37   end
38   
39   def delete_token
40     respond_to do |format|
41       if current_admin.delete_token
42         flash[:notice] = I18n.t('flash.notice.destroyed', :model => Admin.human_attribute_name(:authentication_token))
43         format.html { redirect_to :action => :auth_token}
44       else
45         flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Admin.human_attribute_name(:authentication_token))
46         format.html { render action: "auth_token" }
47       end
48     end
49   end
50   
51   def approve
52     @admin = Admin.find params[:id]
53     respond_to do |format|
54       if @admin.apv
55         format.html { redirect_to({:action => :waiting_list}, {:notice => 'admin was successfully approved.'}) }
56       else
57         format.html { render action: "waiting_list" }
58       end
59     end
60   end
61   
62   def waiting_list
63     @waits = Admin.find(:all, :conditions => ['approve = 0'])
64   end
65   
66   def accept_admin
67     @newadmin = Admin.find params[:id]
68     if admin_signed_in? and current_admin.activate
69       @newadmin.activate = 1
70       @newadmin.save
71     else
72     end
73   end
74   
75   def production_layout
76     MagicNumber['test_layout'] = false
77     respond_to do |format|
78       format.html { render text: 'production', status: 200 }
79     end
80   end
81   
82   def test_layout
83     MagicNumber['test_layout'] = 'test'
84     respond_to do |format|
85       format.html { render text: 'test', status: 200 }
86     end
87   end
88   
89 end