Add tag when submission templated to v2 (#863)
* Add tag when submission templated to v2 * Protect against no user in articles/new
This commit is contained in:
parent
e62ffd0ff5
commit
a14c37f4ab
2 changed files with 7 additions and 3 deletions
|
|
@ -42,13 +42,17 @@ class ArticlesController < ApplicationController
|
|||
@user = current_user
|
||||
@organization = @user&.organization
|
||||
@tag = Tag.find_by_name(params[:template])
|
||||
@article = if @tag&.submission_template.present? && @user
|
||||
@article = if @tag.present? && @user&.editor_version == "v2"
|
||||
authorize Article
|
||||
Article.new(body_markdown: "", cached_tag_list: @tag.name,
|
||||
processed_html: "")
|
||||
elsif @tag&.submission_template.present? && @user
|
||||
authorize Article
|
||||
Article.new(body_markdown: @tag.submission_template_customized(@user.name),
|
||||
processed_html: "")
|
||||
else
|
||||
skip_authorization
|
||||
if params[:state] == "v2" || Rails.env.development?
|
||||
if @user&.editor_version == "v2"
|
||||
Article.new
|
||||
else
|
||||
Article.new(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<% title "New Post" %>
|
||||
|
||||
<% if user_signed_in? %>
|
||||
<% if params[:state] == "v2" || current_user.editor_version == "v2" || (Rails.env.development? && params[:state] != "v1") %>
|
||||
<% if current_user.editor_version == "v2" %>
|
||||
<%= javascript_pack_tag 'articleForm', defer: true %>
|
||||
<%= render 'articles/v2_form' %>
|
||||
<% else %>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue