-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a scoped endpoint for constituencies
This is so the petition map can show the correct list for archived petitions.
- Loading branch information
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
class ConstituenciesController < ApplicationController | ||
before_action :set_cors_headers, only: [:index], if: :json_request? | ||
before_action :fetch_parliament, only: [:index] | ||
|
||
def index | ||
@constituencies = Constituency.current.by_ons_code | ||
@constituencies = @parliament.constituencies.by_ons_code | ||
|
||
respond_to do |format| | ||
format.json | ||
end | ||
end | ||
|
||
private | ||
|
||
def fetch_parliament | ||
case params[:period] | ||
when Parliament::PERIOD_FORMAT | ||
@parliament = Parliament.archived.find_by!(period: params[:period]) | ||
else | ||
@parliament = Parliament.instance | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters