Add basic crud rights

Signed-off-by: kolaente <k@knt.li>
This commit is contained in:
kolaente 2020-02-16 22:38:22 +01:00
parent d3a5e62cdc
commit 003cf85d05
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 23 additions and 4 deletions

View File

@ -17,5 +17,24 @@
package models
// TODO
// Rights based on the task
import "code.vikunja.io/web"
func (tc *TaskComment) CanWrite(a web.Auth) (bool, error) {
t := Task{ID: tc.ID}
return t.CanWrite(a)
}
func (tc *TaskComment) CanDelete(a web.Auth) (bool, error) {
t := Task{ID: tc.ID}
return t.CanWrite(a)
}
func (tc *TaskComment) CanUpdate(a web.Auth) (bool, error) {
t := Task{ID: tc.ID}
return t.CanWrite(a)
}
func (tc *TaskComment) CanCreate(a web.Auth) (bool, error) {
t := Task{ID: tc.ID}
return t.CanWrite(a)
}

View File

@ -28,7 +28,7 @@ type TaskComment struct {
Comment string `xorm:"text not null" json:"comment"`
AuthorID int64 `xorm:"not null" json:"-"`
Author *user.User `xorm:"extends" json:"author"`
TaskID int64 `xorm:"not null" json:"-"`
TaskID int64 `xorm:"not null" json:"-" param:"task"`
Created timeutil.TimeStamp `xorm:"created"`
Updated timeutil.TimeStamp `xorm:"updated"`

View File

@ -64,7 +64,7 @@ func (t *Task) canDoTask(a web.Auth) (bool, error) {
return false, err
}
// A user can do a task if he has write acces to its list
// A user can do a task if it has write acces to its list
l := &List{ID: lI.ListID}
return l.CanWrite(a)
}