Add notifications
This commit is contained in:
parent
6545cbdff8
commit
e68f41445e
8 changed files with 114 additions and 63 deletions
6
admin.go
6
admin.go
|
@ -9,7 +9,8 @@ import (
|
|||
|
||||
func deleteHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if SessionUser(r) == "" {
|
||||
sess := GetSession(r)
|
||||
if sess.User == "" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
@ -24,7 +25,8 @@ func deleteHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request
|
|||
os.RemoveAll(book.Cover[1:])
|
||||
os.RemoveAll(book.CoverSmall[1:])
|
||||
coll.Remove(bson.M{"_id": id})
|
||||
sess.Notify("Removed book!", "The book '"+book.Title+"' it's completly removed", "success")
|
||||
sess.Save(w, r)
|
||||
http.Redirect(w, r, "/", 307)
|
||||
//TODO: notify deleted
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue