phcdevworks_tutorials 1.0.2 → 1.2.2

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
  SHA256:
3
- metadata.gz: 8a45e1901641ed89f76059cfe021ce3f8b02b585bf7956aaa424ad3e0e31e3fd
4
- data.tar.gz: 3e9929250fcb7c624194d78673f720c1b8dd50f1fcd6ba9f57e1e6187b450a11
3
+ metadata.gz: 4f20962d4a1dcee4e01f921bb7fe0e413d3f57f9de8c71d1b0413cb7f516e7fd
4
+ data.tar.gz: '09615f03b8c76ce654fc100cc73c6eca19d2a884a84458da7718560ebf2e5793'
5
5
  SHA512:
6
- metadata.gz: 9d069541f5e14f712aa693d7a33d06b45fab873f2a0c57a3a2ded462ff8eb6e6ffe4e1d302c465da1b7b4f8a6d279bc82ef9244a9b07a675b0a2d63f0bdc93ff
7
- data.tar.gz: 62778941f02f41342af967d6eaf46f8045848c693be3ad442ab74af5ca2eaf57430f4a3f4c2d2654f7087b8f83568709053e1bb3ebfcf9769bfeeed61ad31beb
6
+ metadata.gz: 07dcd4698effa6821abfd3315bdac1661827a2cb1e48eac822ab64ff08118056cc77461471c5ef7c82617728566d53d6bd5961e97ea6c2131dd4589bf22cc4c1
7
+ data.tar.gz: 6ce3ecd655f8a390c99ac6c313f8e7802b7ee846382ce963a071ec52cee2fb6d15fcdfc81b642f83c1b1d53194cbc400d5a22a776b0c3582665f279d851ff8b1
@@ -2,13 +2,13 @@ require_dependency "phcdevworks_tutorials/application_controller"
2
2
 
3
3
  module PhcdevworksTutorials
4
4
  class Blog::TutorialsController < ApplicationController
5
-
5
+
6
6
  # Layout
7
7
  layout 'phcdevworks_tutorials/frontend'
8
8
 
9
9
  # INDEX
10
10
  def index
11
- @phcdevworks_tutorials_index = Tutorial::Post.where(org_id: current_user.org_id)
11
+ @phcdevworks_tutorials_index = Tutorial::Post.where(tutorial_post_status: "published")
12
12
  end
13
13
 
14
14
  # SHOW
@@ -75,7 +75,7 @@ module PhcdevworksTutorials
75
75
 
76
76
  # Whitelist
77
77
  def tutorial_post_params
78
- params.require(:tutorial_post).permit(:tutorial_post_step, :tutorial_post_title, :tutorial_post_text, :category_id, :slug, :user_id, :org_id)
78
+ params.require(:tutorial_post).permit(:tutorial_post_step, :tutorial_post_title, :tutorial_post_text,:tutorial_post_description, :tutorial_post_status, :tutorial_post_image, :slug, :user_id, :org_id, category_ids: [])
79
79
  end
80
80
 
81
81
  end
@@ -39,7 +39,7 @@ module PhcdevworksTutorials
39
39
  @tutorial_step.org_id = current_user.org_id
40
40
  respond_to do |format|
41
41
  if @tutorial_step.save
42
- format.html { redirect_to tutorial_post_steps_path, notice: 'Step was successfully created.' }
42
+ format.html { redirect_to tutorial_post_steps_path, :flash => { :success => 'Tutorial Step has been Added' }}
43
43
  format.json { render :show, status: :created, location: @tutorial_step }
44
44
  else
45
45
  format.html { render :new }
@@ -54,7 +54,7 @@ module PhcdevworksTutorials
54
54
  @tutorial_post = Tutorial::Post.friendly.find(params[:post_id])
55
55
  respond_to do |format|
56
56
  if @tutorial_step.update(tutorial_step_params)
57
- format.html { redirect_to @tutorial_step, notice: 'Step was successfully updated.' }
57
+ format.html { redirect_to tutorial_post_steps_path, :flash => { :notice => 'Tutorial Step has been Updated.' }}
58
58
  format.json { render :show, status: :ok, location: @tutorial_step }
59
59
  else
60
60
  format.html { render :edit }
@@ -69,7 +69,7 @@ module PhcdevworksTutorials
69
69
  @tutorial_step = tutorial_post.steps.find(params[:id])
70
70
  @tutorial_step.destroy
71
71
  respond_to do |format|
72
- format.html { redirect_to tutorial_steps_url, notice: 'Step was successfully destroyed.' }
72
+ format.html { redirect_to tutorial_post_steps_path, :flash => { :error => 'Tutorial Step has been Removed' }}
73
73
  format.json { head :no_content }
74
74
  end
75
75
  end
@@ -79,7 +79,7 @@ module PhcdevworksTutorials
79
79
  # Common Callbacks
80
80
 
81
81
  def set_tutorial_step
82
- @tutorial_step = Tutorial::Step.friendly.find(params[:id])
82
+ @tutorial_step = Tutorial::Step.find(params[:id])
83
83
  end
84
84
 
85
85
  def tutorial_post
@@ -88,7 +88,7 @@ module PhcdevworksTutorials
88
88
 
89
89
  # Whitelist
90
90
  def tutorial_step_params
91
- params.require(:tutorial_step).permit(:steps_number, :steps_body, :post_id, :slug, :user_id, :org_id)
91
+ params.require(:tutorial_step).permit(:steps_number, :steps_body, :tutorial_step_image, :post_id, :slug, :user_id, :org_id)
92
92
  end
93
93
 
94
94
  end
@@ -5,7 +5,7 @@ module PhcdevworksTutorials
5
5
  extend FriendlyId
6
6
 
7
7
  #Relationships
8
- has_many :posts, class_name: 'PhcdevworksTutorials::Tutorial::Post'
8
+ has_and_belongs_to_many :posts, class_name: 'Tutorial::Post', :join_table => 'categories_posts', :dependent => :destroy
9
9
 
10
10
  # Form Fields Validation
11
11
  validates :tutorial_category_name,
@@ -4,9 +4,12 @@ module PhcdevworksTutorials
4
4
  # Clean URL Initialize
5
5
  extend FriendlyId
6
6
 
7
+ # Image Upload
8
+ has_one_attached :tutorial_post_image
9
+
7
10
  # Relationships
8
- belongs_to :category, class_name: 'PhcdevworksTutorials::Tutorial::Category'
9
- has_many :steps, class_name: "PhcdevworksTutorials::Tutorial::Step"
11
+ has_and_belongs_to_many :categories, class_name: 'Tutorial::Category', :join_table => 'categories_posts', :dependent => :destroy
12
+ has_many :steps, class_name: "Tutorial::Step"
10
13
 
11
14
  # Form Fields Validation
12
15
  validates :tutorial_post_title,
@@ -1,6 +1,9 @@
1
1
  module PhcdevworksTutorials
2
2
  class Tutorial::Step < ApplicationRecord
3
3
 
4
+ # Image Upload
5
+ has_one_attached :tutorial_step_image
6
+
4
7
  # Relationships
5
8
  belongs_to :post, class_name: "PhcdevworksTutorials::Tutorial::Post"
6
9
 
@@ -10,9 +10,34 @@
10
10
  <%= form.text_field :tutorial_post_title, placeholder: "Tutorial Title", class: "form-control" %>
11
11
  </div>
12
12
 
13
+ <div class="form-group field_with_errors">
14
+ <%= form.label :tutorial_post_description, "Tutorial Description" %>
15
+ <%= form.text_area :tutorial_post_description, class: "form-control", rows: "10" %>
16
+ </div>
17
+
18
+ <div class="form-group field_with_errors">
19
+ <%= form.label :tutorial_post_status, "Tutorial Status" %>
20
+ <%= form.select( :tutorial_post_status, [['Draft','draft'],['Published','published'],['Review','review']], {}, {class: "form-control form-control"}) %>
21
+ </div>
22
+
23
+ <div class="form-group field_with_errors">
24
+ <div class="form-group field_with_errors">
25
+ <%= form.label :tutorial_post_image, "Featured Image" %>
26
+ <%= form.file_field :tutorial_post_image, class: "form-control" %>
27
+ </div>
28
+ <% if form.object.tutorial_post_image.attached? %>
29
+ <%= image_tag main_app.url_for(form.object.tutorial_post_image), class: "img-responsive img-thumbnail" %>
30
+ <% end %>
31
+ </div>
32
+
13
33
  <div class="form-group field_with_errors">
14
34
  <label>Select a Category</label>
15
- <%= form.collection_select :category_id, PhcdevworksTutorials::Tutorial::Category.order(:tutorial_category_name),:id, :tutorial_category_name, {}, {class: "form-control"} %>
35
+ <div class="panel-body">
36
+ <%= form.collection_check_boxes :category_ids, PhcdevworksTutorials::Tutorial::Category.order(:tutorial_category_name), :id, :tutorial_category_name do |post_category| %>
37
+ <%= post_category.check_box %>
38
+ <%= post_category.label %><br>
39
+ <% end %>
40
+ </div>
16
41
  </div>
17
42
  <!-- Form Input Fields -->
18
43
 
@@ -37,7 +37,8 @@
37
37
  <thead>
38
38
  <tr>
39
39
  <th>Tutorial Title</th>
40
- <th>Tutorial Category</th>
40
+ <th>Tutorial Description</th>
41
+ <th>Tutorial Status</th>
41
42
  <th></th>
42
43
  </tr>
43
44
  </thead>
@@ -46,7 +47,8 @@
46
47
  <% @tutorial_posts.each do |tutorial_post| %>
47
48
  <tr>
48
49
  <td><%= tutorial_post.tutorial_post_title %></td>
49
- <td><%= tutorial_post.category.tutorial_category_name %></td>
50
+ <td><%= tutorial_post.tutorial_post_description %></td>
51
+ <td><%= tutorial_post.tutorial_post_status %></td>
50
52
  <td>
51
53
  <div class="btn-group d-flex" role="group">
52
54
  <%= link_to "Details", tutorial_post, class: "btn btn-purple btn-xs" %>
@@ -10,12 +10,22 @@
10
10
  <%= form.select( :tutorial_step_number, [["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"]], {}, {class: "form-control"}) %>
11
11
  </div>
12
12
 
13
- <div class="field">
14
- <%= form.label :tutorial_step_body %>
15
- <%= form.text_area :tutorial_step_body %>
13
+ <div class="form-group field_with_errors">
14
+ <%= form.label :tutorial_step_body, "Step Text" %>
15
+ <%= form.text_area :tutorial_step_body, class: "form-control", rows: "10" %>
16
+ </div>
17
+
18
+ <div class="form-group field_with_errors">
19
+ <div class="form-group field_with_errors">
20
+ <%= form.label :tutorial_step_image, "Step Image" %>
21
+ <%= form.file_field :tutorial_step_image, class: "form-control" %>
22
+ </div>
23
+ <% if form.object.tutorial_step_image.attached? %>
24
+ <%= image_tag main_app.url_for(form.object.tutorial_step_image), class: "img-responsive img-thumbnail" %>
25
+ <% end %>
16
26
  </div>
17
27
  <!-- Form Input Fields -->
18
-
28
+
19
29
  <!-- Form Submition Button -->
20
30
  <div class="actions">
21
31
  <%= form.submit class: "btn btn-primary" %>
@@ -47,9 +47,9 @@
47
47
  <tr>
48
48
  <td><%= tutorial_step.tutorial_step_number %></td>
49
49
  <td><%= tutorial_step.tutorial_step_body %></td>
50
- <td><%= link_to 'Show', tutorial_step %></td>
51
- <td><%= link_to 'Edit', edit_tutorial_step_path(tutorial_step) %></td>
52
- <td><%= link_to 'Destroy', tutorial_step, method: :delete, data: { confirm: 'Are you sure?' } %></td>
50
+ <td><%= link_to 'Show', tutorial_post_step_path(tutorial_step.post, tutorial_step) %></td>
51
+ <td><%= link_to 'Edit', edit_tutorial_post_step_path(tutorial_step.post, tutorial_step) %></td>
52
+ <td><%= link_to 'Destroy', tutorial_post_step_path(tutorial_step.post, tutorial_step), method: :delete, data: { confirm: 'Are you sure?' } %></td>
53
53
  </tr>
54
54
  <% end %>
55
55
  </tbody>
@@ -4,8 +4,6 @@ class CreatePhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
4
4
 
5
5
  t.string :tutorial_post_title
6
6
 
7
- t.references :category
8
-
9
7
  t.string :slug
10
8
  t.string :user_id
11
9
  t.string :org_id
@@ -0,0 +1,9 @@
1
+ class AddInfoToPhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
2
+ def change
3
+
4
+ add_column :phcdevworks_tutorials_tutorial_posts, :tutorial_post_images, :string
5
+ add_column :phcdevworks_tutorials_tutorial_posts, :tutorial_post_description, :text
6
+ add_column :phcdevworks_tutorials_tutorial_posts, :tutorial_post_status, :string
7
+
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ class AddInfoToPhcdevworksTutorialsTutorialSteps < ActiveRecord::Migration[6.0]
2
+ def change
3
+
4
+ add_column :phcdevworks_tutorials_tutorial_steps, :tutorial_step_images, :string
5
+
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class AddImageToPhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
2
+ def change
3
+
4
+ add_column :phcdevworks_tutorials_tutorial_steps, :tutorial_step_image, :string
5
+ add_column :phcdevworks_tutorials_tutorial_posts, :tutorial_post_image, :string
6
+
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ class CreateJoinTableCategoriesPosts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_join_table :categories, :posts do |t|
4
+
5
+ # t.index [:category_id, :post_id]
6
+ # t.index [:post_id, :category_id]
7
+
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module PhcdevworksTutorials
2
- VERSION = '1.0.2'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phcdevworks_tutorials
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - PHCDevworks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-25 00:00:00.000000000 Z
11
+ date: 2019-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -58,84 +58,84 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: 1.2.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.0'
68
+ version: 1.2.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: phcthemes_web_theme_pack
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.0'
75
+ version: 1.1.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.0'
82
+ version: 1.1.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: phcdevworks_active_menus
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.0'
89
+ version: 1.0.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.0'
96
+ version: 1.0.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: phcdevworks_notifications
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.0'
103
+ version: 1.0.1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.0'
110
+ version: 1.0.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: phcdevworks_titleseo
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.0'
117
+ version: 1.0.1
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.0'
124
+ version: 1.0.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: friendly_id
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '5.2'
131
+ version: '5.3'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '5.2'
138
+ version: '5.3'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: gravtastic
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '1.46'
159
+ version: '1.48'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '1.46'
166
+ version: '1.48'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: google-cloud-storage
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 1.1.0
201
+ version: 1.2.0
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 1.1.0
208
+ version: 1.2.0
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: sqlite3
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -213,9 +213,6 @@ dependencies:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
215
  version: '1.4'
216
- - - ">="
217
- - !ruby/object:Gem::Version
218
- version: 1.4.1
219
216
  type: :development
220
217
  prerelease: false
221
218
  version_requirements: !ruby/object:Gem::Requirement
@@ -223,9 +220,6 @@ dependencies:
223
220
  - - "~>"
224
221
  - !ruby/object:Gem::Version
225
222
  version: '1.4'
226
- - - ">="
227
- - !ruby/object:Gem::Version
228
- version: 1.4.1
229
223
  description: Ruby on Rails 6 Tutorial engine to manage and post tutorials.
230
224
  email:
231
225
  - developers@phcdevworks.com
@@ -292,6 +286,10 @@ files:
292
286
  - db/migrate/20190911225813_create_phcdevworks_tutorials_tutorial_posts.rb
293
287
  - db/migrate/20190911225925_create_phcdevworks_tutorials_tutorial_categories.rb
294
288
  - db/migrate/20190923113101_create_phcdevworks_tutorials_tutorial_steps.rb
289
+ - db/migrate/20190929044403_add_info_to_phcdevworks_tutorials_tutorial_posts.rb
290
+ - db/migrate/20190929044505_add_info_to_phcdevworks_tutorials_tutorial_steps.rb
291
+ - db/migrate/20191002093451_add_image_to_phcdevworks_tutorials_tutorial_posts.rb
292
+ - db/migrate/20191003235303_create_join_table_categories_posts.rb
295
293
  - lib/phcdevworks_tutorials.rb
296
294
  - lib/phcdevworks_tutorials/engine.rb
297
295
  - lib/phcdevworks_tutorials/version.rb