OSDN Git Service

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