admin: add message on claim state change and assignee change
This commit is contained in:
parent
e45a674937
commit
83b7df7e69
|
@ -106,11 +106,8 @@ func showClaim(claim fic.Claim, _ []byte) (interface{}, error) {
|
|||
}
|
||||
|
||||
type ClaimUploaded struct {
|
||||
Subject string `json:"subject"`
|
||||
Team *int64 `json:"id_team"`
|
||||
Exercice *int64 `json:"id_exercice"`
|
||||
Assignee *int64 `json:"id_assignee"`
|
||||
Priority string `json:"priority"`
|
||||
fic.Claim
|
||||
Whoami *int64 `json:"whoami"`
|
||||
}
|
||||
|
||||
func newClaim(_ httprouter.Params, body []byte) (interface{}, error) {
|
||||
|
@ -124,8 +121,8 @@ func newClaim(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
}
|
||||
|
||||
var t *fic.Team
|
||||
if uc.Team != nil {
|
||||
if team, err := fic.GetTeam(*uc.Team); err != nil {
|
||||
if uc.IdTeam != nil {
|
||||
if team, err := fic.GetTeam(*uc.IdTeam); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
t = &team
|
||||
|
@ -135,8 +132,8 @@ func newClaim(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
}
|
||||
|
||||
var e *fic.Exercice
|
||||
if uc.Exercice != nil {
|
||||
if exercice, err := fic.GetExercice(*uc.Exercice); err != nil {
|
||||
if uc.IdExercice != nil {
|
||||
if exercice, err := fic.GetExercice(*uc.IdExercice); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
e = &exercice
|
||||
|
@ -146,8 +143,8 @@ func newClaim(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
}
|
||||
|
||||
var a *fic.ClaimAssignee
|
||||
if uc.Assignee != nil {
|
||||
if assignee, err := fic.GetAssignee(*uc.Assignee); err != nil {
|
||||
if uc.IdAssignee != nil {
|
||||
if assignee, err := fic.GetAssignee(*uc.IdAssignee); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
a = &assignee
|
||||
|
@ -215,7 +212,7 @@ func updateClaimDescription(claim fic.Claim, body []byte) (interface{}, error) {
|
|||
}
|
||||
|
||||
func updateClaim(claim fic.Claim, body []byte) (interface{}, error) {
|
||||
var uc fic.Claim
|
||||
var uc ClaimUploaded
|
||||
if err := json.Unmarshal(body, &uc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -225,6 +222,32 @@ func updateClaim(claim fic.Claim, body []byte) (interface{}, error) {
|
|||
if _, err := uc.Update(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
if claim.State != uc.State {
|
||||
if uc.Whoami != nil {
|
||||
if assignee, err := fic.GetAssignee(*uc.Whoami); err == nil {
|
||||
claim.AddDescription(fmt.Sprintf("%s a changé l'état de la tâche vers %q (était %q).", assignee.Name, uc.State, claim.State), assignee, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if claim.IdAssignee != uc.IdAssignee {
|
||||
if uc.Whoami != nil {
|
||||
if whoami, err := fic.GetAssignee(*uc.Whoami); err == nil {
|
||||
if uc.IdAssignee != nil {
|
||||
if assignee, err := fic.GetAssignee(*uc.IdAssignee); err == nil {
|
||||
if assignee.Id != whoami.Id {
|
||||
claim.AddDescription(fmt.Sprintf("%s a assigné la tâche à %s.", whoami.Name, assignee.Name), whoami, false)
|
||||
} else {
|
||||
claim.AddDescription(fmt.Sprintf("%s s'est assigné la tâche.", assignee.Name), whoami, false)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
claim.AddDescription(fmt.Sprintf("%s a retiré l'attribution de la tâche.", whoami.Name), whoami, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if team, _ := claim.GetTeam(); team != nil {
|
||||
err = generateTeamIssuesFile(*team)
|
||||
}
|
||||
|
|
|
@ -1150,6 +1150,8 @@ angular.module("FICApp")
|
|||
|
||||
$scope.changeState = function(state) {
|
||||
this.claim.state = state;
|
||||
if ((state == "in-progress" || state == "invalid") && this.claim.id_assignee)
|
||||
this.claim.id_assignee = $scope.whoami;
|
||||
if (this.claim.id)
|
||||
this.saveClaim(state == "invalid" || state == "closed");
|
||||
}
|
||||
|
@ -1184,6 +1186,7 @@ angular.module("FICApp")
|
|||
});
|
||||
}
|
||||
$scope.saveClaim = function(backToList) {
|
||||
this.claim.whoami = $scope.whoami;
|
||||
if (this.claim.id_team) {
|
||||
this.claim.id_team = parseInt(this.claim.id_team, 10);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user