From fec0372073299d78d86c7c5c21a85e9713b3fce1 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 1 Oct 2018 19:36:58 -0300 Subject: [PATCH] todo lo que hacen lxs invitadxs se marca como borrador --- app/controllers/posts_controller.rb | 11 ++++++++++- app/models/post.rb | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index b1059b2b..59b3a3c9 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -49,10 +49,14 @@ class PostsController < ApplicationController # defecto es la usuaria actual if current_user.is_a? Usuaria @post.update_attributes({author: params[:post][:author]}) + else + # Todo lo que crean lxs invitadxs es borrador + @post.update_attributes({draft: true}) end @post.update_attributes({author: current_user.username}) unless @post.author if @post.save + flash[:success] = @site.config.dig('thanks') redirect_to site_posts_path(@site, lang: @lang) else render 'posts/new' @@ -78,10 +82,15 @@ class PostsController < ApplicationController # Solo las usuarias pueden modificar la autorĂ­a if current_user.is_a? Usuaria - @post.update_attributes({author: params[:post][:author]}) + @post.update_attributes({author: params[:post][:author]}) if params[:post][:author].present? + @post.update_attributes({draft: false}) + else + # Todo lo que crean lxs invitadxs es borrador + @post.update_attributes({draft: true}) end if @post.save + flash[:success] = @site.config.dig('thanks') redirect_to site_posts_path(@site, category: session[:category], lang: @lang) else render 'posts/edit' diff --git a/app/models/post.rb b/app/models/post.rb index f9215334..2141e6ad 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -20,7 +20,7 @@ class Post REJECT_FROM_DATA = %w[excerpt].freeze # datos que no tienen que terminar en el front matter - REJECT_FROM_FRONT_MATTER = %w[date slug draft ext].freeze + REJECT_FROM_FRONT_MATTER = %w[date slug ext].freeze # datos que no traemos del template REJECT_FROM_TEMPLATE = %w[draft categories layout title ext tags date slug].freeze DEFAULT_PARAMS = [:title, :date, :content, :slug, :cover,