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:
Ben Halpern 2018-10-08 16:35:02 -04:00 committed by GitHub
parent e62ffd0ff5
commit a14c37f4ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -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(

View file

@ -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 %>