Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.7 KiB

CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
class LocationsController < ApplicationController
include Pagy::Backend
before_action :authenticate_user!
before_action :authenticate_scope!
before_action :find_location, except: %i[new create index]
before_action :find_scheme
before_action :authenticate_action!
include Modules::SearchFilter
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
def index
@pagy, @locations = pagy(filtered_collection(@scheme.locations, search_term))
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
@total_count = @scheme.locations.size
@searched = search_term.presence
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
end
def new
@location = Location.new
end
def create
if date_params_missing?(location_params) || valid_date_params?(location_params)
@location = Location.new(location_params)
if @location.save
if location_params[:add_another_location] == "Yes"
redirect_to new_location_path(@scheme)
else
check_answers_path = @scheme.confirmed? ? scheme_check_answers_path(@scheme, anchor: "locations") : scheme_check_answers_path(@scheme)
redirect_to check_answers_path
end
else
render :new, status: :unprocessable_entity
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
else
@location = Location.new(location_params.except("startdate(3i)", "startdate(2i)", "startdate(1i)"))
@location.valid?
@location.errors.add(:startdate)
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
render :new, status: :unprocessable_entity
end
end
def edit
render_not_found and return unless @location && @scheme
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
def edit_name
render_not_found and return unless @location && @scheme
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
def update
render_not_found and return unless @location && @scheme
page = params[:location][:page]
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
if @location.update(location_params)
case page
when "edit"
location_params[:add_another_location] == "Yes" ? redirect_to(new_location_path(@location.scheme)) : redirect_to(scheme_check_answers_path(@scheme, anchor: "locations"))
when "edit-name"
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations"))
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
else
render :edit, status: :unprocessable_entity
end
end
private
def valid_date_params?(location_params)
is_integer?(location_params["startdate(1i)"]) && is_integer?(location_params["startdate(2i)"]) && is_integer?(location_params["startdate(3i)"]) &&
Date.valid_date?(location_params["startdate(1i)"].to_i, location_params["startdate(2i)"].to_i, location_params["startdate(3i)"].to_i)
end
def date_params_missing?(location_params)
location_params["startdate(1i)"].blank? || location_params["startdate(2i)"].blank? || location_params["startdate(3i)"].blank?
end
def is_integer?(string)
2 years ago
string.sub(/^0+/, "").to_i.to_s == string.sub(/^0+/, "")
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
def find_scheme
@scheme = if %w[new create index edit_name].include?(action_name)
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
Scheme.find(params[:id])
else
@location&.scheme
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
end
end
def find_location
@location = params[:location_id].present? ? Location.find_by(id: params[:location_id]) : Location.find_by(id: params[:id])
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
end
def authenticate_scope!
head :unauthorized and return unless current_user.data_coordinator? || current_user.support?
end
def authenticate_action!
if %w[new edit update create index edit_name].include?(action_name) && !((current_user.organisation == @scheme&.owning_organisation) || current_user.support?)
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
render_not_found and return
end
end
def location_params
required_params = params.require(:location).permit(:postcode, :name, :units, :type_of_unit, :add_another_location, :startdate, :mobility_type).merge(scheme_id: @scheme.id)
required_params[:postcode] = PostcodeService.clean(required_params[:postcode]) if required_params[:postcode]
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
required_params
end
def search_term
params["search"]
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
end