start work on news list

This commit is contained in:
Dan Ballard 2015-05-11 22:50:09 -07:00
parent 93000625c7
commit 770bf08fc3
4 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,15 @@
-- +goose Up
-- SQL in section 'Up' is executed when this migration is applied
ALTER TABLE tags RENAME TO categories;
ALTER TABLE categories RENAME COLUMN tag_id TO id;
ALTER TABLE news RENAME COLUMN news_id TO id;
ALTER TABLE news RENAME COLUMN tag_id TO category_id;
ALTER TABLE news RENAME COLUMN description TO notes;
-- +goose Down
-- SQL section 'Down' is executed when this migration is rolled back
ALTER TABLE categories RENAMTE TO tags

View File

@ -0,0 +1,9 @@
-- +goose Up
-- SQL in section 'Up' is executed when this migration is applied
ALTER TABLE news ADD COLUMN exported BOOLEAN DEFAULT false;
-- +goose Down
-- SQL section 'Down' is executed when this migration is rolled back

View File

@ -14,6 +14,7 @@ type News struct {
Category_id int
Date time.Time
Notes string
Expoerted bool
}
func (news *News) Insert(db *sql.DB) error {
@ -23,4 +24,17 @@ func (news *News) Insert(db *sql.DB) error {
return err
}
return nil
}
func Unexported(db *sql.DB) ([]News, error) {
res, err := db.Query("SELECT url, title, category_id, timestamp, notes FROM news WHERE exported=false")
if err != nil {
fmt.Println("DB errpr reading unexported news: ", err)
return nil, err
}
news := []News{}
return news, nil
}

View File

@ -2,4 +2,14 @@
<h2 class="form-add-heading">List</h2>
{{template "flashes" .}}
<form class="form-add" action="/" method="post" role="form" class="container col-form">
<div class="row">
<div class="col-xs-10"></div><div class="col-xs-2">
<input class="btn btn-lg btn-primary btn-block" type="submit" value="Export" />
</div>
</div>
</form>
<textarea class="form-control" name="template" placeholder="Template" rows="3" cols="80">{{.template}}</textarea>
{{end}}