diff --git a/Gemfile b/Gemfile index b4af2e714..603a3dbeb 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,7 @@ gem "russian" gem "grit" gem 'whenever', :require => false gem 'delayed_job' +gem 'whenever', :require => false gem 'unicorn' group :production do diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 22378cc2d..5af2cd547 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,10 +2,10 @@ class ApplicationController < ActionController::Base protect_from_forgery layout :layout_by_resource + private def get_role(object_id, object_type, target_id, target_type) - rel=Relation.where(:object_id=>object_id, :object_type=>object_type, :target_id=>target_id, :target_type=>target_type).first - return (rel) ? rel.roles : nil + Relation.where(:object_id=>object_id, :object_type=>object_type, :target_id=>target_id, :target_type=>target_type).first.try(:roles) end def checkaccess diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index 9494dd461..b94ba4b5c 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -7,7 +7,20 @@ class PlatformsController < ApplicationController before_filter :get_paths, :only => [:new, :create] def index - @platforms = Platform.paginate(:page => params[:platform_page]) + respond_to do |format| + format.html { @platforms = Platform.paginate(:page => params[:platform_page]) } + format.json do + @platforms = Platform.where(:distrib_type => 'mandriva', :visibility => 'open', :platform_type => 'main') + render :json => { + :platforms => @platforms.map do |p| + {:name => p.name, + :architectures => ['i586', 'x86_64'], + :repositories => p.repositories.map(&:name), + :url => "http://abs.rosalab.ru/downloads/platforms/#{p.name}/repository"} + end + } + end + end end def show