feat(views): use project id when fetching views
This commit is contained in:
parent
98b7cc9254
commit
38457aaca5
@ -113,7 +113,7 @@ func (p *ProjectView) ReadAll(s *xorm.Session, a web.Auth, _ string, _ int, _ in
|
|||||||
// @Failure 500 {object} models.Message "Internal error"
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
// @Router /projects/{project}/views/{id} [get]
|
// @Router /projects/{project}/views/{id} [get]
|
||||||
func (p *ProjectView) ReadOne(s *xorm.Session, _ web.Auth) (err error) {
|
func (p *ProjectView) ReadOne(s *xorm.Session, _ web.Auth) (err error) {
|
||||||
view, err := GetProjectViewByID(s, p.ID)
|
view, err := GetProjectViewByID(s, p.ID, p.ProjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ func (p *ProjectView) Create(s *xorm.Session, a web.Auth) (err error) {
|
|||||||
// @Router /projects/{project}/views/{id} [post]
|
// @Router /projects/{project}/views/{id} [post]
|
||||||
func (p *ProjectView) Update(s *xorm.Session, _ web.Auth) (err error) {
|
func (p *ProjectView) Update(s *xorm.Session, _ web.Auth) (err error) {
|
||||||
// Check if the project view exists
|
// Check if the project view exists
|
||||||
_, err = GetProjectViewByID(s, p.ID)
|
_, err = GetProjectViewByID(s, p.ID, p.ProjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -189,9 +189,9 @@ func (p *ProjectView) Update(s *xorm.Session, _ web.Auth) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetProjectViewByID(s *xorm.Session, id int64) (view *ProjectView, err error) {
|
func GetProjectViewByID(s *xorm.Session, id, projectID int64) (view *ProjectView, err error) {
|
||||||
exists, err := s.
|
exists, err := s.
|
||||||
Where("id = ?", id).
|
Where("id = ? AND project_id = ?", id, projectID).
|
||||||
NoAutoCondition().
|
NoAutoCondition().
|
||||||
Get(view)
|
Get(view)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -172,7 +172,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tf.ProjectViewID != 0 {
|
if tf.ProjectViewID != 0 {
|
||||||
view, err := GetProjectViewByID(s, tf.ProjectViewID)
|
view, err := GetProjectViewByID(s, tf.ProjectViewID, tf.ProjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, 0, err
|
return nil, 0, 0, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user