Add setting of is_local to organisations

This commit is contained in:
Tom Bloor 2017-10-24 15:23:09 +01:00
parent d881b3f95f
commit ef36cbc541
3 changed files with 24 additions and 4 deletions

View file

@ -35,6 +35,7 @@ sub add_org_submit {
$validation->optional('sector');
$validation->optional('postcode')->postcode;
$validation->optional('pending');
$validation->optional('is_local');
if ( $validation->has_error ) {
$c->flash( error => 'The validation has failed' );
@ -53,6 +54,7 @@ sub add_org_submit {
postcode => $validation->param('postcode'),
submitted_by_id => $c->current_user->id,
pending => defined $validation->param('pending') ? 0 : 1,
is_local => $validation->param('is_local'),
},
type => 'organisation',
});
@ -94,6 +96,7 @@ sub valid_edit {
$validation->optional('sector');
$validation->required('postcode')->postcode;
$validation->optional('pending');
$validation->optional('is_local');
if ( $validation->has_error ) {
$c->flash( error => 'The validation has failed' );
@ -111,6 +114,7 @@ sub valid_edit {
sector => $validation->param('sector'),
postcode => $validation->param('postcode'),
pending => defined $validation->param('pending') ? 0 : 1,
is_local => $validation->param('is_local'),
});
} );
} finally {

View file

@ -28,6 +28,13 @@
% if ( $org_result->pending ) {
<span class="badge badge-warning">Unvalidated</span>
% }
% if ( !defined $org_result->is_local ) {
<span class="badge badge-danger">Locality Not Set</span>
% } elsif ( $org_result->is_local ) {
<span class="badge badge-success">Local Org</span>
% } else {
<span class="badge badge-warning">Non Local Org</span>
% }
</div>
</a>
% }

View file

@ -57,25 +57,34 @@ function initMap() {
</div>
</div>
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label">Sector</label>
<label for="sector" class="col-md-4 col-form-label">Sector</label>
<div class="col-md-8">
<select class="form-control" name="sector">
<select id="sector" class="form-control" name="sector">
%= include 'partials/sector_options', selected_sector => $valid_org->sector || '';
</select>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label">Postcode</label>
<label for="postcode" class="col-md-4 col-form-label">Postcode</label>
<div class="col-md-8">
<input id="postcode" type="text" class="form-control" placeholder="Postcode" name="postcode" value="<%= $valid_org->postcode %>">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label">Validated</label>
<label for="pending" class="col-md-4 col-form-label">Validated</label>
<div class="col-md-8">
<input id="pending" type="checkbox" name="pending" value="0"<%= $valid_org->pending ? '' : ' checked' %>>
</div>
</div>
<div class="form-group row">
<label for="local" class="col-md-4 col-form-label">Is Local</label>
<div class="col-md-8">
<select id="local" class="form-control" name="is_local">
<option value="0"<%= !$valid_org->is_local ? '' : ' selected' %>>Non Local</option>
<option value="1"<%= $valid_org->is_local ? ' selected' : '' %>>Local</option>
</select>
</div>
</div>
<div class="form-group row">
<div class="ml-auto col-md-8">
<button class="btn btn-success btn-block" type="submit">Save Changes To Organisation</button>