fic: Tag now in Title format
Signed-off-by: MCharpy <mahe.charpy@epita.fr>
This commit is contained in:
parent
56d8d49304
commit
2e4513c00f
1 changed files with 5 additions and 0 deletions
|
@ -1,5 +1,9 @@
|
||||||
package fic
|
package fic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
// GetTags returns tags associated with this exercice.
|
// GetTags returns tags associated with this exercice.
|
||||||
func (e Exercice) GetTags() (tags []string, err error) {
|
func (e Exercice) GetTags() (tags []string, err error) {
|
||||||
if rows, errr := DBQuery("SELECT tag FROM exercice_tags WHERE id_exercice = ?", e.Id); errr != nil {
|
if rows, errr := DBQuery("SELECT tag FROM exercice_tags WHERE id_exercice = ?", e.Id); errr != nil {
|
||||||
|
@ -22,6 +26,7 @@ func (e Exercice) GetTags() (tags []string, err error) {
|
||||||
|
|
||||||
// AddTag assign a new tag to the exercice and registers it into the database.
|
// AddTag assign a new tag to the exercice and registers it into the database.
|
||||||
func (e Exercice) AddTag(tag string) (string, error) {
|
func (e Exercice) AddTag(tag string) (string, error) {
|
||||||
|
tag = strings.Title(tag)
|
||||||
if _, err := DBExec("INSERT INTO exercice_tags (id_exercice, tag) VALUES (?, ?)", e.Id, tag); err != nil {
|
if _, err := DBExec("INSERT INTO exercice_tags (id_exercice, tag) VALUES (?, ?)", e.Id, tag); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else {
|
} else {
|
||||||
|
|
Reference in a new issue