OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / controllers / system_controller.rb
index a466600..f5f8d95 100644 (file)
@@ -1,28 +1,27 @@
 class SystemController < ApplicationController
-  before_filter :authenticate_admin!, :except => [:start]
+  before_action :authenticate_admin!, :except => [:start]
   
   #layout :system
   
   def start
-    OriginalPicture.all.each do |a|
-      a.lisence_id = 1 if a.lisence_id.blank?
-      a.save
-    end
-    ResourcePicture.all.each do |a|
-      a.lisence_id = 1 if a.lisence_id.blank?
-      a.artist_id = 1 if a.artist_id.blank?
-      a.save
-    end
-    Artist.all.each do |a|
-      a.default_lisence_id = 1 if a.default_lisence_id.blank?
-      a.save
-    end
   end
   
   def index
   end
   
-  def browse
+  def import
+  end
+  
+  def reload_manifest
+    Manifest::load JSON.parse(open(Rails.root + 'public/manifest.json').read)
+    Manifest.manifest.init
+    LocalManifest::load JSON.parse(open(Rails.root + 'public/local_manifest.json').read)
+    LocalManifest.manifest.init
+    Manifest.manifest.init_after_load_manifest
+    Manifest.manifest.load_models_manifest
+    respond_to do |format|
+      format.html { redirect_to({:action => :index}) }
+    end
   end
   
   def auth_token
@@ -32,17 +31,24 @@ class SystemController < ApplicationController
     @admin = current_admin
     respond_to do |format|
       if @admin.create_token
-        format.html { redirect_to({:action => :auth_token}, {:notice => 'admin token was successfully created.'}) }
+        flash[:notice] = I18n.t('flash.notice.created', :model => Admin.human_attribute_name(:authentication_token))
+        format.html { redirect_to({:action => :auth_token}) }
       else
+        flash[:notice] = I18n.t('flash.notice.not_created', :model => Admin.human_attribute_name(:authentication_token))
         format.html { render action: "auth_token" }
       end
     end
   end
   
   def delete_token
-    current_admin.delete_token
     respond_to do |format|
-      format.html { redirect_to :action => :auth_token}
+      if current_admin.delete_token
+        flash[:notice] = I18n.t('flash.notice.destroyed', :model => Admin.human_attribute_name(:authentication_token))
+        format.html { redirect_to :action => :auth_token}
+      else
+        flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Admin.human_attribute_name(:authentication_token))
+        format.html { render action: "auth_token" }
+      end
     end
   end
   
@@ -58,7 +64,7 @@ class SystemController < ApplicationController
   end
   
   def waiting_list
-    @waits = Admin.find(:all, :conditions => ['approve = 0'])
+    @waits = Admin.where(approve: 0)
   end
   
   def accept_admin