Skip to content

Commit 8f2facb

Browse files
committed
admins are now redirected to category post types edit page upon attempting to create a post without any allowed
1 parent 25eb7a1 commit 8f2facb

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

app/controllers/categories_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def post_types
130130
@post_types = @category.top_level_post_types
131131
if @post_types.one?
132132
redirect_to new_category_post_path(post_type: @post_types.first, category: @category)
133+
elsif @post_types.empty? && current_user&.admin?
134+
redirect_to edit_category_post_types_path(@category, no_return: '1')
133135
end
134136
end
135137

app/views/categories/category_post_types.html.erb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
<p class="has-font-size-caption">
2-
<%= link_to edit_category_path(@category) do %>
3-
&laquo; Back to category edit
4-
<% end %>
5-
</p>
1+
<%#
2+
View for managing allowed category post types
3+
4+
Parameters:
5+
params[:no_return] : whether to suppress the return link
6+
%>
7+
8+
<% unless params[:no_return] == '1' %>
9+
<p class="has-font-size-caption">
10+
<%= link_to edit_category_path(@category) do %>
11+
&laquo; Back to category edit
12+
<% end %>
13+
</p>
14+
<% end %>
615
<h1>Allowed post types for <%= @category.name %></h1>
716
<p class="has-font-size-caption">
817
Only post types listed here are allowed to be posted in this category. Not all will be displayed as available options

0 commit comments

Comments
 (0)