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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 272c8fa8591b97b203861406c7b27c9212e6cf38
|
4
|
+
data.tar.gz: 7a5c466297ce9e04c6da492adcdd7d7457c364e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
4
|
+
# Code for News Posting
|
5
5
|
module Phcpress
|
6
|
-
class
|
6
|
+
class News::PostsController < ApplicationController
|
7
7
|
|
8
8
|
# Filters & Security
|
9
|
-
layout 'layouts/phcpress/
|
9
|
+
layout 'layouts/phcpress/newspost/news_layout'
|
10
10
|
before_action :authenticate_user!
|
11
|
-
before_action :current_user
|
12
|
-
before_action :
|
11
|
+
before_action :current_user
|
12
|
+
before_action :set_news_post, only: [:edit, :update, :destroy]
|
13
13
|
|
14
|
-
#
|
14
|
+
# News Post Index (/news/posts)
|
15
15
|
def index
|
16
|
-
@
|
16
|
+
@news_posts = News::Post.all
|
17
17
|
end
|
18
18
|
|
19
|
-
# Single
|
19
|
+
# Single News Post (/news/posts/1)
|
20
20
|
#def show
|
21
21
|
#end
|
22
22
|
|
23
|
-
# Create a New
|
23
|
+
# Create a New News Post (/news/posts/new)
|
24
24
|
def new
|
25
|
-
@
|
25
|
+
@news_post = News::Post.new
|
26
26
|
end
|
27
27
|
|
28
|
-
# 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
|
-
@
|
35
|
-
@
|
36
|
-
if @
|
37
|
-
redirect_to
|
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 @
|
46
|
-
redirect_to
|
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
|
-
@
|
55
|
-
redirect_to
|
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
|
62
|
-
|
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
|
67
|
-
params.require(:
|
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
|
72
|
-
|
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
|
72
|
-
|
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
|
data/lib/phcpress/version.rb
CHANGED