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
|
||||
UploadDate time.Time
|
||||
Tsv string
|
||||
//BadQuality int `bad_quality`
|
||||
BadQualityReporters []string `sql:"-"` // TODO: deprecate??
|
||||
}
|
||||
|
||||
// TODO: missing history
|
||||
|
|
|
@ -50,10 +50,9 @@ func logoutHandler(h handler) {
|
|||
}
|
||||
|
||||
type bookData struct {
|
||||
S Status
|
||||
Book database.Book
|
||||
Description []string
|
||||
FlaggedBadQuality bool
|
||||
S Status
|
||||
Book database.Book
|
||||
Description []string
|
||||
}
|
||||
|
||||
func bookHandler(h handler) {
|
||||
|
@ -74,13 +73,6 @@ func bookHandler(h handler) {
|
|||
data.S.Title = book.Title + author + " -- " + data.S.Title
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -113,21 +105,6 @@ func downloadHandler(h handler) {
|
|||
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 {
|
||||
S Status
|
||||
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("/cover/{id:"+idPattern+"}/{size}/{img:.*}", sg.Gather(coverHandler))
|
||||
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(loginPostHandler)).Methods("POST")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{{template "header.html" .S}}
|
||||
|
||||
{{$role := .S.Role}}
|
||||
{{$flaggedBadQuality := .FlaggedBadQuality}}
|
||||
{{with .Book}}
|
||||
<script>
|
||||
function delBook(){
|
||||
|
@ -59,10 +58,6 @@ function delBook(){
|
|||
</div>
|
||||
</div>
|
||||
{{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>
|
||||
{{end}}
|
||||
|
|
Reference in a new issue