qa: Add todo list on home page
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a237936feb
commit
42d594ccac
5 changed files with 159 additions and 1 deletions
49
qa/api/todo.go
Normal file
49
qa/api/todo.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
func init() {
|
||||
router.GET("/api/qa_mywork.json", apiHandler(getQAWork))
|
||||
router.GET("/api/qa_work.json", apiHandler(getQATodo))
|
||||
router.POST("/api/qa_work.json", apiHandler(createQATodo))
|
||||
}
|
||||
|
||||
func getQAWork(u QAUser, ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
if team, err := fic.GetTeam(u.TeamId); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return team.GetQAQueries()
|
||||
}
|
||||
}
|
||||
|
||||
func getQATodo(u QAUser, ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
if team, err := fic.GetTeam(u.TeamId); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return team.GetQATodo()
|
||||
}
|
||||
}
|
||||
|
||||
func createQATodo(u QAUser, ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
if u.User != "nemunaire" {
|
||||
return nil, errors.New("Restricted")
|
||||
}
|
||||
|
||||
var ut fic.QATodo
|
||||
if err := json.Unmarshal(body, &ut); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if team, err := fic.GetTeam(ut.IdTeam); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return team.NewQATodo(ut.IdExercice)
|
||||
}
|
||||
}
|
||||
Reference in a new issue