Ajout d'un champ de rapport basique pour décrire la prise de décision

- Enregistrement et prise en compte dans l'affichage des évènements de
  vote/clotûre d'un DAD
This commit is contained in:
2020-10-12 12:44:30 +02:00
parent 7d0831ee57
commit 1eaaa9065f
8 changed files with 116 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package model
import (
"context"
"errors"
"time"
"github.com/jinzhu/gorm"
errs "github.com/pkg/errors"
@ -75,6 +76,14 @@ func (r *DSFRepository) updateFromChanges(dsf *DecisionSupportFile, changes *Dec
}
if changes.Status != nil {
if dsf.Status != StatusVoted && *changes.Status == StatusVoted {
dsf.VotedAt = time.Now().UTC()
}
if *changes.Status == StatusClosed {
dsf.VotedAt = time.Time{}
}
dsf.Status = *changes.Status
}

View File

@ -31,6 +31,10 @@ func (v *DecisionSupportFileVoter) Vote(ctx context.Context, subject interface{}
case ActionRead:
return voter.Allow, nil
case ActionUpdate:
if dsf.Status == StatusClosed || dsf.Status == StatusVoted {
return voter.Deny, nil
}
if inWorkgroup(user, dsf.Workgroup) {
return voter.Allow, nil
}

View File

@ -14,6 +14,7 @@ const (
EventTypeClosed EventType = "closed"
EventTypeStatusChanged EventType = "status-changed"
EventTypeTitleChanged EventType = "title-changed"
EventTypeVoted EventType = "voted"
)
type EventObject interface {