summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-03-16 00:03:37 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-03-16 00:03:37 (GMT)
commit46dd82ebbdac86701aedccc7712ef396da459507 (patch)
tree57f424aeb4ab2996e34430c14f092a5fb066cbc4 /rhimport
parent6580b4e76f288c2a2591f25bc916f7a728816609 (diff)
fix creation of carts for shows
Diffstat (limited to 'rhimport')
-rw-r--r--rhimport/importer.go25
1 files changed, 17 insertions, 8 deletions
diff --git a/rhimport/importer.go b/rhimport/importer.go
index 4473ee4..73d446e 100644
--- a/rhimport/importer.go
+++ b/rhimport/importer.go
@@ -393,20 +393,29 @@ func clearShowCarts(ctx *Context, res *Result, carts []uint) (err error) {
}
func addShowCartCut(ctx *Context, res *Result, carts []uint) (err error) {
- if err = addCart(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
- return
+ if ctx.Cart != 0 {
+ return addCartCut(ctx, res)
}
+
for _, cart := range carts {
- if cart == ctx.Cart {
- if err = addCut(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
- return removeCart(ctx, &Result{ResponseCode: http.StatusOK})
+ ctx.Cart = cart
+ if err = addCart(ctx, res); err != nil {
+ return
+ }
+ switch res.ResponseCode {
+ case http.StatusOK:
+ {
+ if err = addCut(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
+ return removeCart(ctx, &Result{ResponseCode: http.StatusOK})
+ }
+ return
}
+ case http.StatusForbidden: // Cart already exists
+ continue
+ default:
return
}
}
- if err = removeCart(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
- return
- }
res.ResponseCode = http.StatusForbidden
res.ErrorString = fmt.Sprintf("Show %d has no free carts left", ctx.ShowId)
return