feat: fix non pictured thread view

This commit is contained in:
Yanislav Igonin 2021-08-31 22:51:31 +03:00
parent 8d050d2521
commit a70413ceb3
3 changed files with 9 additions and 28 deletions

2
.env
View File

@ -1,3 +1,3 @@
ENV=release ENV=debug
PORT=3000 PORT=3000
POSTGRES_URL=postgresql://localhost/micrach POSTGRES_URL=postgresql://localhost/micrach

View File

@ -84,33 +84,11 @@ func seedDbMocks() {
} }
for _, post := range posts { for _, post := range posts {
Posts.Create(post) _, err := Posts.Create(post)
if err != nil {
log.Panicln(err)
}
} }
// fileSql := `
// INSERT INTO files (post_id, name, ext, size)
// VALUES ($1, $2, $3, $4)
// `
// for _, post := range posts {
// if post.ParentID == 0 {
// conn.Query(context.Background(), postSql, post.ID, post.IsParent, nil, post.Title, post.Text, post.IsSage)
// } else {
// conn.Query(context.Background(), postSql, post.ID, post.IsParent, post.ParentID, post.Title, post.Text, post.IsSage)
// }
// if err != nil {
// log.Panicln(err)
// }
// for _, file := range post.Files {
// _, err = Db.Pool.Query(context.TODO(), fileSql, file.PostID, file.Name, file.Ext, file.Size)
// if err != nil {
// log.Panicln(err)
// }
// }
// }
} }
func SeedMocks() { func SeedMocks() {

View File

@ -49,13 +49,16 @@
{{range $Post := .}} {{range $Post := .}}
<div class="col col-sm-6 col-md-4 col-lg-3"> <div class="col col-sm-6 col-md-4 col-lg-3">
<div class="card"> <div class="card">
{{$FirstFile := index $Post.Files 0}}
{{ $length := len $Post.Files }} {{ if gt $length 0 }}
{{$FirstFile := index $Post.Files 0}}
<img <img
src="{{$FirstFile.Name}}" src="{{$FirstFile.Name}}"
class="card-img-top" class="card-img-top"
alt="Uploaded picture" alt="Uploaded picture"
> >
{{end}}
<div class="card-body"> <div class="card-body">
<h5 class="card-title">{{$Post.Title}}</h5> <h5 class="card-title">{{$Post.Title}}</h5>
<p class="card-text">{{$Post.Text}}</p> <p class="card-text">{{$Post.Text}}</p>