-
Notifications
You must be signed in to change notification settings - Fork 794
AO3-6960 Admin post drafts and previews #5822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcus8448
wants to merge
8
commits into
otwcode:master
Choose a base branch
from
marcus8448:AO3-6960
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1de91b9
AO3-6960 Admin post drafts and previews
marcus8448 4f509e9
AO3-6960 Dog and lint
marcus8448 f64b903
AO3-6960 Remove unused i18n key
marcus8448 812df7c
AO3-6960 Check validity before previewing new admin posts
marcus8448 f568aaf
AO3-6960 Use pagy on the normal index
marcus8448 51e464f
AO3-6960 Add admin permission check for draft news link in nav
marcus8448 d8befd7
AO3-6960 Missing closing tag and double 'an'
marcus8448 1897463
AO3-6960 Add validation to prevent posting translations before the or…
marcus8448 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,25 @@ | ||
| class AdminPostPolicy < ApplicationPolicy | ||
| POSTING_ROLES = %w[superadmin board board_assistants_team communications support translation].freeze | ||
| DRAFTING_ROLES = %w[policy_and_abuse].freeze | ||
|
|
||
| def can_post? | ||
| user_has_roles?(POSTING_ROLES) | ||
| end | ||
|
|
||
| alias new? can_post? | ||
| alias edit? can_post? | ||
| alias create? can_post? | ||
| alias update? can_post? | ||
| alias destroy? can_post? | ||
| def can_draft? | ||
| user_has_roles?(DRAFTING_ROLES) || can_post? | ||
| end | ||
|
|
||
| def edit? | ||
| can_post? || (@record&.draft? && can_draft?) | ||
| end | ||
|
|
||
| alias new? can_draft? | ||
| alias show? can_draft? | ||
| alias create? edit? | ||
| alias update? edit? | ||
| alias destroy? edit? | ||
| alias post? can_post? | ||
| alias drafts? can_draft? | ||
| alias preview? edit? | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,17 @@ | ||
| <!--Descriptive page name, messages and instructions--> | ||
| <h2 class="heading"><%= ts("AO3 News (includes Release Notes)") %></h2> | ||
| <h2 class="heading"><%= t(".page_heading") %></h2> | ||
| <!--/descriptions--> | ||
| <!--subnav--> | ||
| <%= render 'filters' %> | ||
| <%= render :partial => 'admin/admin_nav' %> | ||
| <!--/subnav--> | ||
|
|
||
| <!--main content--> | ||
| <h3 class="heading"><%= ts("Manage News Postings") %></h3> | ||
| <h3 class="landmark heading"><%= t(".landmark") %></h3> | ||
| <dl class="news index group"> | ||
| <% @admin_posts.each do |admin_post| %> | ||
| <dt><%= link_to admin_post.title.html_safe, admin_post %></dt> | ||
| <dd> | ||
| <p class="datetime"><%= ts("Created at %{created_date} and updated at %{updated_date}", :created_date => admin_post.created_at, :updated_date => admin_post.updated_at) %></p> | ||
| <ul class="actions"> | ||
| <li><%= link_to ts("Show"), admin_post %></li> | ||
| <li><%= link_to ts("Edit"), edit_admin_post_path(admin_post) %></li> | ||
| <li><%= link_to ts("Delete"), admin_post, data: {confirm: 'Are you sure?'}, :method => :delete %></li> | ||
| </ul> | ||
| </dd> | ||
| <% end %> | ||
| <%= render partial: "admin_post_blurb", collection: @admin_posts, as: :admin_post %> | ||
| </dl> | ||
| <!--/content--> | ||
| <!--subnav--> | ||
| <%= will_paginate @admin_posts %> | ||
| <%== pagy_nav @pagy %> | ||
| <!--/subnav--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check
@admin_post&.translated_post&.draft?like we do in create and update to avoid potential bugs?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a validation to the model to prevent translations from being posted first, which should cover this and also prevent already published posts from turned into translations of a draft post.