OSDN Git Service

t#29325:add server result
[pettanr/pettanr.git] / app / controllers / application_controller.rb
index af9271d..4ba05ae 100644 (file)
@@ -3,7 +3,11 @@ class ApplicationController < ActionController::Base
   before_filter :bf
   
   def bf
-    if Admin.count.to_i == 0 # or License.count.to_i == 0
+    @server_result = {
+      :location => {:controller => params[:controller], :action => params[:action]}
+    }
+    @server_result[:location][:id] = params[:id] if params[:id]
+    if Admin.count.to_i == 0 or License.count.to_i == 0
       if params[:controller] == 'system' and params[:action] == 'start'
       else
         redirect_to :controller => '/system', :action => 'start'
@@ -15,28 +19,51 @@ class ApplicationController < ActionController::Base
         @artist = if @author and @author.artist?
           @author.artist
         else
-          Artist.new author_id: @author.id, email: @user.email, name: @author.name, default_license_id: 1
+          Artist.new author_id: @author.id, email: @user.email, name: @author.name
         end
       end
     end
   end
   
+  def authenticate_artist
+    if @author.artist?
+      true
+    else
+      respond_to do |format|
+        format.html { redirect_to main_app.new_artist_path, :status => :found }
+        format.js { render "artists/new" }
+        format.json { 
+          raise ActiveRecord::Forbidden
+        }
+      end
+      false
+    end
+  end
+  
+  def set_image(file)
+    if file.respond_to?(:read)
+      file.read
+    else
+      Base64.decode64(file.to_s.gsub(' ', '+')) #rubyのバグ?+でデコードされるべきキャラがスペースになる
+    end
+  end
+  
 =begin
-  rescue_from ActiveRecord::RecordNotFound, :with => :render_404\r
-\r
-  private\r
-  def render_404(exception = nil)\r
-    if exception\r
-        logger.info "Rendering 404: #{exception.message}"\r
-    end\r
+  rescue_from ActiveRecord::RecordNotFound, :with => :render_404
+
+  private
+  def render_404(exception = nil)
+    if exception
+        logger.info "Rendering 404: #{exception.message}"
+    end
     respond_to do |format|
-          format.html { \r
-    render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false\r
+          format.html { 
+    render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
 }
           format.json { 
-    render :text => "404 found", :status => 404\r
+    render :text => "404 found", :status => 404
 }
-  end\r
-  end\r
-=end  \r
+  end
+  end
+=end  
 end