5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 04:56:22 +00:00

Merge branch 'issue-159' into panel.sutty.nl

This commit is contained in:
f 2023-04-03 16:59:00 -03:00
commit 97b746bc9f
4 changed files with 23 additions and 0 deletions

View file

@ -17,4 +17,8 @@ class Licencia < ApplicationRecord
validates :description, presence: true validates :description, presence: true
validates :short_description, presence: true validates :short_description, presence: true
validates :deed, presence: true validates :deed, presence: true
def custom?
url == 'custom'
end
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) 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 # Devolver el post aunque no se haya salvado para poder rescatar los
# errores # errores
post post
@ -44,6 +46,8 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
# relacionados. # relacionados.
commit(action: :updated, file: update_related_posts) if post.update(post_params) 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 # Devolver el post aunque no se haya salvado para poder rescatar los
# errores # errores
post post
@ -137,4 +141,12 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
p.path.absolute if p.save(validate: false) p.path.absolute if p.save(validate: false)
end.compact << post.path.absolute end.compact << post.path.absolute
end 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 end

View file

@ -81,6 +81,7 @@
%h2= t('.licencia.title') %h2= t('.licencia.title')
%p.lead= t('.help.licencia') %p.lead= t('.help.licencia')
- Licencia.all.find_each do |licencia| - Licencia.all.find_each do |licencia|
- next if licencia.custom? && site.licencia != licencia
.row.license .row.license
.col .col
.media.mt-1 .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_en: 'Peer Production License'
name_es: 'Licencia de Producción de Pares' name_es: 'Licencia de Producción de Pares'
short_description_en: "This work is licensed under a Peer Production License" short_description_en: "This work is licensed under a Peer Production License"