diff --git a/http/good_show.go b/http/good_show.go index 1e649a2..e6ce652 100644 --- a/http/good_show.go +++ b/http/good_show.go @@ -60,7 +60,8 @@ func getGoodAvailablityCount(w http.ResponseWriter, r *http.Request) (int, *logr return -1, log } var count float64 - (&models.Good{}).FilterAvailable(database.Read.Where("product_id = ?", id)).Count(&count) + var g models.Good + g.FilterAvailable(database.Read).Where("product_id = ?", id).Count(&count) return int(count), log } @@ -70,7 +71,7 @@ func getGoodAvailability(w http.ResponseWriter, r *http.Request) { if count < 0 { return } - log = log.WithField("type", r.Header.Get("Content-Type")) + log = log.WithField("c", count).WithField("type", r.Header.Get("Content-Type")) switch r.Header.Get("Content-Type") { case "application/json": lib.Write(w, count) diff --git a/http/good_test.go b/http/good_test.go index d0db782..b9e5f93 100644 --- a/http/good_test.go +++ b/http/good_test.go @@ -2,6 +2,7 @@ package http import ( + "fmt" "net/http" "testing" "time" @@ -86,7 +87,6 @@ func TestAddGood(t *testing.T) { test.Close() } -/* // Function to test delGood() func TestDelGood(t *testing.T) { assertion, router := test.Init(t) @@ -127,4 +127,3 @@ func TestDelGood(t *testing.T) { test.Close() } -*/ diff --git a/webroot/static/js/item-add.controller.js b/webroot/static/js/item-add.controller.js index 935a527..fb1d381 100644 --- a/webroot/static/js/item-add.controller.js +++ b/webroot/static/js/item-add.controller.js @@ -14,9 +14,9 @@ angular.module('microStock') $scope.submit = function(){ $http.post(config.store.goods.productById.replace("%d",$stateParams.productid)+'?count='+$scope.count,$scope.obj).then(function(){ $scope.obj = {}; - $scope.msg = {type:'success',text:'Saved '+count+' good(s) from product '+$scope.product.title+'.'}; + $scope.msg = {type:'success',text:'Saved '+$scope.count+' good(s) from product '+$scope.product.title+'.'}; }, function(){ - $scope.msg = {type:'error',text:'Error: Saved '+count+' good(s) from product '+$scope.product.title+'.'}; + $scope.msg = {type:'error',text:'Error: Saved '+$scope.count+' good(s) from product '+$scope.product.title+'.'}; }); }; }]);