5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 02:41:41 +00:00

por defecto la autora es la usuaria actual

This commit is contained in:
f 2018-09-28 15:10:10 -03:00
parent 451bdc36e0
commit 32d8ebd1e8
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
2 changed files with 7 additions and 3 deletions

View file

@ -45,8 +45,12 @@ class PostsController < ApplicationController
@post = Post.new(site: @site, lang: @lang, template: @template)
@post.update_attributes(repair_nested_params(post_params))
# El author no se modifica
@post.update_attributes({author: current_user.username})
# Las usuarias pueden especificar una autora, de la contrario por
# 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
redirect_to site_posts_path(@site, lang: @lang)

View file

@ -24,7 +24,7 @@
= label_tag 'post_author', t('posts.author')
- todxs = (@site.usuarias + @site.invitadxs).map(&:username)
= select_tag 'post[author]',
options_for_select(todxs, @post.author),
options_for_select(todxs, @post.author || current_user.email),
{ class: 'form-control select2',
data: { tags: true,
placeholder: t('posts.select.placeholder'),