From 770bf08fc31d805f198c9e61e8ccc176c5b9e71b Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Mon, 11 May 2015 22:50:09 -0700 Subject: [PATCH] start work on news list --- db/migrations/20150511204500_rename.sql | 15 +++++++++++++++ db/migrations/20150511222323_export.sql | 9 +++++++++ news/news.go | 14 ++++++++++++++ templates/pages/list.html | 10 ++++++++++ 4 files changed, 48 insertions(+) create mode 100644 db/migrations/20150511204500_rename.sql create mode 100644 db/migrations/20150511222323_export.sql diff --git a/db/migrations/20150511204500_rename.sql b/db/migrations/20150511204500_rename.sql new file mode 100644 index 0000000..f586a25 --- /dev/null +++ b/db/migrations/20150511204500_rename.sql @@ -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 diff --git a/db/migrations/20150511222323_export.sql b/db/migrations/20150511222323_export.sql new file mode 100644 index 0000000..aa3d843 --- /dev/null +++ b/db/migrations/20150511222323_export.sql @@ -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 + diff --git a/news/news.go b/news/news.go index 366e10f..6d5889a 100644 --- a/news/news.go +++ b/news/news.go @@ -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 } \ No newline at end of file diff --git a/templates/pages/list.html b/templates/pages/list.html index cbfda19..a959583 100644 --- a/templates/pages/list.html +++ b/templates/pages/list.html @@ -2,4 +2,14 @@

List

{{template "flashes" .}} +
+
+
+ +
+
+
+ + + {{end}} \ No newline at end of file