Skip to content

Commit

Permalink
Comienza a agregar pais al filtro avanzado. #552
Browse files Browse the repository at this point in the history
  • Loading branch information
vtamara committed Sep 27, 2023
1 parent a36b4af commit fb08acc
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GIT

GIT
remote: https://gitlab.com/pasosdeJesus/msip.git
revision: 1123a67dd42a76f95a1b3c3de4c3f5c105c7609c
revision: be0055f20ad5e8dcc2fa638ce6738f93536031b5
branch: main
specs:
msip (2.2.0.beta4)
Expand Down Expand Up @@ -356,7 +356,7 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-minitest (0.32.1)
rubocop-minitest (0.32.2)
rubocop (>= 1.39, < 2.0)
rubocop-rails (2.21.1)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -489,4 +489,4 @@ DEPENDENCIES
will_paginate

BUNDLED WITH
2.4.19
2.4.20
24 changes: 12 additions & 12 deletions app/views/sivel2_gen/casos/_filtro_avanzado.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
<div class="offset-sm-0 col-sm-2 offset-md-1 col-md-1">
Ubicación
</div>
<div class="offset-sm-0 col-sm-2 col-md-2">
<%= f.input :pais_id,
collection: Msip::ModeloHelper.opciones_tabla_basica(
Msip::Pais, f, :pais_id
),
label_method: :nombre,
value_method: :id,
selected: [Msip.paisomision],
label: false,
include_blank: "-- Pais"
%>
</div>
<div class="offset-sm-0 col-sm-3 col-md-3">
<%= f.input :departamento_id,
collection: Msip::ModeloHelper.opciones_tabla_basica(
Expand All @@ -36,18 +48,6 @@
input_html: {disabled: :disabled }
%>
</div>
<div class="col-md-2">
<%= f.input :clase_id,
collection: Msip::ModeloHelper.opciones_tabla_basica(
Msip::Clase, f, :clase_id
),
label_method: :nombre,
value_method: :id,
label: false,
include_blank: "-- Clase",
input_html: {disabled: :disabled }
%>
</div>
<div class="offset-sm-0 col-sm-1 text-center">
<%= f.input :inc_ubicaciones,
as: :boolean,
Expand Down
104 changes: 103 additions & 1 deletion test/dummy/db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,58 @@ CREATE FUNCTION public.first_element_state(anyarray, anyelement) RETURNS anyarra
$_$;


--
-- Name: msip_agregar_o_remplazar_familiar_inverso(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.msip_agregar_o_remplazar_familiar_inverso() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
num2 INTEGER;
rinv CHAR(2);
rexistente CHAR(2);
BEGIN
ASSERT(TG_OP = 'INSERT' OR TG_OP = 'UPDATE');
RAISE NOTICE 'Insertando o actualizando en msip_persona_trelacion';
RAISE NOTICE 'TG_OP = %', TG_OP;
RAISE NOTICE 'NEW.id = %', NEW.id;
RAISE NOTICE 'NEW.persona1 = %', NEW.persona1;
RAISE NOTICE 'NEW.persona2 = %', NEW.persona2;
RAISE NOTICE 'NEW.trelacion_id = %', NEW.trelacion_id;
RAISE NOTICE 'NEW.observaciones = %', NEW.observaciones;

SELECT COUNT(*) INTO num2 FROM msip_persona_trelacion
WHERE persona1 = NEW.persona2 AND persona2=NEW.persona1;
RAISE NOTICE 'num2 = %', num2;
ASSERT(num2 < 2);
SELECT inverso INTO rinv FROM msip_trelacion
WHERE id = NEW.trelacion_id;
RAISE NOTICE 'rinv = %', rinv;
ASSERT(rinv IS NOT NULL);
CASE num2
WHEN 0 THEN
INSERT INTO msip_persona_trelacion
(persona1, persona2, trelacion_id, observaciones, created_at, updated_at)
VALUES (NEW.persona2, NEW.persona1, rinv, 'Inverso agregado automaticamente', NOW(), NOW());
ELSE -- num2 = 1
SELECT trelacion_id INTO rexistente FROM msip_persona_trelacion
WHERE persona1=NEW.persona2 AND persona2=NEW.persona1;
RAISE NOTICE 'rexistente = %', rexistente;
IF rinv <> rexistente THEN
UPDATE msip_persona_trelacion
SET trelacion_id = rinv,
observaciones = 'Inverso cambiado automaticamente (era ' ||
rexistente || '). ' || COALESCE(observaciones, ''),
updated_at = NOW()
WHERE persona1=NEW.persona2 AND persona2=NEW.persona1;
END IF;
END CASE;
RETURN NULL;
END ;
$$;


--
-- Name: msip_edad_de_fechanac_fecharef(integer, integer, integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: -
--
Expand Down Expand Up @@ -181,6 +233,31 @@ CREATE FUNCTION public.msip_edad_de_fechanac_fecharef(anionac integer, mesnac in
$$;


--
-- Name: msip_eliminar_familiar_inverso(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.msip_eliminar_familiar_inverso() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
num2 INTEGER;
BEGIN
ASSERT(TG_OP = 'DELETE');
RAISE NOTICE 'Eliminando inverso de msip_persona_trelacion';
SELECT COUNT(*) INTO num2 FROM msip_persona_trelacion
WHERE persona1 = OLD.persona2 AND persona2=OLD.persona1;
RAISE NOTICE 'num2 = %', num2;
ASSERT(num2 < 2);
IF num2 = 1 THEN
DELETE FROM msip_persona_trelacion
WHERE persona1 = OLD.persona2 AND persona2 = OLD.persona1;
END IF;
RETURN NULL;
END ;
$$;


--
-- Name: probapellido(text); Type: FUNCTION; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2593,6 +2670,15 @@ CREATE MATERIALIZED VIEW public.nmujeres AS
WITH NO DATA;


--
-- Name: num2; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.num2 (
count bigint
);


--
-- Name: persona_nomap; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--
Expand Down Expand Up @@ -5779,6 +5865,20 @@ CREATE INDEX sivel2_gen_victima_orientacionsexual ON public.sivel2_gen_victima U
CREATE UNIQUE INDEX usuario_nusuario ON public.usuario USING btree (nusuario);


--
-- Name: msip_persona_trelacion msip_eliminar_familiar; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER msip_eliminar_familiar AFTER DELETE ON public.msip_persona_trelacion FOR EACH ROW EXECUTE FUNCTION public.msip_eliminar_familiar_inverso();


--
-- Name: msip_persona_trelacion msip_insertar_familiar; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER msip_insertar_familiar AFTER INSERT OR UPDATE ON public.msip_persona_trelacion FOR EACH ROW EXECUTE FUNCTION public.msip_agregar_o_remplazar_familiar_inverso();


--
-- Name: sivel2_gen_supracategoria $1; Type: FK CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -7643,10 +7743,12 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230504084246'),
('20230526153207'),
('20230613111532'),
('20230616203948'),
('20230622205529'),
('20230622205530'),
('20230712163859'),
('20230722180204'),
('20230723011110');
('20230723011110'),
('20230927001422');


0 comments on commit fb08acc

Please sign in to comment.