admin: new route to fill URLIds if they are not defined
This commit is contained in:
parent
44ceeb17d9
commit
5fdb35eabc
4 changed files with 56 additions and 0 deletions
|
|
@ -122,6 +122,14 @@ func (e Exercice) Update() (int64, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (e *Exercice) FixURLId() bool {
|
||||
if e.URLId == "" {
|
||||
e.URLId = ToURLid(e.Title)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e Exercice) GetThemeId() (int, error) {
|
||||
var tid int
|
||||
if err := DBQueryRow("SELECT id_theme FROM exercices WHERE id_exercice=?", e.Id).Scan(&tid); err != nil {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,14 @@ func CreateTheme(name string, url_id string, authors string, intro string) (Them
|
|||
}
|
||||
}
|
||||
|
||||
func (t *Theme) FixURLId() bool {
|
||||
if t.URLId == "" {
|
||||
t.URLId = ToURLid(t.Name)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (t Theme) Update() (int64, error) {
|
||||
if res, err := DBExec("UPDATE themes SET name = ?, url_id = ?, authors = ?, intro = ? WHERE id_theme = ?", t.Name, t.URLId, t.Authors, t.Intro, t.Id); err != nil {
|
||||
return 0, err
|
||||
|
|
|
|||
Reference in a new issue