comments now show the username
This commit is contained in:
parent
a6d9a109c0
commit
3c5e5460e8
|
@ -330,12 +330,12 @@ func GetComments(username string) (map[int][]types.Comment, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return commentMap, err
|
return commentMap, err
|
||||||
}
|
}
|
||||||
stmt := "select c.id, c.taskID, c.content, c.created from comments c, task t where t.id=c.taskID and c.user_id=?;"
|
stmt := "select c.id, c.taskID, c.content, c.created, u.username from comments c, task t, user u where t.id=c.taskID and c.user_id=t.user_id and t.user_id=u.id and u.id=?"
|
||||||
rows := database.query(stmt, userID)
|
rows := database.query(stmt, userID)
|
||||||
|
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err := rows.Scan(&comment.ID, &taskID, &comment.Content, &created)
|
err := rows.Scan(&comment.ID, &taskID, &comment.Content, &created, &comment.Username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return commentMap, err
|
return commentMap, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
{{range $value.Comments}}
|
{{range $value.Comments}}
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<span>{{.Content}}</span>
|
<span>{{.Content}}</span>
|
||||||
<span class="timestamp">{{.Created}}</span>
|
<span class="timestamp">{{.Username}} {{.Created}}</span>
|
||||||
<a href="/del-comment/{{.ID}}"><span class="glyphicon glyphicon-trash timestamp"></span></a>
|
<a href="/del-comment/{{.ID}}"><span class="glyphicon glyphicon-trash timestamp"></span></a>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -22,6 +22,7 @@ type Comment struct {
|
||||||
ID int
|
ID int
|
||||||
Content string
|
Content string
|
||||||
Created string
|
Created string
|
||||||
|
Username string
|
||||||
}
|
}
|
||||||
|
|
||||||
//Context is the struct passed to templates
|
//Context is the struct passed to templates
|
||||||
|
|
Loading…
Reference in New Issue