minor fixes

This commit is contained in:
Andrew Brown 2018-09-16 21:17:44 -05:00
parent 42feb3ca4e
commit 833199dfc6
5 changed files with 15 additions and 9 deletions

View File

@ -82,8 +82,13 @@ class ContentController < ApplicationController
end
def edit
@content = content_type_from_controller(self.class)
.find(params[:id])
content_type_class = content_type_from_controller(self.class)
@content = content_type_class.find_by(id: params[:id])
if @content.nil?
return redirect_to root_path,
notice: "Either this #{content_type_class.name.downcase} doesn't exist, or you don't have access to view it."
end
unless @content.updatable_by? current_user
return redirect_to @content, notice: t(:no_do_permission)
@ -238,8 +243,8 @@ class ContentController < ApplicationController
private
def migrate_old_style_field_values
content ||= content_type_from_controller(self.class).find(params[:id])
TemporaryFieldMigrationService.migrate_fields_for_content(content, current_user)
content ||= content_type_from_controller(self.class).find_by(id: params[:id])
TemporaryFieldMigrationService.migrate_fields_for_content(content, current_user) if content.present?
end
def valid_content_types

View File

@ -27,7 +27,7 @@ class UsersController < ApplicationController
def delete_my_account # :(
unless user_signed_in?
redirect_to root_path
redirect_to(root_path, notice: "You must be signed in to do that!")
return
end
@ -40,7 +40,7 @@ class UsersController < ApplicationController
report_user_deletion_to_slack(current_user)
current_user.really_destroy!
redirect_to root_path, notice: 'Your account has been deleted. We will miss you greatly!'
redirect_to(root_path, notice: 'Your account has been deleted. We will miss you greatly!')
end
def report_user_deletion_to_slack user

View File

@ -16,14 +16,14 @@
<% end %>
</div>
<script type="text/javascript">
<%= content_for :javascripts do %>
$(document).ready(function(){
$('.slider').slider({
height: 200,
indicators: false
});
});
</script>
<% end %>
<% if @content.persisted? %>
<%= render partial: 'content/share', locals: { shared_content: @content} %>

View File

@ -163,5 +163,6 @@
<script style="text/javascript">
// todo see if the M.init in application.html covers this
$(".dropdown-trigger").dropdown();
</script>

View File

@ -3,4 +3,4 @@
</div>
<div class="col s12 m6">
<%= render partial: 'cards/user/recent_activity', locals: { title: 'Recently-created pages', content_list: @recent_creates } %>
</div>
</div>