Task Attachments #104

Merged
konrad merged 63 commits from feature/attachments into master 2019-10-16 20:52:31 +00:00
5 changed files with 18 additions and 18 deletions
Showing only changes of commit 07b54d385b - Show all commits

2
go.mod
View File

@ -58,7 +58,7 @@ require (
github.com/samedi/caldav-go v3.0.0+incompatible
github.com/shurcooL/httpfs v0.0.0-20190527155220-6a4d4a70508b
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/afero v1.2.2
github.com/spf13/cobra v0.0.3
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.3.2

View File

@ -23,6 +23,7 @@ import (
"time"
)
// File holds all information about a file
type File struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
Name string `xorm:"text not null" json:"name"`
@ -38,14 +39,17 @@ type File struct {
File *multipart.FileHeader `xorm:"-" json:"-"`
}
// TableName is the table name for the files table
func (File) TableName() string {
return "files"
}
// GetFileByID returns a file by its ID
func (f *File) GetFileByID() (err error) {
return
}
// Create creates a new file from an FileHeader
func Create(f *multipart.FileHeader) (file *File, err error) {
// We first insert the file into the db to get it's ID
@ -71,6 +75,7 @@ func Create(f *multipart.FileHeader) (file *File, err error) {
return
}
// Delete removes a file from the DB and the file system
func (f *File) Delete() (err error) {
return
}

View File

@ -22,7 +22,7 @@ import (
"mime/multipart"
)
// TODO: Migration
// TaskAttachment is the definition of a task attachment
type TaskAttachment struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
TaskID int64 `xorm:"int(11) not null" json:"task_id" param:"task"`
@ -34,8 +34,12 @@ type TaskAttachment struct {
File *multipart.FileHeader `xorm:"-" json:"-"`
Created int64 `xorm:"created"`
web.CRUDable `xorm:"-" json:"-"`
web.Rights `xorm:"-" json:"-"`
}
// Create creates a new task attachment
func (ta *TaskAttachment) Create(a web.Auth) error {
// Store the file
@ -58,18 +62,17 @@ func (ta *TaskAttachment) Create(a web.Auth) error {
return nil
}
// ReadOne returns a new task attachment
func (ta *TaskAttachment) ReadOne() error {
panic("implement me")
}
// ReadAll returns a list with all attachments
func (ta *TaskAttachment) ReadAll(string, web.Auth, int) (interface{}, error) {
panic("implement me")
}
func (ta *TaskAttachment) Update() error {
panic("implement me")
}
// Delete removes an attachment
func (ta *TaskAttachment) Delete() error {
panic("implement me")
}

View File

@ -18,26 +18,17 @@ package models
import "code.vikunja.io/web"
func (ta *TaskAttachment) IsAdmin(web.Auth) (bool, error) {
panic("implement me")
}
func (ta *TaskAttachment) CanWrite(web.Auth) (bool, error) {
panic("implement me")
}
// CanRead checks if the user can see an attachment
func (ta *TaskAttachment) CanRead(web.Auth) (bool, error) {
panic("implement me")
}
// CanDelete checks if the user can delete an attachment
func (ta *TaskAttachment) CanDelete(web.Auth) (bool, error) {
panic("implement me")
}
func (ta *TaskAttachment) CanUpdate(web.Auth) (bool, error) {
panic("implement me")
}
// CanCreate checks if the user can create an attachment
func (ta *TaskAttachment) CanCreate(a web.Auth) (bool, error) {
t := Task{ID: ta.TaskID}
return t.CanCreate(a)

View File

@ -23,6 +23,7 @@ import (
"net/http"
)
// UploadTaskAttachment handles everything needed for the upload of a task attachment
func UploadTaskAttachment(c echo.Context) error {
var taskAttachment models.TaskAttachment