changeset 1300:e2e87bf152bb

merge
author Markus Kottlaender <markus@intevation.de>
date Fri, 23 Nov 2018 10:24:50 +0100
parents 2738a6ae9ad8 (current diff) 6590208e3ee1 (diff)
children 2304778c4432 86be0002cd10
files
diffstat 15 files changed, 189 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/srimports.go	Fri Nov 23 10:24:29 2018 +0100
+++ b/pkg/controllers/srimports.go	Fri Nov 23 10:24:50 2018 +0100
@@ -276,7 +276,7 @@
 	result := struct {
 		Message string `json:"message"`
 	}{
-		Message: fmt.Sprintf("Token %s deletes.", token),
+		Message: fmt.Sprintf("Token %s deleted.", token),
 	}
 	SendJSON(rw, http.StatusOK, &result)
 }
--- a/pkg/models/sr.go	Fri Nov 23 10:24:29 2018 +0100
+++ b/pkg/models/sr.go	Fri Nov 23 10:24:50 2018 +0100
@@ -46,6 +46,11 @@
 
 	checkBottleneckSQL = `
 SELECT true FROM waterway.bottlenecks WHERE objnam = $1`
+
+	checkBottleneckDateUniqueSQL = `
+SELECT true FROM waterway.sounding_results sr JOIN
+  waterway.bottlenecks bn ON sr.bottleneck_id = bn.bottleneck_id
+WHERE bn.objnam = $1 AND sr.date_info = $2`
 )
 
 func (srd *SoundingResultDate) UnmarshalJSON(data []byte) error {
@@ -85,7 +90,7 @@
 		errs = append(errs, errors.New("Unexpected depth reference"))
 	}
 
-	err = conn.QueryRowContext(context.Background(),
+	err = conn.QueryRowContext(ctx,
 		checkBottleneckSQL,
 		m.Bottleneck).Scan(&b)
 	switch {
@@ -97,5 +102,17 @@
 		errs = append(errs, errors.New("Unexpected bottleneck"))
 	}
 
+	err = conn.QueryRowContext(ctx,
+		checkBottleneckDateUniqueSQL,
+		m.Bottleneck, m.Date.Time).Scan(&b)
+	switch {
+	case err == sql.ErrNoRows: // good! -> unique.
+	case err != nil:
+		errs = append(errs, err)
+	case b:
+		errs = append(errs,
+			errors.New("Sounding result for this date already exists."))
+	}
+
 	return errs
 }
--- a/schema/auth.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/auth.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de>
+
 BEGIN;
 
 --
--- a/schema/auth_tests.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/auth_tests.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de>
+
 --
 -- pgTAP test script for privileges and RLS policies
 --
--- a/schema/default_sysconfig.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/default_sysconfig.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Wilde <wilde@intevation.de>
+
 BEGIN;
 
 --
--- a/schema/gemma.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/gemma.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de> 
+
 BEGIN;
 
 --
--- a/schema/install-db.sh	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/install-db.sh	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,17 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Wilde <wilde@intevation.d>
+
+
 #!/bin/bash -e
 # Author(s):
 # Sascha Wilde <wilde@intevation.de>
--- a/schema/isrs_tests.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/isrs_tests.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de>
+
 --
 -- pgTAP test script for ISRS location code types and functions
 --
--- a/schema/manage_users.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/manage_users.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de>
+
 --
 -- Functions encapsulating user management functionality and
 -- exposing it to appropriately privileged users
--- a/schema/manage_users_tests.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/manage_users_tests.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de>
+
 --
 -- pgTAP test script for user management functions
 --
--- a/schema/roles.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/roles.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de>
+
 --
 -- Primary GEMMA roles
 --
--- a/schema/run_tests.sh	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/run_tests.sh	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de>
+
 #!/bin/sh -e
 
 dropdb --if-exists gemma_test
--- a/schema/search.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/search.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * wilde  <wilde@intevation.de>     
+
 CREATE FUNCTION search_bottlenecks(search_string text) RETURNS jsonb
   LANGUAGE plpgsql
   AS $$
--- a/schema/std_login_roles.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/std_login_roles.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Wilde <wilde@intevation.de>
+
 BEGIN;
 
 --
--- a/schema/tap_tests_data.sql	Fri Nov 23 10:24:29 2018 +0100
+++ b/schema/tap_tests_data.sql	Fri Nov 23 10:24:50 2018 +0100
@@ -1,3 +1,16 @@
+-- This is Free Software under GNU Affero General Public License v >= 3.0
+-- without warranty, see README.md and license for details.
+
+-- SPDX-License-Identifier: AGPL-3.0-or-later
+-- License-Filename: LICENSES/AGPL-3.0.txt
+
+-- Copyright (C) 2018 by via donau
+--   – Österreichische Wasserstraßen-Gesellschaft mbH
+-- Software engineering by Intevation GmbH
+
+-- Author(s):
+--  * Tom <tom@intevation.de>
+
 --
 -- Test data used in *_tests.sql scripts
 --