Add some html to internal articles and new internal view (#4636)
* Add some html to internal articles and new internal view * Add check for article existence for buffer updates * Change arrays to unions
This commit is contained in:
parent
bb55efb775
commit
ec6d66018f
5 changed files with 74 additions and 27 deletions
7
app/controllers/internal/permissions_controller.rb
Normal file
7
app/controllers/internal/permissions_controller.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class Internal::PermissionsController < Internal::ApplicationController
|
||||
layout "internal"
|
||||
|
||||
def index
|
||||
@users = User.with_role(:admin).union(User.with_role(:super_admin)).union(User.with_role(:single_resource_admin, :any))
|
||||
end
|
||||
end
|
||||
|
|
@ -44,33 +44,36 @@
|
|||
</h1>
|
||||
<% end %>
|
||||
|
||||
<% @pending_buffer_updates.each do |buffer_update| %>
|
||||
<div class="row">
|
||||
<h2><%= buffer_update.article.title %></h2>
|
||||
<h4>Score: <%= buffer_update.article.score %></h4>
|
||||
<hr />
|
||||
<%= HTML_Truncator.truncate(buffer_update.article.processed_html,
|
||||
50, ellipsis: '<a class="comment-read-more" href="' + buffer_update.article.path + '">... Read Entire Post</a>').html_safe %>
|
||||
<hr />
|
||||
<code><b><%= Tag.find_by(id: buffer_update.tag_id)&.name || buffer_update.social_service_name %>:</b></code>
|
||||
<form action="/internal/buffer_updates/<%= buffer_update.id %>" accept-charset="UTF-8" method="post">
|
||||
<input name="utf8" type="hidden" value="✓">
|
||||
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
|
||||
<input type="hidden" name="_method" value="patch" />
|
||||
<input type="hidden" name="status" value="confirmed" />
|
||||
<textarea name="body_text" style="height: 100px"><%= buffer_update.body_text %></textarea>
|
||||
<br />
|
||||
<button value="confirmed" name="status" class="btn btn-success">confirm</button>
|
||||
</form>
|
||||
<form action="/internal/buffer_updates/<%= buffer_update.id %>" accept-charset="UTF-8" method="post">
|
||||
<input name="utf8" type="hidden" value="✓">
|
||||
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
|
||||
<input type="hidden" name="_method" value="patch" />
|
||||
<input type="hidden" name="status" value="dismissed" />
|
||||
<button value="dismissed" name="status" class="btn btn-danger">dismiss</button>
|
||||
</form>
|
||||
</div>
|
||||
<% end %>
|
||||
<details>
|
||||
<summary style="font-size: 1.3em; cursor: pointer;">Suggested tweets (<%= @pending_buffer_updates.size %>)</summary>
|
||||
<% @pending_buffer_updates.each do |buffer_update| %>
|
||||
<% next unless buffer_update.article %>
|
||||
<div class="row">
|
||||
<h2><%= buffer_update.article.title %></h2>
|
||||
<h4>Score: <%= buffer_update.article.score %></h4>
|
||||
<hr />
|
||||
<%= HTML_Truncator.truncate(buffer_update.article.processed_html, 50, ellipsis: '<a class="comment-read-more" href="' + buffer_update.article.path + '">... Read Entire Post</a>').html_safe %>
|
||||
<hr />
|
||||
<code><b><%= Tag.find_by(id: buffer_update.tag_id)&.name || buffer_update.social_service_name %>:</b></code>
|
||||
<form action="/internal/buffer_updates/<%= buffer_update.id %>" accept-charset="UTF-8" method="post">
|
||||
<input name="utf8" type="hidden" value="✓">
|
||||
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
|
||||
<input type="hidden" name="_method" value="patch" />
|
||||
<input type="hidden" name="status" value="confirmed" />
|
||||
<textarea name="body_text" style="height: 100px"><%= buffer_update.body_text %></textarea>
|
||||
<br />
|
||||
<button value="confirmed" name="status" class="btn btn-success">confirm</button>
|
||||
</form>
|
||||
<form action="/internal/buffer_updates/<%= buffer_update.id %>" accept-charset="UTF-8" method="post">
|
||||
<input name="utf8" type="hidden" value="✓">
|
||||
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
|
||||
<input type="hidden" name="_method" value="patch" />
|
||||
<input type="hidden" name="status" value="dismissed" />
|
||||
<button value="dismissed" name="status" class="btn btn-danger">dismiss</button>
|
||||
</form>
|
||||
</div>
|
||||
<% end %>
|
||||
</details>
|
||||
|
||||
<% if @featured_articles && @featured_articles.any? %>
|
||||
<h1>Manually Featured Articles</h1>
|
||||
|
|
|
|||
13
app/views/internal/permissions/index.html.erb
Normal file
13
app/views/internal/permissions/index.html.erb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<h1>Admin Roles</h1>
|
||||
|
||||
<div class="wrapper" style="font-weight: 600; border-bottom: 2px solid black; grid-template-columns: 25% 25% 50%;">
|
||||
<div>ID</div>
|
||||
<div>Profile</div>
|
||||
<div>Roles</div>
|
||||
</div>
|
||||
<% @users.each do |user| %>
|
||||
<div class="wrapper" style="border-top: 1px solid grey; padding: 10px; grid-template-columns: 25% 25% 50%; font-size: 0.9em">
|
||||
<div><a href="/internal/users/<%= user.id %>"><%= user.id %></a></div>
|
||||
<div><a href="<%= user.path %>">@<%= user.username %></a></div>
|
||||
<div><%= user.roles.pluck(:name) %></div>
|
||||
<% end %>
|
||||
|
|
@ -41,6 +41,7 @@ Rails.application.routes.draw do
|
|||
resources :listings, only: %i[index edit update destroy], controller: "classified_listings"
|
||||
resources :pages, only: %i[index new create edit update destroy]
|
||||
resources :mods, only: %i[index update]
|
||||
resources :permissions, only: %i[index]
|
||||
resources :podcasts, only: %i[index edit update destroy] do
|
||||
member do
|
||||
post :add_admin
|
||||
|
|
|
|||
23
spec/requests/internal/permissions_spec.rb
Normal file
23
spec/requests/internal/permissions_spec.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "/internal/permissions", type: :request do
|
||||
let(:super_admin) { create(:user, :super_admin) }
|
||||
let(:regular_user) { create(:user) }
|
||||
|
||||
describe "GET /internal/mods" do
|
||||
before do
|
||||
sign_in super_admin
|
||||
end
|
||||
|
||||
it "displays admin users" do
|
||||
regular_user.add_role(:admin)
|
||||
get "/internal/permissions"
|
||||
expect(response.body).to include(regular_user.username)
|
||||
end
|
||||
|
||||
it "does not display non-admin" do
|
||||
get "/internal/permissions"
|
||||
expect(response.body).not_to include(regular_user.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue