Sha256: f1f2c4ac1cf927a8456fd195535acf180c47639eeb31f9012625ccb91c5da76b

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

require_dependency "ishapi/application_controller"

class Ishapi::MapsController < Ishapi::ApplicationController
  before_action :check_profile, only: [ :show ]

  def show
    @location   = ::Gameui::Map.where( slug: params[:slug] ).first
    @location ||= ::Gameui::Map.find params[:slug]
    @map = @location.map || @location

    authorize! :show, @map

    @newsitems = @location.newsitems.page( params[:newsitems_page]
      ).per( @location.newsitems_page_size )

    @markers = @map.markers.permitted_to(@current_profile).order_by(ordering: :asc)
    # case @map.ordering_type
    # when ::Gameui::Map::ORDERING_TYPE_ALPHABETIC
    #   @markers = @markers.order_by( name: :asc )
    # when ::Gameui::Map::ORDERING_TYPE_CUSTOM
    #   @markers = @markers.order_by( ordering: :asc )
    # end

    if @map.is_premium && !@current_profile.has_premium_purchase( @map )
      render 'show_restricted'
    else
      render 'show'
    end
  end

  def show_marker
    @marker = ::Gameui::Marker.find_by slug: params[:slug]
    authorize! :show, @marker
    render json: @marker
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ishapi-0.1.8.201 app/controllers/ishapi/maps_controller.rb
ishapi-0.1.8.200 app/controllers/ishapi/maps_controller.rb
ishapi-0.1.8.199 app/controllers/ishapi/maps_controller.rb
ishapi-0.1.8.197 app/controllers/ishapi/maps_controller.rb
ishapi-0.1.8.196 app/controllers/ishapi/maps_controller.rb
ishapi-0.1.8.195 app/controllers/ishapi/maps_controller.rb