Kanban #393

Merged
konrad merged 14 commits from feature/kanban into master 2020-04-19 07:27:29 +00:00
2 changed files with 17 additions and 8 deletions
Showing only changes of commit 2da2837942 - Show all commits

View File

@ -26,17 +26,20 @@ import (
// Bucket represents a kanban bucket
type Bucket struct {
// The unique, numeric id of this bucket.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"bucket"`
Title string `xorm:"text not null" valid:"runelength(1|)" minLength:"1" json:"title"`
ListID int64 `xorm:"int(11) not null" json:"list_id"`
Tasks []*Task `xorm:"-" json:"tasks"`
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"bucket"`
// The title of this bucket.
Title string `xorm:"text not null" valid:"runelength(1|)" minLength:"1" json:"title"`
// The list this bucket belongs to.
ListID int64 `xorm:"int(11) not null" json:"list_id"`
// All tasks which belong to this bucket.
Tasks []*Task `xorm:"-" json:"tasks"`
// A timestamp when this task was created. You cannot change this value.
// A timestamp when this bucket was created. You cannot change this value.
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
// A timestamp when this task was last updated. You cannot change this value.
// A timestamp when this bucket was last updated. You cannot change this value.
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
// The user who initially created the task.
// The user who initially created the bucket.
CreatedBy *user.User `xorm:"-" json:"created_by" valid:"-"`
CreatedByID int64 `xorm:"int(11) not null" json:"-"`
@ -44,6 +47,7 @@ type Bucket struct {
web.CRUDable `xorm:"-" json:"-"`
}
// TableName returns the table name for this bucket.
func (b *Bucket) TableName() string {
return "buckets"
}

View File

@ -18,18 +18,23 @@ package models
import "code.vikunja.io/web"
// CanCreate checks if a user can create a new bucket
func (b *Bucket) CanCreate(a web.Auth) (bool, error) {
return b.canDoBucket(a)
l := &List{ID: b.ListID}
return l.CanWrite(a)
}
// CanUpdate checks if a user can update an existing bucket
func (b *Bucket) CanUpdate(a web.Auth) (bool, error) {
return b.canDoBucket(a)
}
// CanDelete checks if a user can delete an existing bucket
func (b *Bucket) CanDelete(a web.Auth) (bool, error) {
return b.canDoBucket(a)
}
// canDoBucket checks if the bucket exists and if the user has the right to act on it
func (b *Bucket) canDoBucket(a web.Auth) (bool, error) {
bb, err := getBucketByID(b.ID)
if err != nil {