OSDN Git Service

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