fmt + lint + docs
This commit is contained in:
parent
9979b7e321
commit
0487889963
5 changed files with 21 additions and 9 deletions
|
@ -108,12 +108,12 @@ Teams sind global, d.h. Ein Team kann mehrere Namespaces verwalten.
|
|||
|
||||
~~Ein zu lösendes Problem: Wie regelt man die Berechtigungen um Teams zu verwalten?~~
|
||||
|
||||
* [ ] Namespaces
|
||||
* [x] Namespaces
|
||||
* [x] Erstellen
|
||||
* [x] Ansehen
|
||||
* [x] Bearbeiten
|
||||
* [x] Löschen
|
||||
* [ ] Teams hinzufügen. Der Nutzer kriegt nur Teams angezeigt die er erstellt hat.
|
||||
* [x] Teams hinzufügen. Der Nutzer kriegt nur Teams angezeigt die er erstellt hat.
|
||||
* [x] Alle Listen eines Namespaces anzeigen
|
||||
* [x] Listen
|
||||
* [x] Listen zu einem Namespace hinzufügen
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models
|
||||
|
||||
// ReadAll implements the method to read all teams of a namespace
|
||||
func (tn *TeamNamespace) ReadAll(user *User) (interface{}, error) {
|
||||
// Check if the user can read the namespace
|
||||
n, err := GetNamespaceByID(tn.NamespaceID)
|
||||
|
@ -7,7 +8,7 @@ func (tn *TeamNamespace) ReadAll(user *User) (interface{}, error) {
|
|||
return nil, err
|
||||
}
|
||||
if !n.CanRead(user) {
|
||||
return nil, ErrNeedToHaveNamespaceReadAccess{NamespaceID:tn.NamespaceID, UserID:user.ID}
|
||||
return nil, ErrNeedToHaveNamespaceReadAccess{NamespaceID: tn.NamespaceID, UserID: user.ID}
|
||||
}
|
||||
|
||||
// Get the teams
|
||||
|
@ -20,4 +21,4 @@ func (tn *TeamNamespace) ReadAll(user *User) (interface{}, error) {
|
|||
Find(&all)
|
||||
|
||||
return all, err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@ func (tn *TeamNamespace) CanCreate(user *User) bool {
|
|||
func (tn *TeamNamespace) CanDelete(user *User) bool {
|
||||
n, _ := GetNamespaceByID(tn.NamespaceID)
|
||||
return n.IsAdmin(user)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,18 @@ import (
|
|||
|
||||
const paramTagName = "param"
|
||||
|
||||
/////////////////////////
|
||||
// HOW THIS BINDER WORKS
|
||||
/////////////////////////
|
||||
// This binder binds all values inside the url to their respective fields in a struct. Those fields need to have a tag
|
||||
// "param" with the name of the url placeholder which must be the same as in routes.
|
||||
//
|
||||
// Whenever one of the standard CRUD methods is invoked, this binder is called, which enables one handler method
|
||||
// to handle all kinds of different urls with different parameters.
|
||||
/////////////////////////
|
||||
|
||||
// ParamBinder binds parameters to a struct.
|
||||
// Currently a working implementation, waiting to implement this officially into echo.
|
||||
func ParamBinder(i interface{}, c echo.Context) (err error) {
|
||||
|
||||
// Default binder
|
||||
|
@ -77,9 +89,7 @@ func ParamBinder(i interface{}, c echo.Context) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// This is kind of ugly, more a "feature proof", copied from the echo source code.
|
||||
// Workaround until the pr to implement this nativly in echo is merged.
|
||||
|
||||
// Binder represents a binder
|
||||
type Binder struct{}
|
||||
|
||||
func (b *Binder) bindData(ptr interface{}, data map[string][]string, tag string) error {
|
||||
|
@ -227,6 +237,7 @@ func setFloatField(value string, bitSize int, field reflect.Value) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// BindUnmarshaler type
|
||||
type BindUnmarshaler interface {
|
||||
// UnmarshalParam decodes and assigns a value from an form or query param.
|
||||
UnmarshalParam(param string) error
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package crud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.kolaente.de/konrad/list/models"
|
||||
"github.com/labstack/echo"
|
||||
"net/http"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ReadOneWeb is the webhandler to get one object
|
||||
|
|
Loading…
Reference in a new issue