storytime 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/storytime/application_controller.rb +20 -0
- data/app/controllers/storytime/comments_controller.rb +4 -2
- data/app/controllers/storytime/dashboard/media_controller.rb +3 -1
- data/app/controllers/storytime/dashboard/users_controller.rb +1 -1
- data/app/controllers/storytime/posts_controller.rb +1 -1
- data/app/models/storytime/autosave.rb +1 -1
- data/app/models/storytime/comment.rb +2 -2
- data/app/models/storytime/media.rb +1 -1
- data/app/models/storytime/post.rb +1 -1
- data/app/models/storytime/version.rb +1 -1
- data/app/views/storytime/dashboard/_navigation.html.erb +2 -2
- data/app/views/storytime/dashboard/users/_user.html.erb +3 -3
- data/app/views/storytime/dashboard/users/edit.html.erb +1 -1
- data/app/views/storytime/dashboard/users/new.html.erb +2 -1
- data/config/routes.rb +1 -1
- data/lib/storytime/concerns/storytime_user.rb +5 -0
- data/lib/storytime/version.rb +1 -1
- data/lib/storytime.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf39a31891a15bcee7b10824400ad71d55dada8c
|
4
|
+
data.tar.gz: 6827ab5ce70be645b272de46062d7ceaf991f726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3f251310c2b7af9a815b214d7b42df3b458756db96df5868a959c0b43c2ea5f676d5c87f666401014388d9809ba9fe97d00760f2847bc44877af6436f943061
|
7
|
+
data.tar.gz: 1cc0d64fee3ab5721d9a32c046a7f54cd211d7bee13de96d64c0da4ecee2f60643e227cffccf4e1155f34b631aa5d3ab9b5b163e4c0f07f582a68a5e95aaf315
|
@@ -8,6 +8,12 @@ class Storytime::ApplicationController < ApplicationController
|
|
8
8
|
|
9
9
|
helper :all
|
10
10
|
|
11
|
+
if Storytime.user_class_symbol != :user
|
12
|
+
helper_method :authenticate_user!
|
13
|
+
helper_method :current_user
|
14
|
+
helper_method :user_signed_in?
|
15
|
+
end
|
16
|
+
|
11
17
|
def setup
|
12
18
|
url = if Storytime.user_class.count == 0
|
13
19
|
main_app.new_user_registration_url
|
@@ -22,6 +28,20 @@ class Storytime::ApplicationController < ApplicationController
|
|
22
28
|
redirect_to url
|
23
29
|
end
|
24
30
|
|
31
|
+
if Storytime.user_class_symbol != :user
|
32
|
+
def authenticate_user!
|
33
|
+
send("authenticate_#{Storytime.user_class.to_s.downcase}!".to_sym)
|
34
|
+
end
|
35
|
+
|
36
|
+
def current_user
|
37
|
+
send("current_#{Storytime.user_class.to_s.downcase}".to_sym)
|
38
|
+
end
|
39
|
+
|
40
|
+
def user_signed_in?
|
41
|
+
send("#{Storytime.user_class.to_s.downcase}_signed_in?".to_sym)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
25
45
|
private
|
26
46
|
def ensure_site
|
27
47
|
redirect_to new_dashboard_site_url unless devise_controller? || @site = Storytime::Site.first
|
@@ -10,8 +10,10 @@ module Storytime
|
|
10
10
|
respond_to :json, only: :destroy
|
11
11
|
|
12
12
|
def create
|
13
|
-
@comment =
|
13
|
+
@comment = Comment.new(comment_params)
|
14
|
+
@comment.user = current_user
|
14
15
|
@comment.post = @post
|
16
|
+
|
15
17
|
authorize @comment
|
16
18
|
opts = { notice: I18n.t('flash.comments.create.success') } if @comment.save
|
17
19
|
redirect_to @post, opts
|
@@ -31,7 +33,7 @@ module Storytime
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def comment_params
|
34
|
-
params.require(:comment).permit(*policy(@comment ||
|
36
|
+
params.require(:comment).permit(*policy(@comment || Comment.new).permitted_attributes)
|
35
37
|
end
|
36
38
|
|
37
39
|
end
|
@@ -49,7 +49,7 @@ module Storytime
|
|
49
49
|
|
50
50
|
private
|
51
51
|
def user_params
|
52
|
-
params.require(
|
52
|
+
params.require(Storytime.user_class_symbol).permit(:email, :storytime_role_id, :storytime_name, :password, :password_confirmation)
|
53
53
|
end
|
54
54
|
|
55
55
|
def load_user
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Storytime
|
2
2
|
class Comment < ActiveRecord::Base
|
3
|
-
belongs_to Storytime.
|
3
|
+
belongs_to :user, class_name: Storytime.user_class.to_s
|
4
4
|
belongs_to :post
|
5
5
|
|
6
|
-
validates
|
6
|
+
validates :user, presence: true
|
7
7
|
validates :post_id, presence: true
|
8
8
|
|
9
9
|
def commenter_name
|
@@ -6,7 +6,7 @@ module Storytime
|
|
6
6
|
extend FriendlyId
|
7
7
|
friendly_id :slug_candidates, use: [:history]
|
8
8
|
|
9
|
-
belongs_to Storytime.
|
9
|
+
belongs_to :user, class_name: Storytime.user_class.to_s
|
10
10
|
belongs_to :featured_media, class_name: "Media"
|
11
11
|
belongs_to :secondary_media, class_name: "Media"
|
12
12
|
|
@@ -27,7 +27,7 @@
|
|
27
27
|
<% end %>
|
28
28
|
|
29
29
|
<% if Pundit.policy(current_user, Storytime.user_class).index? %>
|
30
|
-
<li <%= active_nav_item_class("users") %>><%= link_to "Users", storytime.url_for([:dashboard,
|
30
|
+
<li <%= active_nav_item_class("users") %>><%= link_to "Users", storytime.url_for([:dashboard, :users]) %></li>
|
31
31
|
<% end %>
|
32
32
|
|
33
33
|
<% if Pundit.policy(current_user, Storytime::Site).edit? %>
|
@@ -43,7 +43,7 @@
|
|
43
43
|
</a>
|
44
44
|
<ul class="dropdown-menu">
|
45
45
|
<li><%= link_to "My Account", storytime.edit_dashboard_user_path(current_user) %></li>
|
46
|
-
<li><%= link_to "Sign Out", main_app.
|
46
|
+
<li><%= link_to "Sign Out", main_app.send("destroy_#{Storytime.user_class_underscore}_session_path"), method: :delete %></li>
|
47
47
|
</ul>
|
48
48
|
</li>
|
49
49
|
</ul>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<tr id="
|
1
|
+
<tr id="<%= Storytime.user_class_underscore %>_<%= user.id %>">
|
2
2
|
<td><%= user.email %></td>
|
3
3
|
<td><%= user.storytime_name %></td>
|
4
4
|
<td><%= user.storytime_role.name.humanize if user.storytime_role %></td>
|
5
5
|
<td class='right'>
|
6
6
|
<div class="btn-group">
|
7
|
-
<%= link_to t('dashboard.users.edit_user_button'),
|
8
|
-
<%= delete_resource_link user,
|
7
|
+
<%= link_to t('dashboard.users.edit_user_button'), url_for(:controller => 'dashboard/users', :action => 'edit', :id => user.id), class: "btn btn-xs btn-default" %>
|
8
|
+
<%= delete_resource_link user, dashboard_user_url(user) unless user == current_user %>
|
9
9
|
</div>
|
10
10
|
</td>
|
11
11
|
</tr>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="container">
|
2
2
|
<h2><%= t('dashboard.users.edit_user_header') %></h2>
|
3
3
|
|
4
|
-
<%= simple_form_for
|
4
|
+
<%= simple_form_for @user, :url => dashboard_user_path do |f| %>
|
5
5
|
<%= f.input :email %>
|
6
6
|
<%= f.input :storytime_name %>
|
7
7
|
<%= f.association :storytime_role, include_blank: true, label_method: :label %>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<div class="container">
|
2
2
|
<h2>New User</h2>
|
3
|
-
|
3
|
+
|
4
|
+
<%= simple_form_for @user, :url => dashboard_users_path, :method => :post do |f| %>
|
4
5
|
<%= f.input :email %>
|
5
6
|
<%= f.association :storytime_role, include_blank: false, label_method: :label %>
|
6
7
|
<%= f.input :password %>
|
data/config/routes.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
resources :snippets, except: [:show]
|
11
11
|
resources :media, except: [:show, :edit, :update]
|
12
12
|
resources :imports, only: [:new, :create]
|
13
|
-
resources :users
|
13
|
+
resources :users, path: Storytime.user_class_underscore.pluralize
|
14
14
|
resources :roles do
|
15
15
|
collection do
|
16
16
|
patch :update_multiple
|
@@ -6,6 +6,7 @@ module Storytime
|
|
6
6
|
module ClassMethods
|
7
7
|
def storytime_user
|
8
8
|
belongs_to :storytime_role, class_name: "Storytime::Role"
|
9
|
+
|
9
10
|
has_many :storytime_posts, class_name: "Storytime::Post"
|
10
11
|
has_many :storytime_pages, class_name: "Storytime::Page"
|
11
12
|
has_many :storytime_media, class_name: "Storytime::Media"
|
@@ -13,6 +14,10 @@ module Storytime
|
|
13
14
|
has_many :storytime_comments, class_name: "Storytime::Comment"
|
14
15
|
|
15
16
|
class_eval <<-EOS
|
17
|
+
def self.policy_class
|
18
|
+
UserPolicy
|
19
|
+
end
|
20
|
+
|
16
21
|
def storytime_user?
|
17
22
|
!storytime_role.nil?
|
18
23
|
end
|
data/lib/storytime/version.rb
CHANGED
data/lib/storytime.rb
CHANGED
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storytime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Roesch, David Van Der Beek, Brandon Robins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|