OSDN Git Service

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