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

fixup! feat: cuando se modifica la licencia, considerarla personalizada

This commit is contained in:
f 2023-04-03 17:50:04 -03:00
parent b7a27a87dd
commit 94d30ac12a
5 changed files with 16 additions and 8 deletions

View file

@ -19,6 +19,6 @@ class Licencia < ApplicationRecord
validates :deed, presence: true validates :deed, presence: true
def custom? def custom?
url == 'custom' icons == 'custom'
end end
end end

View file

@ -145,8 +145,8 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
# Si les usuaries modifican o crean una licencia, considerarla # Si les usuaries modifican o crean una licencia, considerarla
# personalizada en el panel. # personalizada en el panel.
def update_site_license! def update_site_license!
if site.usuarie?(usuarie) && post.layout.name == :license if site.usuarie?(usuarie) && post.layout.name == :license && !site.licencia.custom?
site.update licencia: Licencia.find_by_url('custom') site.update licencia: Licencia.find_by_icons('custom')
end end
end end
end end

View file

@ -110,6 +110,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
# @return [Boolean] # @return [Boolean]
def add_licencias def add_licencias
return true unless site.layout? :license return true unless site.layout? :license
return true if site.licencia.custom?
with_all_locales do |locale| with_all_locales do |locale|
add_licencia lang: locale add_licencia lang: locale
@ -140,6 +141,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
# @return [Boolean] # @return [Boolean]
def change_licencias def change_licencias
return true unless site.layout? :license return true unless site.layout? :license
return true if site.licencia.custom?
with_all_locales do |locale| with_all_locales do |locale|
post = site.posts(lang: locale).find_by(layout: 'license') post = site.posts(lang: locale).find_by(layout: 'license')

View file

@ -83,6 +83,7 @@
.row.license .row.license
.col .col
.media.mt-1 .media.mt-1
- unless licencia.custom?
= image_tag licencia.icons, alt: licencia.name, class: 'mr-3 mt-4' = image_tag licencia.icons, alt: licencia.name, class: 'mr-3 mt-4'
.media-body .media-body
.custom-control.custom-radio .custom-control.custom-radio
@ -94,8 +95,8 @@
= sanitize_markdown licencia.description, = sanitize_markdown licencia.description,
tags: %w[p a strong em ul ol li h1 h2 h3 h4 h5 h6] tags: %w[p a strong em ul ol li h1 h2 h3 h4 h5 h6]
= link_to t('.licencia.url'), licencia.url, - unless licencia.custom?
target: '_blank', class: 'btn' = link_to t('.licencia.url'), licencia.url, target: '_blank', class: 'btn', rel: 'noopener'
%hr/ %hr/

View file

@ -1,10 +1,15 @@
--- ---
- name_en: "Custom license" - name_en: "Custom license"
name_es: "Licencia personalizada" name_es: "Licencia personalizada"
url_en: "custom" url_en: ""
url_es: "custom" url_es: ""
icons: "custom"
short_description_en: ""
short_description_es: ""
description_en: "The license terms are provided by you." description_en: "The license terms are provided by you."
description_es: "Los términos de la licencia fueron provistos por vos." description_es: "Los términos de la licencia fueron provistos por vos."
deed_en: ""
deed_es: ""
- 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"