From d48adb741c5c30ba3f2d3c039a7e342b43add352 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 4 Jul 2018 10:42:21 -0400 Subject: Added blog drafts An unpublished post is not viewable unless you are logged in. The "Create record" field is disabled for unpublished posts, though this is only in JavaScript and the backend will not disallow creating records for unpublished posts if forced to. Unpublishing a post does not destroy records for that post. This only applies to blog posts, currently; streams and stream updates cannot be drafted. Unpublished posts still require titles and slugs. There is no autosaving functionality yet. refs #1 --- db/migrate/20180704125527_add_blog_drafts.rb | 17 +++++++++++++++++ db/schema.rb | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180704125527_add_blog_drafts.rb (limited to 'db') diff --git a/db/migrate/20180704125527_add_blog_drafts.rb b/db/migrate/20180704125527_add_blog_drafts.rb new file mode 100644 index 0000000..07c5078 --- /dev/null +++ b/db/migrate/20180704125527_add_blog_drafts.rb @@ -0,0 +1,17 @@ +class AddBlogDrafts < ActiveRecord::Migration[5.1] + def change + add_column :blogs, :published, :boolean, null: false, default: false + add_column :blogs, :published_at, :datetime, null: true + + reversible do |dir| + dir.up do + Blog.all.each do |blog| + blog.published = true + blog.published_at = blog.created_at + + blog.save! + end + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 2ca0b58..d885500 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180702221133) do +ActiveRecord::Schema.define(version: 20180704125527) do create_table "blogs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| t.string "title" @@ -18,6 +18,8 @@ ActiveRecord::Schema.define(version: 20180702221133) do t.string "slug", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "published", default: false, null: false + t.datetime "published_at" end create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| -- cgit 1.4.1