Skip to content

Commit

Permalink
Add Division ID
Browse files Browse the repository at this point in the history
Returns the Division ID in the output JSON
  • Loading branch information
pol-ak committed Nov 25, 2024
1 parent d7a8fba commit 94850c5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions app/controllers/api/v1/divisions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ class DivisionsController < ApplicationController
#Deshabilita CSRF protection
skip_before_action :verify_authenticity_token, only: [:add_address, :remove_address]

=begin
def index
#seed_commons_id = Division.find_by(name: "Seed Commons").id
seed_commons_division_ids = Division.find_by(name: "Seed Commons").self_and_descendants.pluck(:id)
#divisions = Division.includes(address: [:country, :geo_state]).where(parent_id: seed_commons_id, public: true)
divisions = Division.includes(address: [:country, :geo_state]).where(parent_id: seed_commons_division_ids, public: true)
render json: divisions.map { |division| format_division(division) }
end
=end

=begin
def index
divisions = [
{
Expand Down Expand Up @@ -333,6 +332,7 @@ def index
render json: divisions
end
=end

# POST /api/v1/divisions/:id/address
def add_address
Expand Down Expand Up @@ -368,8 +368,10 @@ def set_division
end
end

=begin
def format_division(division)
{
id: division.id,
name: division.name,
public_url: public_division_url(division.short_name),
website: division.homepage,
Expand All @@ -384,6 +386,19 @@ def format_division(division)
labely: division.address&.geo_labely
}
end
=end

def format_division(division)
{
id: division.id,
division: division.name,
lat: division.address&.geo_lat,
long: division.address&.geo_long,
movex: division.address&.geo_labelx,
movey: division.address&.geo_labely,
website: division.homepage
}
end

def authenticate_api_user
authenticate_or_request_with_http_basic do |username, password|
Expand Down

0 comments on commit 94850c5

Please sign in to comment.