admin: Can change capture_regexp along with key
This commit is contained in:
parent
0c53372618
commit
a7d521fbdd
@ -953,6 +953,23 @@ func updateExerciceFlag(c *gin.Context) {
|
||||
flag.Help = uk.Help
|
||||
flag.IgnoreCase = uk.IgnoreCase
|
||||
flag.Multiline = uk.Multiline
|
||||
flag.ChoicesCost = uk.ChoicesCost
|
||||
flag.BonusGain = uk.BonusGain
|
||||
|
||||
if uk.CaptureRe != nil && len(*uk.CaptureRe) > 0 {
|
||||
if flag.CaptureRegexp != uk.CaptureRe && uk.Flag == "" {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Pour changer la capture_regexp, vous devez rentrer la réponse attendue à nouveau, car le flag doit être recalculé."})
|
||||
return
|
||||
}
|
||||
flag.CaptureRegexp = uk.CaptureRe
|
||||
} else {
|
||||
if flag.CaptureRegexp != nil && uk.Flag == "" {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Pour changer la capture_regexp, vous devez rentrer la réponse attendue à nouveau, car le flag doit être recalculé."})
|
||||
return
|
||||
}
|
||||
flag.CaptureRegexp = nil
|
||||
}
|
||||
|
||||
if len(uk.Flag) > 0 {
|
||||
var err error
|
||||
flag.Checksum, err = flag.ComputeChecksum([]byte(uk.Flag))
|
||||
@ -964,14 +981,6 @@ func updateExerciceFlag(c *gin.Context) {
|
||||
} else {
|
||||
flag.Checksum = uk.Value
|
||||
}
|
||||
flag.ChoicesCost = uk.ChoicesCost
|
||||
flag.BonusGain = uk.BonusGain
|
||||
|
||||
if uk.CaptureRe != nil && len(*uk.CaptureRe) > 0 {
|
||||
flag.CaptureRegexp = uk.CaptureRe
|
||||
} else {
|
||||
flag.CaptureRegexp = nil
|
||||
}
|
||||
|
||||
if _, err := flag.Update(); err != nil {
|
||||
log.Println("Unable to updateExerciceFlag:", err.Error())
|
||||
|
@ -2317,9 +2317,9 @@ angular.module("FICApp")
|
||||
}
|
||||
$scope.saveFlag = function () {
|
||||
if (this.flag.id) {
|
||||
this.flag.$update();
|
||||
this.flag.$update().then(function() {}, function(error) { $scope.addToast('danger', 'Impossible de mettre à jour le flag :', error.data.errmsg); });
|
||||
} else {
|
||||
this.flag.$save({ exerciceId: $routeParams.exerciceId });
|
||||
this.flag.$save({ exerciceId: $routeParams.exerciceId }).then(function() {}, function(error) { $scope.addToast('danger', 'Impossible de créer le flag :', error.data.errmsg); });
|
||||
}
|
||||
$rootScope.staticFilesNeedUpdate++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user