phcdevworks_tutorials 1.1.0 → 1.2.3

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: '08396c3e31fa52863cd02f3ee048a42ee5c5750e12fa1fbefe0fdcfd01fd886c'
4
- data.tar.gz: 417b0c4686adeafed8e66c503a0a50aa3fe608ea258a910056403126bcce7e7d
3
+ metadata.gz: 3195d42bc2b12f68a6193727f9261f3610350595e69daecde898b4bf161a2179
4
+ data.tar.gz: fc035c3777c0c86392c62f88599b429c8557f3988491de23b522a05c104a4d0f
5
5
  SHA512:
6
- metadata.gz: aa8cecbe28424e0700b533a43c629b4a2f34df37d409955d306a96a17039757eb9b2fc3dc887f0aaa5c3b03e6cc7ee9846b6e4a0a94594bff77fb9ce04ac8471
7
- data.tar.gz: e76c31a7754b25cbff079168a3fcee1b0cdf26105a5a316e136229bc256fe2603c30fc2b35ed3291b90fa1694a02f27013ac4bb48e79dff931b71a33acfa936c
6
+ metadata.gz: d8cc8b9cdd6c7585caecb7ee179cb681af0ecd6770b4a097ae71dc387fbb1248b6663b176bae243948debc23d67a2ff276f299997011fc507231ee7e853be426
7
+ data.tar.gz: 4870e32d9555d6aafb70219f466686620a5005f5cd4d996b45dba8078b9bf5f166d42ffbd369b293a5f700862d09454a9bfaebce0ecd5ed6772e347bb800e1ca
@@ -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,14 +4,21 @@ 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"
13
+ belongs_to :user, class_name: 'PhcdevworksAccounts::User'
10
14
 
11
15
  # Form Fields Validation
12
16
  validates :tutorial_post_title,
13
17
  presence: true
14
18
 
19
+ validates :tutorial_post_description,
20
+ presence: true
21
+
15
22
  # Clean URL Define
16
23
  friendly_id :phcdev_tutorials_post_nice_urls, use: [:slugged, :finders]
17
24
 
@@ -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,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.1.0'
2
+ VERSION = '1.2.3'
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.1.0
4
+ version: 1.2.3
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-29 00:00:00.000000000 Z
11
+ date: 2019-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -288,6 +288,8 @@ files:
288
288
  - db/migrate/20190923113101_create_phcdevworks_tutorials_tutorial_steps.rb
289
289
  - db/migrate/20190929044403_add_info_to_phcdevworks_tutorials_tutorial_posts.rb
290
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
291
293
  - lib/phcdevworks_tutorials.rb
292
294
  - lib/phcdevworks_tutorials/engine.rb
293
295
  - lib/phcdevworks_tutorials/version.rb