about summary refs log tree commit diff stats
path: root/app/controllers
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-07-04 10:42:21 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-07-04 10:42:21 -0400
commitd48adb741c5c30ba3f2d3c039a7e342b43add352 (patch)
treecbc25ac929e73702142a5ec5728a98dc54d88602 /app/controllers
parent66353403efcc9c0b16c82ea8ab9860ca8a44aa4c (diff)
downloadthoughts-d48adb741c5c30ba3f2d3c039a7e342b43add352.tar.gz
thoughts-d48adb741c5c30ba3f2d3c039a7e342b43add352.tar.bz2
thoughts-d48adb741c5c30ba3f2d3c039a7e342b43add352.zip
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
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/blogs_controller.rb8
-rw-r--r--app/controllers/blogs_controller.rb3
2 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/admin/blogs_controller.rb b/app/controllers/admin/blogs_controller.rb index fa46ab8..9706df3 100644 --- a/app/controllers/admin/blogs_controller.rb +++ b/app/controllers/admin/blogs_controller.rb
@@ -2,7 +2,11 @@ class Admin::BlogsController < Admin::AdminController
2 before_action :set_section 2 before_action :set_section
3 3
4 def index 4 def index
5 @blogs = Blog.order(created_at: :desc) 5 @blogs = Blog.where(published: true).order(published_at: :desc)
6 end
7
8 def drafts
9 @blogs = Blog.where(published: false).order(updated_at: :desc)
6 end 10 end
7 11
8 def new 12 def new
@@ -42,7 +46,7 @@ class Admin::BlogsController < Admin::AdminController
42 private 46 private
43 47
44 def blog_params 48 def blog_params
45 params.require(:blog).permit(:title, :body, :slug, records_attributes: [:description, :_destroy]) 49 params.require(:blog).permit(:title, :body, :slug, :published, records_attributes: [:description, :_destroy])
46 end 50 end
47 51
48 def set_section 52 def set_section
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 5e72601..f31287b 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb
@@ -2,6 +2,9 @@ class BlogsController < ApplicationController
2 2
3 def show 3 def show
4 @blog = Blog.find_by_slug(params[:slug]) 4 @blog = Blog.find_by_slug(params[:slug])
5
6 raise ActiveRecord::RecordNotFound unless @blog
7 raise ActiveRecord::RecordNotFound unless @blog.published or user_signed_in?
5 end 8 end
6 9
7end 10end