Sha256: 9470bd95aba080565bfb987fa40b6c2eda3156674b1aa1257004d21304de883d

Contents?: true

Size: 1.46 KB

Versions: 69

Compression:

Stored size: 1.46 KB

Contents

require_dependency "ishapi/application_controller"

##
## supersedes Ishapi::MapsController
##
class Ishapi::LocationsController < Ishapi::ApplicationController

  before_action :check_profile # , only: [ :show, :show_marker ]

  def show
    if 'self' == params[:slug] # @TODO: constantize _vp_ 2023-01-11
      @location = ::Gameui::Map.where( slug: @current_profile[:email] ).first
    else
      @location   = ::Gameui::Map.where( slug: params[:slug] ).first
      @location ||= ::Gameui::Map.find params[:slug]
    end

    authorize! :show, @location
    map = @location.map || @location # @TODO: remove _vp_ 2023-03-20

    @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
      respond_to do |format|
        format.json do
          render 'show'
        end
        format.html do
          render 'show'
        end
      end
    end
  end

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

end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
ishapi-0.1.8.316 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.315 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.314 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.313 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.312 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.310 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.309 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.308 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.307 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.306 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.305 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.304 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.303 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.302 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.301 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.300 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.298 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.297 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.296 app/controllers/ishapi/locations_controller.rb
ishapi-0.1.8.295 app/controllers/ishapi/locations_controller.rb