Skip to content

Commit

Permalink
Boton de copiar actividad de msip. Ver https://gitlab.com/pasosdeJesu…
Browse files Browse the repository at this point in the history
  • Loading branch information
vtamara committed Mar 27, 2024
1 parent d5f65f7 commit 98013d1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.

This file was deleted.

5 changes: 0 additions & 5 deletions app/views/cor1440_gen/actividades/_show_mas_acciones.html.erb

This file was deleted.

6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

Cor1440Gen::Engine.routes.draw do
get "/actividad/copia/:actividad_id" =>
"actividades#copia",
as: :copia_actividad
get "/actividad/copiar/:id" =>
"actividades#copiar",
as: :copiar_actividad

# Poner antes de resources :actividads
get "/actividades/contar" => "actividades#contar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def atributos_show
]
end

def con_boton_copiar?
true
end

def vistas_manejadas
["Actividad"]
end
Expand Down
28 changes: 28 additions & 0 deletions lib/cor1440_gen/concerns/models/actividad.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,34 @@ def asistentes_con_buena_edad
end
end


# Usada por Msip::Modelo.copiar_y_guardar
def excepciones_al_copiar_asociaciones
[
:actividad_anexo,
:respuestafor,
]
end

# Usada por Msip::Modelo.copiar_y_guardar
def copiar_especifico(registro)
# De manera especial copiamos respuestafor asociado
arfs = Cor1440Gen::ActividadRespuestafor.where(actividad_id: self.id)
arfs.each do |arf|
nr = arf.respuestafor.dup
nr.save(validate: false)
narf = arf.dup
narf.respuestafor_id = nr.id
narf.actividad_id = registro.id
narf.save(validate: false)
arf.respuestafor.valorcampo.each do |v|
nv = v.dup
nv.respuestafor_id = nr.id
nv.save(validate: false)
end
end
end #copiar_especifico

def recalcula_poblacion
ConteosHelper.recalcula_poblacion(self)
end
Expand Down

0 comments on commit 98013d1

Please sign in to comment.