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 {
|
||||
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)
|
||||
|
||||
defer rows.Close()
|
||||
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 {
|
||||
return commentMap, err
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
{{range $value.Comments}}
|
||||
<div class="comment">
|
||||
<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>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
|
@ -22,6 +22,7 @@ type Comment struct {
|
|||
ID int
|
||||
Content string
|
||||
Created string
|
||||
Username string
|
||||
}
|
||||
|
||||
//Context is the struct passed to templates
|
||||
|
|
Loading…
Reference in New Issue