por defecto la autora es la usuaria actual
This commit is contained in:
parent
451bdc36e0
commit
32d8ebd1e8
2 changed files with 7 additions and 3 deletions
|
@ -45,8 +45,12 @@ class PostsController < ApplicationController
|
||||||
@post = Post.new(site: @site, lang: @lang, template: @template)
|
@post = Post.new(site: @site, lang: @lang, template: @template)
|
||||||
@post.update_attributes(repair_nested_params(post_params))
|
@post.update_attributes(repair_nested_params(post_params))
|
||||||
|
|
||||||
# El author no se modifica
|
# Las usuarias pueden especificar una autora, de la contrario por
|
||||||
@post.update_attributes({author: current_user.username})
|
# defecto es la usuaria actual
|
||||||
|
if current_user.is_a? Usuaria
|
||||||
|
@post.update_attributes({author: params[:post][:author]})
|
||||||
|
end
|
||||||
|
@post.update_attributes({author: current_user.username}) unless @post.author
|
||||||
|
|
||||||
if @post.save
|
if @post.save
|
||||||
redirect_to site_posts_path(@site, lang: @lang)
|
redirect_to site_posts_path(@site, lang: @lang)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
= label_tag 'post_author', t('posts.author')
|
= label_tag 'post_author', t('posts.author')
|
||||||
- todxs = (@site.usuarias + @site.invitadxs).map(&:username)
|
- todxs = (@site.usuarias + @site.invitadxs).map(&:username)
|
||||||
= select_tag 'post[author]',
|
= select_tag 'post[author]',
|
||||||
options_for_select(todxs, @post.author),
|
options_for_select(todxs, @post.author || current_user.email),
|
||||||
{ class: 'form-control select2',
|
{ class: 'form-control select2',
|
||||||
data: { tags: true,
|
data: { tags: true,
|
||||||
placeholder: t('posts.select.placeholder'),
|
placeholder: t('posts.select.placeholder'),
|
||||||
|
|
Loading…
Reference in a new issue