1 class ApplicationController < ActionController::Base
3 layout :devise_layout if MagicNumber['test_layout']
21 :location => {:controller => params[:controller], :action => params[:action]}
23 @server_result[:location][:id] = params[:id] if params[:id]
24 if Admin.count.to_i == 0 or License.count.to_i == 0
25 if params[:controller] == 'system' and params[:action] == 'start'
27 redirect_to :controller => '/system', :action => 'start'
32 @author = @user.author
33 @artist = if @author and @author.artist?
39 @admin = if admin_signed_in?
44 @demand_user = if demand_user_signed_in?
52 def authenticate_author
56 respond_to do |format|
57 format.html { redirect_to main_app.new_author_path, :status => :found }
58 format.js { render "authors/new" }
60 raise ActiveRecord::Forbidden
67 def authenticate_artist
71 respond_to do |format|
72 format.html { redirect_to main_app.new_artist_path, :status => :found }
73 format.js { render "artists/new" }
75 raise ActiveRecord::Forbidden
83 if file.respond_to?(:read)
86 Base64.decode64(file.to_s.gsub(' ', '+'))
90 def ymd_to_time ymd_str
91 return nil if ymd_str.blank?
94 date = Time.parse(ymd_str[0..3] + '/' + ymd_str[4..5] + '/' + ymd_str[6..7])
101 def export_url demander_url, token, date
102 u = demander_url + (demander_url[-1] == '/' ? '' : '/')
103 u = URI.join(u, 'licenses_export.json?auth_token=' + token)
104 u = URI.join(u, '&date=' + date) unless date.blank?
108 def export_from_provider url
109 json = RestClient.get url
114 rescue_from ActiveRecord::RecordNotFound, :with => :render_404
117 def render_404(exception = nil)
119 logger.info "Rendering 404: #{exception.message}"
121 respond_to do |format|
123 render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
126 render :text => "404 found", :status => 404