QA: add a list of team's exercices
This commit is contained in:
parent
911bcb032e
commit
ea334a8a2f
5 changed files with 154 additions and 23 deletions
|
@ -12,6 +12,8 @@ import (
|
|||
func init() {
|
||||
router.GET("/api/qa_exercices.json", apiHandler(getExerciceTested))
|
||||
router.GET("/api/qa_mywork.json", apiHandler(getQAWork))
|
||||
router.GET("/api/qa_myexercices.json", apiHandler(getQAView))
|
||||
router.POST("/api/qa_my_exercices.json", apiHandler(addQAView))
|
||||
router.GET("/api/qa_work.json", apiHandler(getQATodo))
|
||||
router.POST("/api/qa_work.json", apiHandler(createQATodo))
|
||||
}
|
||||
|
@ -42,6 +44,14 @@ func getExerciceTested(u QAUser, ps httprouter.Params, body []byte) (interface{}
|
|||
}
|
||||
}
|
||||
|
||||
func getQAView(u QAUser, ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
if team, err := fic.GetTeam(u.TeamId); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return team.GetQAView()
|
||||
}
|
||||
}
|
||||
|
||||
func getQAWork(u QAUser, ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
if team, err := fic.GetTeam(u.TeamId); err != nil {
|
||||
return nil, err
|
||||
|
@ -74,3 +84,20 @@ func createQATodo(u QAUser, ps httprouter.Params, body []byte) (interface{}, err
|
|||
return team.NewQATodo(ut.IdExercice)
|
||||
}
|
||||
}
|
||||
|
||||
func addQAView(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.NewQAView(ut.IdExercice)
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue