5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 14:51:41 +00:00

feat: cuando se modifica la licencia, considerarla personalizada

This commit is contained in:
f 2023-04-03 16:58:22 -03:00
parent 661655abb5
commit b7a27a87dd
4 changed files with 23 additions and 0 deletions

View file

@ -17,4 +17,8 @@ class Licencia < ApplicationRecord
validates :description, presence: true
validates :short_description, presence: true
validates :deed, presence: true
def custom?
url == 'custom'
end
end

View file

@ -18,6 +18,8 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
commit(action: :created, file: update_related_posts) if post.update(post_params)
update_site_license!
# Devolver el post aunque no se haya salvado para poder rescatar los
# errores
post
@ -44,6 +46,8 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
# relacionados.
commit(action: :updated, file: update_related_posts) if post.update(post_params)
update_site_license!
# Devolver el post aunque no se haya salvado para poder rescatar los
# errores
post
@ -137,4 +141,12 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
p.path.absolute if p.save(validate: false)
end.compact << post.path.absolute
end
# Si les usuaries modifican o crean una licencia, considerarla
# personalizada en el panel.
def update_site_license!
if site.usuarie?(usuarie) && post.layout.name == :license
site.update licencia: Licencia.find_by_url('custom')
end
end
end

View file

@ -79,6 +79,7 @@
%h2= t('.licencia.title')
%p.lead= t('.help.licencia')
- Licencia.all.find_each do |licencia|
- next if licencia.custom? && site.licencia != licencia
.row.license
.col
.media.mt-1

View file

@ -1,4 +1,10 @@
---
- name_en: "Custom license"
name_es: "Licencia personalizada"
url_en: "custom"
url_es: "custom"
description_en: "The license terms are provided by you."
description_es: "Los términos de la licencia fueron provistos por vos."
- name_en: 'Peer Production License'
name_es: 'Licencia de Producción de Pares'
short_description_en: "This work is licensed under a Peer Production License"