phcpress 2.8.11 → 2.8.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4654cd0d0ce4a4104375923b42778d6966037a22
4
- data.tar.gz: 8974555458ea52454a0897b31b1e4c73d10f3bff
3
+ metadata.gz: 272c8fa8591b97b203861406c7b27c9212e6cf38
4
+ data.tar.gz: 7a5c466297ce9e04c6da492adcdd7d7457c364e4
5
5
  SHA512:
6
- metadata.gz: d810bba3e56d055cb4e74a14cd7fc31d74b07d46cf2c5947a803dd3bf559fed24876b212bfd9dd6dc2da3ee27c897be107df3a5b448f2a57877e54ffebc42910
7
- data.tar.gz: 0bc223efb0ad3b5e5bc30b3f15b472958240983e64d5c30d83b64faeabec8167c0bad3167b22a24d561090132e5a06bd7a1d76df861da40a1b7e50ef598a77ad
6
+ metadata.gz: df3e98ba2f74c0b2d1092e155f1f8809835028cf118de42772b227c73e7ffcd3c4f2334d482562df3e60aabd2944ef7a538bce360141de7c6b33c8476f9979b5
7
+ data.tar.gz: fc15546051cb4f23bda66ffb6fa5fd93c5b7f0bd578a502375c9e5ed0cbe4f4bb04492b8c63a7487f9ed2401e7a363c9fa1e391e9f0b5abc5b71a83991c300ac
@@ -1,40 +1,40 @@
1
1
  # Load General Controller for Engine
2
2
  require_dependency "phcpress/application_controller"
3
3
 
4
- # Code for Blog Posting
4
+ # Code for News Posting
5
5
  module Phcpress
6
- class Blog::PostsController < ApplicationController
6
+ class News::PostsController < ApplicationController
7
7
 
8
8
  # Filters & Security
9
- layout 'layouts/phcpress/blogpost/blog_layout'
9
+ layout 'layouts/phcpress/newspost/news_layout'
10
10
  before_action :authenticate_user!
11
- before_action :current_user?
12
- before_action :set_blog_post, only: [:edit, :update, :destroy]
11
+ before_action :current_user
12
+ before_action :set_news_post, only: [:edit, :update, :destroy]
13
13
 
14
- # Blog Post Index (/blog/posts)
14
+ # News Post Index (/news/posts)
15
15
  def index
16
- @blog_posts = Blog::Post.all
16
+ @news_posts = News::Post.all
17
17
  end
18
18
 
19
- # Single Blog Post (/blog/posts/1)
19
+ # Single News Post (/news/posts/1)
20
20
  #def show
21
21
  #end
22
22
 
23
- # Create a New Blog Post (/blog/posts/new)
23
+ # Create a New News Post (/news/posts/new)
24
24
  def new
25
- @blog_post = Blog::Post.new
25
+ @news_post = News::Post.new
26
26
  end
27
27
 
28
- # Edit Blog Post (/blog/posts/1/edit)
28
+ # Edit News Post /news/posts/1/edit
29
29
  def edit
30
30
  end
31
31
 
32
32
  # Create News Post /news/posts/new
33
33
  def create
34
- @blog_post = Blog::Post.new(blog_post_params)
35
- @blog_post.user_id = current_user.id
36
- if @blog_post.save
37
- redirect_to blog_posts_path, notice: 'Blog post was successfully created.'
34
+ @news_post = News::Post.new(news_post_params)
35
+ @news_post.user_id = current_user.id
36
+ if @news_post.save
37
+ redirect_to news_posts_path, notice: 'News post was successfully created.'
38
38
  else
39
39
  render 'new'
40
40
  end
@@ -42,8 +42,8 @@ module Phcpress
42
42
 
43
43
  # PATCH/PUT
44
44
  def update
45
- if @blog_post.update(blog_post_params)
46
- redirect_to blog_posts_path, notice: 'Blog post was successfully updated.'
45
+ if @news_post.update(news_post_params)
46
+ redirect_to news_posts_path, notice: 'News post was successfully updated.'
47
47
  else
48
48
  render :edit
49
49
  end
@@ -51,25 +51,26 @@ module Phcpress
51
51
 
52
52
  # DELETE
53
53
  def destroy
54
- @blog_post.destroy
55
- redirect_to blog_posts_path, notice: 'Blog post was successfully destroyed.'
54
+ @news_post.destroy
55
+ redirect_to news_posts_path, notice: 'News post was successfully destroyed.'
56
56
  end
57
57
 
58
58
  private
59
59
 
60
60
  # Common Callbacks
61
- def set_blog_post
62
- @blog_post = Blog::Post.find(params[:id])
61
+ def set_news_post
62
+ @news_post = News::Post.find(params[:id])
63
63
  end
64
64
 
65
65
  # Whitelist on what can be posted
66
- def blog_post_params
67
- params.require(:blog_post).permit(:blogpsttitle, :blogpsttext, :blogpstexcerpts, :pststatus, :pstimage)
66
+ def news_post_params
67
+ params.require(:news_post).permit(:newspsttitle, :newspsttext, :newspstexcerpts, :pststatus, :pstimage)
68
68
  end
69
-
69
+
70
70
  # Current User
71
- def current_user?(user)
72
- user == current_user
71
+ def current_user
72
+ return unless session[:user_id]
73
+ @current_user ||= User.find(session[:user_id])
73
74
  end
74
75
 
75
76
  end
@@ -8,7 +8,7 @@ module Phcpress
8
8
  # Filters & Security
9
9
  layout 'layouts/phcpress/newspost/news_layout'
10
10
  before_action :authenticate_user!
11
- before_action :current_user?
11
+ before_action :current_user
12
12
  before_action :set_news_post, only: [:edit, :update, :destroy]
13
13
 
14
14
  # News Post Index (/news/posts)
@@ -68,8 +68,9 @@ module Phcpress
68
68
  end
69
69
 
70
70
  # Current User
71
- def current_user?(user)
72
- user == current_user
71
+ def current_user
72
+ return unless session[:user_id]
73
+ @current_user ||= User.find(session[:user_id])
73
74
  end
74
75
 
75
76
  end
@@ -1,3 +1,3 @@
1
1
  module Phcpress
2
- VERSION = "2.8.11"
2
+ VERSION = "2.8.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phcpress
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.11
4
+ version: 2.8.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - BradPotts