admin&sync: insert format helper in database
This commit is contained in:
parent
971273a185
commit
2a6fbd4e32
6 changed files with 22 additions and 17 deletions
|
|
@ -190,6 +190,7 @@ func deleteExerciceHint(hint fic.EHint, _ []byte) (interface{}, error) {
|
|||
|
||||
type uploadedKey struct {
|
||||
Label string
|
||||
Help string
|
||||
Key string
|
||||
Hash []byte
|
||||
}
|
||||
|
|
@ -204,7 +205,7 @@ func createExerciceKey(exercice fic.Exercice, body []byte) (interface{}, error)
|
|||
return nil, errors.New("Key not filled")
|
||||
}
|
||||
|
||||
return exercice.AddRawKey(uk.Label, uk.Key)
|
||||
return exercice.AddRawKey(uk.Label, uk.Help, uk.Key)
|
||||
}
|
||||
|
||||
func showExerciceKey(key fic.Key, _ fic.Exercice, body []byte) (interface{}, error) {
|
||||
|
|
@ -223,6 +224,7 @@ func updateExerciceKey(key fic.Key, exercice fic.Exercice, body []byte) (interfa
|
|||
key.Label = uk.Label
|
||||
}
|
||||
|
||||
key.Help = uk.Help
|
||||
key.Checksum = uk.Hash
|
||||
|
||||
if _, err := key.Update(); err != nil {
|
||||
|
|
|
|||
|
|
@ -95,17 +95,17 @@
|
|||
<button ng-click="deleteKey()" class="btn btn-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row" ng-show="key.id">
|
||||
<input type="text" id="kvalue{{key.id}}" ng-model="key.value" class="col form-control" placeholder="Condensat">
|
||||
<div class="form-group row">
|
||||
<input type="text" id="khelp{{key.id}}" ng-model="key.help" class="col form-control" placeholder="Indication de formatage">
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row" ng-show="key.id">
|
||||
<input type="text" id="kvalue{{key.id}}" ng-model="key.value" class="col form-control" placeholder="Condensat">
|
||||
</div>
|
||||
<div class="form-group row" ng-show="!key.id">
|
||||
<input type="text" id="kvalue{{key.id}}" ng-model="key.key" class="col form-control" placeholder="Chaîne à valider">
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func SyncExerciceKeys(i Importer, exercice fic.Exercice) (errs []string) {
|
|||
errs = append(errs, fmt.Sprintf("%q: WARNING flag #%d: non-printable characters in flag, is this really expected?", path.Base(exercice.Path), nline + 1))
|
||||
}
|
||||
|
||||
if k, err := exercice.AddRawKey(flag.Label, flag.Raw); err != nil {
|
||||
if k, err := exercice.AddRawKey(flag.Label, flag.Help, flag.Raw); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: error flag #%d: %s", path.Base(exercice.Path), nline + 1, err))
|
||||
continue
|
||||
} else {
|
||||
|
|
@ -67,7 +67,7 @@ func SyncExerciceKeys(i Importer, exercice fic.Exercice) (errs []string) {
|
|||
errs = append(errs, fmt.Sprintf("%q: WARNING flag UCQ #%d: non-printable characters in flag, is this really expected?", path.Base(exercice.Path), nline + 1))
|
||||
}
|
||||
|
||||
if k, err := exercice.AddRawKey(flag.Label, flag.Raw); err != nil {
|
||||
if k, err := exercice.AddRawKey(flag.Label, flag.Help, flag.Raw); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: error flag UCQ #%d: %s", path.Base(exercice.Path), nline + 1, err))
|
||||
continue
|
||||
} else {
|
||||
|
|
|
|||
Reference in a new issue