Add policy for article manage action (#2643)

* Add policy for article manage action

This commit adds a policy for the articles#manage method. This will
prevent the error that is stopping article owners from managing their
articles.

* Hide manage button if article isnt published

* account for no current_user

* Move button logic to javascript
This commit is contained in:
Kobe Raypole 2019-05-02 19:31:26 -04:00 committed by Ben Halpern
parent 5891b2ea58
commit bb16b36ca7
2 changed files with 5 additions and 4 deletions

View file

@ -73,12 +73,12 @@ function addRelevantButtonsToArticle(user) {
var articleContainer = document.getElementById('article-show-container');
if (articleContainer) {
if (parseInt(articleContainer.dataset.authorId) == user.id) {
var manageButtonHTML = '<a href="' +articleContainer.dataset.path+ '/manage" rel="nofollow">MANAGE</a>'
document.getElementById('action-space').innerHTML =
'<a href="' +
articleContainer.dataset.path +
'/edit" rel="nofollow">EDIT</a><a href="' +
articleContainer.dataset.path +
'/manage" rel="nofollow">MANAGE</a>';
'/edit" rel="nofollow">EDIT</a>' +
(JSON.parse(articleContainer.dataset.published) == true ? manageButtonHTML : "")
} else if (user.trusted) {
document.getElementById('action-space').innerHTML =
'<a href="' +

View file

@ -70,7 +70,8 @@
id="article-show-container"
data-author-id="<%= @article.user_id %>"
data-live="<%= @article.live_now %>"
data-path="<%= @article.path %>">
data-path="<%= @article.path %>"
data-published="<%= @article.published? %>">
<% if @article.video_state == "PROGRESSING" %>
<h1 style="text-align:center;">⏳ Video Transcoding In Progress ⏳</h1>
<% end %>