Deprecate bad quality flag
This commit is contained in:
parent
7f9c172853
commit
f12114c296
3 changed files with 3 additions and 34 deletions
|
@ -21,8 +21,6 @@ type Book struct {
|
||||||
Active bool
|
Active bool
|
||||||
UploadDate time.Time
|
UploadDate time.Time
|
||||||
Tsv string
|
Tsv string
|
||||||
//BadQuality int `bad_quality`
|
|
||||||
BadQualityReporters []string `sql:"-"` // TODO: deprecate??
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: missing history
|
// TODO: missing history
|
||||||
|
|
|
@ -50,10 +50,9 @@ func logoutHandler(h handler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bookData struct {
|
type bookData struct {
|
||||||
S Status
|
S Status
|
||||||
Book database.Book
|
Book database.Book
|
||||||
Description []string
|
Description []string
|
||||||
FlaggedBadQuality bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func bookHandler(h handler) {
|
func bookHandler(h handler) {
|
||||||
|
@ -74,13 +73,6 @@ func bookHandler(h handler) {
|
||||||
data.S.Title = book.Title + author + " -- " + data.S.Title
|
data.S.Title = book.Title + author + " -- " + data.S.Title
|
||||||
|
|
||||||
data.Description = strings.Split(data.Book.Description, "\n")
|
data.Description = strings.Split(data.Book.Description, "\n")
|
||||||
data.FlaggedBadQuality = false
|
|
||||||
for _, reporter := range book.BadQualityReporters {
|
|
||||||
if reporter == h.sess.User || reporter == h.sess.Id() {
|
|
||||||
data.FlaggedBadQuality = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h.template.load(h, "book", data)
|
h.template.load(h, "book", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,21 +105,6 @@ func downloadHandler(h handler) {
|
||||||
io.Copy(h.w, f)
|
io.Copy(h.w, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func flagHandler(h handler) {
|
|
||||||
id := mux.Vars(h.r)["id"]
|
|
||||||
user := h.sess.Id()
|
|
||||||
if h.sess.User != "" {
|
|
||||||
user = h.sess.User
|
|
||||||
}
|
|
||||||
err := h.db.FlagBadQuality(id, user)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("An error ocurred while flaging ", id, ": ", err)
|
|
||||||
}
|
|
||||||
h.sess.Notify("Flagged!", "Book marked as bad quality, thank you", "success")
|
|
||||||
h.sess.Save(h.w, h.r)
|
|
||||||
http.Redirect(h.w, h.r, h.r.Referer(), http.StatusFound)
|
|
||||||
}
|
|
||||||
|
|
||||||
type indexData struct {
|
type indexData struct {
|
||||||
S Status
|
S Status
|
||||||
Books []database.Book
|
Books []database.Book
|
||||||
|
@ -202,7 +179,6 @@ func InitRouter(db database.DB, sg *StatsGatherer, assetsPath string) {
|
||||||
r.HandleFunc("/download/{id:"+idPattern+"}/{epub:.*}", sg.Gather(downloadHandler))
|
r.HandleFunc("/download/{id:"+idPattern+"}/{epub:.*}", sg.Gather(downloadHandler))
|
||||||
r.HandleFunc("/cover/{id:"+idPattern+"}/{size}/{img:.*}", sg.Gather(coverHandler))
|
r.HandleFunc("/cover/{id:"+idPattern+"}/{size}/{img:.*}", sg.Gather(coverHandler))
|
||||||
r.HandleFunc("/stats/", sg.Gather(statsHandler))
|
r.HandleFunc("/stats/", sg.Gather(statsHandler))
|
||||||
r.HandleFunc("/flag/bad_quality/{id:"+idPattern+"}", sg.Gather(flagHandler))
|
|
||||||
|
|
||||||
r.HandleFunc("/login/", sg.Gather(loginHandler)).Methods("GET")
|
r.HandleFunc("/login/", sg.Gather(loginHandler)).Methods("GET")
|
||||||
r.HandleFunc("/login/", sg.Gather(loginPostHandler)).Methods("POST")
|
r.HandleFunc("/login/", sg.Gather(loginPostHandler)).Methods("POST")
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{{template "header.html" .S}}
|
{{template "header.html" .S}}
|
||||||
|
|
||||||
{{$role := .S.Role}}
|
{{$role := .S.Role}}
|
||||||
{{$flaggedBadQuality := .FlaggedBadQuality}}
|
|
||||||
{{with .Book}}
|
{{with .Book}}
|
||||||
<script>
|
<script>
|
||||||
function delBook(){
|
function delBook(){
|
||||||
|
@ -59,10 +58,6 @@ function delBook(){
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="pull-right">
|
|
||||||
<br />
|
|
||||||
<a href="{{if $flaggedBadQuality}}#{{else}}/flag/bad_quality/{{.Id}}{{end}}" class="btn btn-small{{if $flaggedBadQuality}} disabled{{end}}"><i class="icon-warning-sign"></i> Report bad quality</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Reference in a new issue