From bb99a8917a9b7fc38f0c0847f45c68659791b54a Mon Sep 17 00:00:00 2001
From: Dave Arter
Date: Wed, 14 Dec 2016 17:31:02 +0000
Subject: Add external_id field to ResponsePriority for use with Exor
---
bin/update-schema | 1 +
db/schema.sql | 1 +
db/schema_0049-response-priorities-add-external_id.sql | 6 ++++++
perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm | 1 +
perllib/FixMyStreet/DB/Result/ResponsePriority.pm | 6 ++++--
templates/web/base/admin/responsepriorities/edit.html | 10 ++++++++++
6 files changed, 23 insertions(+), 2 deletions(-)
create mode 100644 db/schema_0049-response-priorities-add-external_id.sql
diff --git a/bin/update-schema b/bin/update-schema
index b85ff87f4..94c42d8ae 100755
--- a/bin/update-schema
+++ b/bin/update-schema
@@ -194,6 +194,7 @@ else {
# By querying the database schema, we can see where we're currently at
# (assuming schema change files are never half-applied, which should be the case)
sub get_db_version {
+ return '0049' if column_exists('response_priorities', 'external_id');
return '0048' if column_exists('response_templates', 'state');
return '0047' if column_exists('response_priorities', 'description');
return '0046' if column_exists('users', 'extra');
diff --git a/db/schema.sql b/db/schema.sql
index e54c6b7b2..23db82b65 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -135,6 +135,7 @@ CREATE TABLE response_priorities (
deleted boolean not null default 'f',
name text not null,
description text,
+ external_id text,
unique(body_id, name)
);
diff --git a/db/schema_0049-response-priorities-add-external_id.sql b/db/schema_0049-response-priorities-add-external_id.sql
new file mode 100644
index 000000000..1d8a1ba1e
--- /dev/null
+++ b/db/schema_0049-response-priorities-add-external_id.sql
@@ -0,0 +1,6 @@
+BEGIN;
+
+ALTER TABLE response_priorities
+ ADD COLUMN external_id TEXT;
+
+COMMIT;
diff --git a/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm b/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm
index a6c13c117..bae0f71a7 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm
@@ -70,6 +70,7 @@ sub edit : Path : Args(2) {
$priority->deleted( $c->get_param('deleted') ? 1 : 0 );
$priority->name( $c->get_param('name') );
$priority->description( $c->get_param('description') );
+ $priority->external_id( $c->get_param('external_id') );
$priority->update_or_insert;
my @live_contact_ids = map { $_->id } @live_contacts;
diff --git a/perllib/FixMyStreet/DB/Result/ResponsePriority.pm b/perllib/FixMyStreet/DB/Result/ResponsePriority.pm
index 6bc8474fa..44635d174 100644
--- a/perllib/FixMyStreet/DB/Result/ResponsePriority.pm
+++ b/perllib/FixMyStreet/DB/Result/ResponsePriority.pm
@@ -26,6 +26,8 @@ __PACKAGE__->add_columns(
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
"description",
{ data_type => "text", is_nullable => 1 },
+ "external_id",
+ { data_type => "text", is_nullable => 1 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("response_priorities_body_id_name_key", ["body_id", "name"]);
@@ -49,8 +51,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-10-17 16:37:28
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wok3cPA7cPjG4e9lnc1PIg
+# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-12-14 17:12:09
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:glsO0fLK6fNvg4TmW1DMPg
__PACKAGE__->many_to_many( contacts => 'contact_response_priorities', 'contact' );
diff --git a/templates/web/base/admin/responsepriorities/edit.html b/templates/web/base/admin/responsepriorities/edit.html
index 4d838eed2..a4dc61213 100644
--- a/templates/web/base/admin/responsepriorities/edit.html
+++ b/templates/web/base/admin/responsepriorities/edit.html
@@ -18,6 +18,16 @@
+
+
+ [% loc('If this priority is passed to an external service (e.g. Exor/Confirm) enter the priority code to use with that service here.') %]
+
+
+
+ [% loc('External ID:') %]
+
+
+
[% loc('If you only want this priority to be an option for specific categories, pick them here. By default they will show for all categories.') %]
--
cgit v1.2.3