diff --git a/app/controllers/info_controller.rb b/app/controllers/info_controller.rb index 7834d2a..86605d7 100644 --- a/app/controllers/info_controller.rb +++ b/app/controllers/info_controller.rb @@ -62,7 +62,7 @@ class InfoController < ApplicationController end def auth - unless mod? + unless mod? && current_user.confirmed? flash[:alert] = "You are not allowed to edit info pages!" redirect_to @info ? @info : info_index_path end diff --git a/app/views/info/edit.html.erb b/app/views/info/edit.html.erb index 0f90c74..7443e3f 100644 --- a/app/views/info/edit.html.erb +++ b/app/views/info/edit.html.erb @@ -1,10 +1,20 @@ <% title "Edit Info: #{@info.title}" %> +<% + def can_edit? + mod? && current_user.confirmed? + end +%> +
<%= f.submit "Update Info", class: "btn blue left" %>
+ <%= f.text_field :title, disabled: !can_edit? %> + <%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, options: {disabled: !can_edit?}} %> +<%= f.submit "Update Info", class: "btn blue left", disabled: !can_edit? %>
<% end %> -<%= button_to "Delete Info", @info, method: "delete", data: {confirm: "Are you sure you want to delete this info page?"}, class: "btn red right" %>
+<%= button_to "Delete Info", @info, method: "delete", data: {confirm: "Are you sure you want to delete this info page?"}, class: "btn red right", disabled: !can_edit? %>
+ +<% if !current_user.confirmed? %> + You must confirm your email before you can edit info pages. +<% end %> diff --git a/app/views/info/new.html.erb b/app/views/info/new.html.erb index 55abdb7..dc50720 100644 --- a/app/views/info/new.html.erb +++ b/app/views/info/new.html.erb @@ -1,9 +1,19 @@ <% title "New Info" %> +<% + def can_create? + mod? && current_user.confirmed? + end +%> +<%= f.submit "Create Info", class: "btn blue left" %>
+ <%= f.text_field :title, placeholder: "Title", disabled: !can_create? %> + <%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, options: {disabled: !can_create?}} %> +<%= f.submit "Create Info", class: "btn blue left", disabled: !can_create? %>
+ + <% if !current_user.confirmed? %> + You must confirm your email before you can create new info pages. + <% end %> <% end %>