Fix lint
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
This commit is contained in:
parent
1a4d652efe
commit
c0c1322c89
|
@ -68,6 +68,17 @@ func getSavedFilterIDFromListID(listID int64) (filterID int64) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create creates a new saved filter
|
||||||
|
// @Summary Creates a new saved filter
|
||||||
|
// @Description Creates a new saved filter
|
||||||
|
// @tags filter
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Success 200 {object} models.SavedFilter "The Saved Filter"
|
||||||
|
// @Failure 403 {object} web.HTTPError "The user does not have access to that saved filter."
|
||||||
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
|
// @Router /filters [put]
|
||||||
func (s *SavedFilter) Create(auth web.Auth) error {
|
func (s *SavedFilter) Create(auth web.Auth) error {
|
||||||
s.OwnerID = auth.GetID()
|
s.OwnerID = auth.GetID()
|
||||||
_, err := x.Insert(s)
|
_, err := x.Insert(s)
|
||||||
|
@ -79,6 +90,18 @@ func getSavedFilterSimpleByID(id int64) (s *SavedFilter, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadOne returns one saved filter
|
||||||
|
// @Summary Gets one saved filter
|
||||||
|
// @Description Returns a saved filter by its ID.
|
||||||
|
// @tags filter
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Param id path int true "Filter ID"
|
||||||
|
// @Success 200 {object} models.SavedFilter "The Saved Filter"
|
||||||
|
// @Failure 403 {object} web.HTTPError "The user does not have access to that saved filter."
|
||||||
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
|
// @Router /filters/{id} [get]
|
||||||
func (s *SavedFilter) ReadOne() error {
|
func (s *SavedFilter) ReadOne() error {
|
||||||
// s already contains almost the full saved filter from the rights check, we only need to add the user
|
// s already contains almost the full saved filter from the rights check, we only need to add the user
|
||||||
u, err := user.GetUserByID(s.OwnerID)
|
u, err := user.GetUserByID(s.OwnerID)
|
||||||
|
@ -86,17 +109,37 @@ func (s *SavedFilter) ReadOne() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadAll returns all tasks of a saved filter.
|
// Update updates an existing filter
|
||||||
// Since saved filters are shown in a pseudo-namespace, we can use this function to get all tasks
|
// @Summary Updates a saved filter
|
||||||
func (s *SavedFilter) ReadAll(auth web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) {
|
// @Description Updates a saved filter by its ID.
|
||||||
return
|
// @tags filter
|
||||||
}
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Param id path int true "Filter ID"
|
||||||
|
// @Success 200 {object} models.SavedFilter "The Saved Filter"
|
||||||
|
// @Failure 403 {object} web.HTTPError "The user does not have access to that saved filter."
|
||||||
|
// @Failure 404 {object} web.HTTPError "The saved filter does not exist."
|
||||||
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
|
// @Router /filters/{id} [post]
|
||||||
func (s *SavedFilter) Update() error {
|
func (s *SavedFilter) Update() error {
|
||||||
_, err := x.Where("id = ?", s.ID).Update(s)
|
_, err := x.Where("id = ?", s.ID).Update(s)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete removes a saved filter
|
||||||
|
// @Summary Removes a saved filter
|
||||||
|
// @Description Removes a saved filter by its ID.
|
||||||
|
// @tags filter
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Param id path int true "Filter ID"
|
||||||
|
// @Success 200 {object} models.SavedFilter "The Saved Filter"
|
||||||
|
// @Failure 403 {object} web.HTTPError "The user does not have access to that saved filter."
|
||||||
|
// @Failure 404 {object} web.HTTPError "The saved filter does not exist."
|
||||||
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
|
// @Router /filters/{id} [delete]
|
||||||
func (s *SavedFilter) Delete() error {
|
func (s *SavedFilter) Delete() error {
|
||||||
_, err := x.Where("id = ?", s.ID).Delete(s)
|
_, err := x.Where("id = ?", s.ID).Delete(s)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -18,19 +18,23 @@ package models
|
||||||
|
|
||||||
import "code.vikunja.io/web"
|
import "code.vikunja.io/web"
|
||||||
|
|
||||||
|
// CanRead checks if a user has the right to read a saved filter
|
||||||
func (s *SavedFilter) CanRead(auth web.Auth) (bool, int, error) {
|
func (s *SavedFilter) CanRead(auth web.Auth) (bool, int, error) {
|
||||||
can, err := s.canDoFilter(auth)
|
can, err := s.canDoFilter(auth)
|
||||||
return can, int(RightAdmin), err
|
return can, int(RightAdmin), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanDelete checks if a user has the right to delete a saved filter
|
||||||
func (s *SavedFilter) CanDelete(auth web.Auth) (bool, error) {
|
func (s *SavedFilter) CanDelete(auth web.Auth) (bool, error) {
|
||||||
return s.canDoFilter(auth)
|
return s.canDoFilter(auth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanUpdate checks if a user has the right to update a saved filter
|
||||||
func (s *SavedFilter) CanUpdate(auth web.Auth) (bool, error) {
|
func (s *SavedFilter) CanUpdate(auth web.Auth) (bool, error) {
|
||||||
return s.canDoFilter(auth)
|
return s.canDoFilter(auth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanCreate checks if a user has the right to update a saved filter
|
||||||
func (s *SavedFilter) CanCreate(auth web.Auth) (bool, error) {
|
func (s *SavedFilter) CanCreate(auth web.Auth) (bool, error) {
|
||||||
if _, is := auth.(*LinkSharing); is {
|
if _, is := auth.(*LinkSharing); is {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -39,6 +43,7 @@ func (s *SavedFilter) CanCreate(auth web.Auth) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to check saved filter rights sind they all have the same logic
|
||||||
func (s *SavedFilter) canDoFilter(auth web.Auth) (can bool, err error) {
|
func (s *SavedFilter) canDoFilter(auth web.Auth) (can bool, err error) {
|
||||||
// Link shares can't view or modify saved filters, therefore we can error out right away
|
// Link shares can't view or modify saved filters, therefore we can error out right away
|
||||||
if _, is := auth.(*LinkSharing); is {
|
if _, is := auth.(*LinkSharing); is {
|
||||||
|
|
Loading…
Reference in New Issue