WIP: licencias

This commit is contained in:
f 2019-07-19 19:37:53 -03:00
parent 1cc4c4de64
commit 1dd8c73991
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
13 changed files with 383 additions and 3 deletions

View file

@ -137,6 +137,6 @@ class SitesController < ApplicationController
private
def site_params
params.require(:site).permit(:name, :design_id)
params.require(:site).permit(:name, :design_id, :licencia_id)
end
end

18
app/models/licencia.rb Normal file
View file

@ -0,0 +1,18 @@
# frozen_string_literal: true
# Las licencias son completamente traducibles
class Licencia < ApplicationRecord
extend Mobility
translates :name, type: :string, locale_accessors: true
translates :url, type: :string, locale_accessors: true
translates :description, type: :text, locale_accessors: true
translates :deed, type: :text, locale_accessors: true
has_many :sites
validates :name, presence: true, uniqueness: true
validates :url, presence: true
validates :description, presence: true
validates :deed, presence: true
end

View file

@ -11,6 +11,7 @@ class Site < ApplicationRecord
friendly_id :name, use: %i[finders]
belongs_to :design
belongs_to :licencia
has_many :roles
has_many :usuaries, -> { where('roles.rol = ?', 'usuarie') },

View file

@ -7,6 +7,8 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.singular 'invitades', 'invitade'
inflect.plural 'usuarie', 'usuaries'
inflect.singular 'usuaries', 'usuarie'
inflect.plural 'licencia', 'licencias'
inflect.singular 'licencias', 'licencia'
inflect.plural 'rol', 'roles'
inflect.singular 'roles', 'rol'
end
@ -20,4 +22,6 @@ ActiveSupport::Inflector.inflections(:es) do |inflect|
inflect.singular 'usuaries', 'usuarie'
inflect.plural 'rol', 'roles'
inflect.singular 'roles', 'rol'
inflect.plural 'licencia', 'licencias'
inflect.singular 'licencias', 'licencia'
end

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
# Crea la tabla de licencias
class CreateLicencias < ActiveRecord::Migration[5.2]
def change
create_table :licencias do |t|
t.timestamps
t.string :name, unique: true
t.text :description
t.text :deed
t.string :url
end
add_belongs_to :sites, :licencia, index: true
end
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
# Agrega íconos a las licencias
class AddIconsToLicenses < ActiveRecord::Migration[5.2]
def change
# XXX: Cambiar por ActiveStorage?
add_column :licencias, :icons, :string
end
end

View file

@ -12,7 +12,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20_190_717_214_308) do
ActiveRecord::Schema.define(version: 20_190_719_221_653) do
create_table 'designs', force: :cascade do |t|
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
@ -24,6 +24,16 @@ ActiveRecord::Schema.define(version: 20_190_717_214_308) do
t.boolean 'disabled', default: false
end
create_table 'licencias', force: :cascade do |t|
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.string 'name'
t.text 'description'
t.text 'deed'
t.string 'url'
t.string 'icons'
end
create_table 'mobility_string_translations', force: :cascade do |t|
t.string 'locale', null: false
t.string 'key', null: false
@ -66,7 +76,9 @@ ActiveRecord::Schema.define(version: 20_190_717_214_308) do
t.datetime 'updated_at', null: false
t.string 'name'
t.integer 'design_id'
t.integer 'licencia_id'
t.index ['design_id'], name: 'index_sites_on_design_id'
t.index ['licencia_id'], name: 'index_sites_on_licencia_id'
t.index ['name'], name: 'index_sites_on_name', unique: true
end

View file

@ -7,3 +7,11 @@ designs.each do |d|
design.update_attributes d
end
licencias = YAML.safe_load(File.read('db/seeds/licencias.yml'))
licencias.each do |l|
licencia = Licencia.find_or_create_by(icons: l['icons'])
licencia.update_attributes l
end

290
db/seeds/licencias.yml Normal file
View file

@ -0,0 +1,290 @@
---
- name_en: 'Peer Production License'
name_es: 'Licencia de Producción de Pares'
icons: "/public/ppl.png"
url_en: 'https://wiki.p2pfoundation.net/Peer_Production_License'
url_es: 'https://endefensadelsl.org/ppl_es.html'
description_en: 'The Peer Production License is a license that allows use for any purpose under the same terms, except for commercial purposes, which are only allowed for collectives, cooperatives and other worker-owned "enterprises". We recommend this license if you are inclined towards non-profit terms, since it allows the development of more ethical economies while fending off capitalistic for-profit uses. If you want to know more about it, we invite you to read [The Telekommunist Manifesto](http://networkcultures.org/blog/publication/no-03-the-telekommunist-manifesto-dmytri-kleiner/)'
description_es: 'La licencia de Producción de Pares permite el uso con cualquier propósito bajo la misma licencia, a excepción de los usos comerciales que solo están permitidos a colectivos, cooperativas y otras "empresas" en manos de sus trabajadorxs. Recomendamos esta licencia si te estabas inclinando hacia términos sin fines de lucro, ya que permite el desarrollo de economías más éticas al mismo tiempo que impide la explotación capitalista. Si te interesa saber más, te invitamos a leer [El manifiesto telecomunista](https://endefensadelsl.org/manifiesto_telecomunista.html).'
deed_en: |
# Peer Production License (human-readable version)
This is a human-readable summary of the [full
license](https://wiki.p2pfoundation.net/Peer_Production_License).
## You are free to
* **Share** -- copy and redistribute the material in any medium or
format
* **Adapt** -- remix, transform, and build upon the material
## Under the following terms:
* **Attribution** -- You must give appropriate credit, provide a link
to the license, and indicate if changes were made. You may do so in
any reasonable manner, but not in any way that suggests the licensor
endorses you or your use.
* **ShareAlike** -- If you remix, transform, or build upon the
material, you must distribute your contributions under the same
license as the original.
* **Non-Capitalist** -- Commercial exploitation of this work is only
allowed to cooperatives, non-profit organizations and collectives,
worker-owned organizations, and any organization without exploitation
relations. Any surplus value obtained by the exercise of the rights
given by this work's license must be distributed by and amongst
workers.'
## Notices:
* You do not have to comply with the license for elements of the
material in the public domain or where your use is permitted by an
applicable exception or limitation.
* No warranties are given. The license may not give you all of the
permissions necessary for your intended use. For example, other rights
such as publicity, privacy, or moral rights may limit how you use the
material.
deed_es: |
# Licencia de producción de pares (versión legible por humanas)
Esto es un resumen legible por humanas del [texto legal (la licencia
completa)](http://endefensadelsl.org/ppl_es.html)
## Ud. es libre de
* Compartir - copiar, distribuir, ejecutar y comunicar públicamente la obra
* Hacer obras derivadas
## Bajo las condiciones siguientes:
* Atribución - Debe reconocer los créditos de la obra de la manera
especificada por el autor o el licenciante (pero no de una manera que
sugiera que tiene su apoyo o que apoyan el uso que hace de su obra).
* Compartir bajo la Misma Licencia - Si altera o transforma esta obra,
o genera una obra derivada, sólo puede distribuir la obra generada
bajo una licencia idéntica a ésta.
* No Capitalista - La explotación comercial de esta obra sólo está
permitida a cooperativas, organizaciones y colectivos sin fines de
lucro, a organizaciones de trabajadores autogestionados, y donde no
existan relaciones de explotación. Todo excedente o plusvalía
obtenidos por el ejercicio de los derechos concedidos por esta
Licencia sobre la Obra deben ser distribuidos por y entre los
trabajadores.
## Entendiendo que
* Renuncia - Alguna de estas condiciones puede no aplicarse si se
obtiene el permiso del titular de los derechos de autor.
* Dominio Público - Cuando la obra o alguno de sus elementos se halle
en el dominio público según la ley vigente aplicable, esta situación
no quedará afectada por la licencia.
* Otros derechos - Los derechos siguientes no quedan afectados por la
licencia de ninguna manera:
* Los derechos derivados de usos legítimos u otras limitaciones
reconocidas por ley no se ven afectados por lo anterior;
* Los derechos morales del autor;
* Derechos que pueden ostentar otras personas sobre la propia obra o
su uso, como por ejemplo derechos de imagen o de privacidad.
* Aviso - Al reutilizar o distribuir la obra, tiene que dejar muy en
claro los términos de la licencia de esta obra. La mejor forma de
hacerlo es enlazar a esta página.
- icons: "/public/by.png"
name_en: 'Attribution 4.0 International (CC BY 4.0)'
description_en: "This license gives everyone the freedom to use,
adapt, and redistribute the contents of your site by requiring
attribution only. We recommend this license if you're publishing
articles that require maximum diffusion, even in commercial media, but
you want to be attributed. Users of the site will have to mention the
source and indicate if they made changes to it."
url_en: 'https://creativecommons.org/licenses/by/4.0/'
name_es: 'Atribución 4.0 Internacional (CC BY 4.0)'
description_es: "Esta licencia permite a todes la libertad de usar,
adaptar/modificar y redistribuir los contenidos de tu sitio con la
única condición de atribuirte la autoría original. Recomendamos esta
licencia si vas a publicar artículos que requieran máxima difusión,
incluso en medios comerciales, pero querés que te atribuyan el
trabajo. Les usuaries de este sitio deberán mencionar la fuente e
indicar si hicieron cambios."
url_es: 'https://creativecommons.org/licenses/by/4.0/deed.es'
deed_en: |
This is a human-readable summary of (and not a substitute for) the
[license](https://creativecommons.org/licenses/by/4.0/legalcode).
# You are free to:
* **Share** -- copy and redistribute the material in any medium or
format
* **Adapt** -- remix, transform, and build upon the material for any
purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the
license terms.
# Under the following terms:
* **Attribution** -- You must give appropriate credit, provide a link to
the license, and indicate if changes were made. You may do so in any
reasonable manner, but not in any way that suggests the licensor
endorses you or your use.
* **No additional restrictions** -- You may not apply legal terms or
technological measures that legally restrict others from doing
anything the license permits.
# Notices:
You do not have to comply with the license for elements of the material
in the public domain or where your use is permitted by an applicable
exception or limitation.
No warranties are given. The license may not give you all of the
permissions necessary for your intended use. For example, other rights
such as publicity, privacy, or moral rights may limit how you use the
material.
deed_es: |
Este es un resumen legible por humanes (y no un sustituto) de la
[licencia](https://creativecommons.org/licenses/by/4.0/legalcode).
# Usted es libre de:
* **Compartir** -- copiar y redistribuir el material en cualquier medio o
formato.
* **Adaptar** -- remezclar, transformar y construir a partir del material
para cualquier propósito, incluso comercialmente.
La licenciante no puede revocar estas libertades en tanto usted siga los
términos de la licencia.
# Bajo los siguientes términos:
* **Atribución** -- Usted debe dar crédito de manera adecuada, brindar
un enlace a la licencia, e indicar si se han realizado cambios. Puede
hacerlo en cualquier forma razonable, pero no de forma tal que sugiera
que usted o su uso tienen el apoyo de la licenciante.
* **No hay restricciones adicionales** -- No puede aplicar términos
legales ni medidas tecnológicas que restrinjan legalmente a otras a
hacer cualquier uso permitido por la licencia.
# Avisos:
No tiene que cumplir con la licencia para elementos del materiale en el
dominio público o cuando su uso esté permitido por una excepción o
limitación aplicable.
No se dan garantías. La licencia podría no darle todos los permisos que
necesita para el uso que tenga previsto. Por ejemplo, otros derechos como
publicidad, privacidad, o derechos morales pueden limitar la forma en que
utilice el material.
- icons: "/public/bysa.png"
name_en: "Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)"
name_es: "Atribución-CompartirIgual 4.0 Internacional (CC BY-SA 4.0)"
url_en: 'https://creativecommons.org/licenses/by-sa/4.0/'
url_es: 'https://creativecommons.org/licenses/by-sa/4.0/deed.es'
description_en: "This license is the same as the CC-BY 4.0 but it adds
a requirement of sharing the work and its derivatives under the same
license. This is a reciprocitary, _copyleft_, license that keeps
culture free. Though commercial uses are allowed, they must be shared
under the same license, so any modifications done for profit are free
as well."
description_es: "Esta licencia es igual que la CC-BY 4.0 con el
requisito agregado de compartir la obra y sus obras derivadas con la
misma licencia. Esta es una licencia reciprocitaria, _copyleft_, que
mantiene y profundiza la cultura libre. Aunque los usos comerciales
están permitidos, las mejoras hechas con fines de lucro deben ser
compartidas bajo la misma licencia."
deed_en: |
This is a human-readable summary of (and not a substitute for) the
[license](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
# You are free to:
* **Share** -- copy and redistribute the material in any medium or
format
* **Adapt** -- remix, transform, and build upon the material for any
purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the
license terms.
# Under the following terms:
* **Attribution** -- You must give appropriate credit, provide a link to
the license, and indicate if changes were made. You may do so in any
reasonable manner, but not in any way that suggests the licensor
endorses you or your use.
* **ShareAlike** -- If you remix, transform, or build upon the
material, you must distribute your contributions under the same
license as the original.
* **No additional restrictions** -- You may not apply legal terms or
technological measures that legally restrict others from doing
anything the license permits.
# Notices:
You do not have to comply with the license for elements of the material
in the public domain or where your use is permitted by an applicable
exception or limitation.
No warranties are given. The license may not give you all of the
permissions necessary for your intended use. For example, other rights
such as publicity, privacy, or moral rights may limit how you use the
material.
deed_es: |
Este es un resumen legible por humanes (y no un sustituto) de la
[licencia](https://creativecommons.org/licenses/by/4.0/legalcode).
# Usted es libre de:
* **Compartir** -- copiar y redistribuir el material en cualquier medio o
formato.
* **Adaptar** -- remezclar, transformar y construir a partir del material
para cualquier propósito, incluso comercialmente.
La licenciante no puede revocar estas libertades en tanto usted siga los
términos de la licencia.
# Bajo los siguientes términos:
* **Atribución** -- Usted debe dar crédito de manera adecuada, brindar
un enlace a la licencia, e indicar si se han realizado cambios. Puede
hacerlo en cualquier forma razonable, pero no de forma tal que sugiera
que usted o su uso tienen el apoyo de la licenciante.
* **CompartirIgual** -- Si remezcla, transforma o crea a partir del
material, debe distribuir su contribución bajo la lamisma licencia del
original.
* **No hay restricciones adicionales** -- No puede aplicar términos
legales ni medidas tecnológicas que restrinjan legalmente a otras a
hacer cualquier uso permitido por la licencia.
# Avisos:
No tiene que cumplir con la licencia para elementos del materiale en el
dominio público o cuando su uso esté permitido por una excepción o
limitación aplicable.
No se dan garantías. La licencia podría no darle todos los permisos que
necesita para el uso que tenga previsto. Por ejemplo, otros derechos como
publicidad, privacidad, o derechos morales pueden limitar la forma en que
utilice el material.

View file

@ -34,7 +34,8 @@ class SitesControllerTest < ActionDispatch::IntegrationTest
post sites_url, headers: @authorization, params: {
site: {
name: name,
design_id: create(:design).id
design_id: create(:design).id,
licencia_id: create(:licencia).id
}
}

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
FactoryBot.define do
factory :licencia do
name { SecureRandom.hex }
description { SecureRandom.hex }
url { SecureRandom.hex }
deed { SecureRandom.hex }
icons { SecureRandom.hex }
end
end

View file

@ -4,5 +4,6 @@ FactoryBot.define do
factory :site do
name { "test-#{SecureRandom.hex}" }
design
licencia
end
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
class LicenciaTest < ActiveSupport::TestCase
test 'se pueden crear' do
licencia = build :licencia
assert licencia.valid?
end
end