Compare commits

..

No commits in common. "885d161cf5f1baed291cc1d31ea9e90868492567" and "1713bd1f06f3715c0cc6a7cda78bf27474765ed4" have entirely different histories.

5 changed files with 5 additions and 20 deletions

View File

@ -9,8 +9,6 @@ The project also contains reusable Go packages with a Brother QL-series USB
printer driver and a simple BDF bitmap font renderer, as well as a few related
utilities for previewing, printing and debugging.
image::sklad.png[align="center"]
Building and Running
--------------------
Build dependencies: Go +

View File

@ -12,8 +12,6 @@
<p>Chyba: Řadu u neprázdných obalů nelze měnit.
{{ else if .ErrorCannotChangeNumber }}
<p>Chyba: Číslo obalu v řadě nelze měnit.
{{ else if .ErrorWouldContainItself }}
<p>Chyba: Obal by obsahoval sám sebe.
{{ else if .ErrorContainerInUse }}
<p>Chyba: Obal se používá.
{{ else if .Error }}
@ -29,7 +27,7 @@
<small>&laquo; <a href="container?id={{ . }}">{{ . }}</a></small>
{{ end }}
</h2>
<form method=post action="label?id={{ .Container.Id }}" target=_blank>
<form method=post action="label?id={{ .Container.Id }}">
<input type=submit value="Vytisknout štítek">
</form>
<form method=post action="container?id={{ .Container.Id }}&amp;remove">
@ -101,7 +99,7 @@
<small>&laquo; <a href="container?id={{ . }}">{{ . }}</a></small>
{{ end }}
</h3>
<form method=post action="label?id={{ .Id }}" target=_blank>
<form method=post action="label?id={{ .Id }}">
<input type=submit value="Vytisknout štítek">
</form>
<form method=post action="container?id={{ .Id }}&amp;remove">

View File

@ -163,7 +163,6 @@ var errNoSuchContainer = errors.New("no such container")
var errCannotChangeSeriesNotEmpty = errors.New(
"cannot change the series of a non-empty container")
var errCannotChangeNumber = errors.New("cannot change the number")
var errWouldContainItself = errors.New("container would contain itself")
var errContainerInUse = errors.New("container is in use")
// Find and filter out the container in O(n).
@ -205,27 +204,19 @@ func dbContainerCreate(c *Container) error {
}
func dbContainerUpdate(c *Container, updated Container) error {
newID := updated.Id()
newId := updated.Id()
if updated.Series != c.Series && len(c.Children()) > 0 {
return errCannotChangeSeriesNotEmpty
}
if updated.Number != c.Number {
return errCannotChangeNumber
}
if _, ok := indexContainer[newID]; ok && newID != c.Id() {
if _, ok := indexContainer[newId]; ok && newId != c.Id() {
return errContainerAlreadyExists
}
if updated.Parent != c.Parent {
// Relying on the invariant that we can't change the ID
// of a non-empty container.
for pv := &updated; pv.Parent != ""; pv = indexContainer[pv.Parent] {
if pv.Parent == updated.Id() {
return errWouldContainItself
}
}
indexChildren[c.Parent] = filterContainer(indexChildren[c.Parent], c)
indexChildren[newID] = append(indexChildren[newID], c)
indexChildren[newId] = append(indexChildren[newId], c)
}
*c = updated
return dbCommit()

View File

@ -130,7 +130,6 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
ErrorNoSuchContainer bool
ErrorCannotChangeSeriesNotEmpty bool
ErrorCannotChangeNumber bool
ErrorWouldContainItself bool
ErrorContainerInUse bool
Container *Container
Children []*Container
@ -142,7 +141,6 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
ErrorNoSuchContainer: err == errNoSuchContainer,
ErrorCannotChangeSeriesNotEmpty: err == errCannotChangeSeriesNotEmpty,
ErrorCannotChangeNumber: err == errCannotChangeNumber,
ErrorWouldContainItself: err == errWouldContainItself,
ErrorContainerInUse: err == errContainerInUse,
Container: container,
Children: children,

BIN
sklad.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB