Made having a confirmed email required to manage blog posts.
This commit is contained in:
@@ -69,7 +69,7 @@ class BlogpostsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def auth
|
def auth
|
||||||
unless mod?
|
unless mod? && current_user.confirmed?
|
||||||
flash[:alert] = "You are not allowed to edit posts!"
|
flash[:alert] = "You are not allowed to edit posts!"
|
||||||
redirect_to @post ? @post : blogposts_path
|
redirect_to @post ? @post : blogposts_path
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
<% title "Edit News: #{@post.title}" %>
|
<% title "Edit News: #{@post.title}" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
def can_edit?
|
||||||
|
mod? && current_user.confirmed?
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
|
||||||
<h1>Edit post</h1>
|
<h1>Edit post</h1>
|
||||||
<%= form_for @post do |f|%>
|
<%= form_for @post do |f|%>
|
||||||
<%= f.text_field :title %>
|
<%= f.text_field :title, disabled: !can_edit? %>
|
||||||
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content} %>
|
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, options: {disabled: !can_edit?}} %>
|
||||||
<p><%= f.submit "Update Post", class: "btn blue left" %></p>
|
<p><%= f.submit "Update Post", class: "btn blue left", disabled: !can_edit? %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p><%= button_to "Delete post", @post, method: "delete", data: {confirm: "Delete post & comments forever?"}, class: "btn red right" %></p>
|
<p><%= button_to "Delete post", @post, method: "delete", data: {confirm: "Delete post & comments forever?"}, class: "btn red right", disabled: !can_edit? %></p>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|
||||||
|
<% if !current_user.confirmed? %>
|
||||||
|
<span class='red-alert'>You must confirm your email before you can edit blog posts.</span>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
<% title "New Blog Post" %>
|
<% title "New Blog Post" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
def can_create?
|
||||||
|
admin? && current_user.confirmed?
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
|
||||||
<h1>New Post</h1>
|
<h1>New Post</h1>
|
||||||
<%= form_for @post do |f|%>
|
<%= form_for @post do |f|%>
|
||||||
<%= f.text_field :title, placeholder: "Title" %>
|
<%= f.text_field :title, placeholder: "Title", disabled: !can_create? %>
|
||||||
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content} %>
|
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, options: {disabled: !can_create?}} %>
|
||||||
<p><%= f.submit "Create Post", class: "btn blue left" %></p>
|
<p><%= f.submit "Create Post", class: "btn blue left", disabled: !can_create? %></p>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|
||||||
|
<% if !current_user.confirmed? %>
|
||||||
|
<span class='red-alert'>You must confirm your email before you can create new blog posts.</span>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user