Handle optionnal flags
This commit is contained in:
parent
e581630d5e
commit
a414cd22c8
18 changed files with 68 additions and 22 deletions
|
@ -735,7 +735,8 @@ type uploadedFlag struct {
|
|||
SortReGroups bool `json:"sort_re_grps"`
|
||||
Flag string
|
||||
Value []byte
|
||||
ChoicesCost int64 `json:"choices_cost"`
|
||||
ChoicesCost int32 `json:"choices_cost"`
|
||||
BonusGain int32 `json:"bonus_gain"`
|
||||
}
|
||||
|
||||
func createExerciceFlag(c *gin.Context) {
|
||||
|
@ -758,7 +759,7 @@ func createExerciceFlag(c *gin.Context) {
|
|||
|
||||
exercice := c.MustGet("exercice").(*fic.Exercice)
|
||||
|
||||
flag, err := exercice.AddRawFlagKey(uk.Label, uk.Type, uk.Placeholder, uk.IgnoreCase, uk.NoTrim, uk.Multiline, vre, uk.SortReGroups, []byte(uk.Flag), uk.ChoicesCost)
|
||||
flag, err := exercice.AddRawFlagKey(uk.Label, uk.Type, uk.Placeholder, uk.IgnoreCase, uk.NoTrim, uk.Multiline, vre, uk.SortReGroups, []byte(uk.Flag), uk.ChoicesCost, uk.BonusGain)
|
||||
if err != nil {
|
||||
log.Println("Unable to createExerciceFlag:", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "An error occurs when trying to create flag."})
|
||||
|
@ -839,6 +840,7 @@ func updateExerciceFlag(c *gin.Context) {
|
|||
flag.Checksum = uk.Value
|
||||
}
|
||||
flag.ChoicesCost = uk.ChoicesCost
|
||||
flag.BonusGain = uk.BonusGain
|
||||
|
||||
if uk.ValidatorRe != nil && len(*uk.ValidatorRe) > 0 {
|
||||
flag.ValidatorRegexp = uk.ValidatorRe
|
||||
|
|
Reference in a new issue