commit inicial
|
@ -0,0 +1,11 @@
|
||||||
|
# carpeta de dependencias
|
||||||
|
/dependencias
|
||||||
|
|
||||||
|
# ignorar respaldos de base de datos
|
||||||
|
*.sql.gz
|
||||||
|
|
||||||
|
db.sqlite3
|
||||||
|
.env
|
||||||
|
.vscode
|
||||||
|
__pycache__
|
||||||
|
migrations
|
|
@ -0,0 +1,517 @@
|
||||||
|
/* AREA DE DESARROLLO */
|
||||||
|
CREATE SCHEMA desarrollo1;
|
||||||
|
SET SEARCH_PATH TO desarrollo1;
|
||||||
|
|
||||||
|
/* REQUERIDO PARA TIPO GEOMETRY */
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: APLICACION */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists APLICACION (
|
||||||
|
ID_APLICACION INT4 not null,
|
||||||
|
NOMBRE_APP varchar(100) null,
|
||||||
|
VIGENTE BOOL null,
|
||||||
|
constraint PK_APLICACION primary key (ID_APLICACION)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: COMUNA */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists COMUNA (
|
||||||
|
ID_COMUNA INT4 not null,
|
||||||
|
ID_REGION INT4 null,
|
||||||
|
NOMBRE_COMUNA varchar(100) null,
|
||||||
|
constraint PK_COMUNA primary key (ID_COMUNA)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: CONDUCTOR */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists CONDUCTOR (
|
||||||
|
PATENTE VARCHAR(10) null,
|
||||||
|
RUT NUMERIC(12) null,
|
||||||
|
VIGENTE BOOL null
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: DISPOSITIVO */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists DISPOSITIVO (
|
||||||
|
ID_DISPOSITIVO INT4 not null,
|
||||||
|
ID_PARADERO INT4 null,
|
||||||
|
VIGENTE BOOL null,
|
||||||
|
ULTIMA_CONEXION DATE null,
|
||||||
|
constraint PK_DISPOSITIVO primary key (ID_DISPOSITIVO)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: FUNCIONARIO */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists FUNCIONARIO (
|
||||||
|
RUT NUMERIC(12) null,
|
||||||
|
ID_OPERADOR INT4 null,
|
||||||
|
DESDE DATE null,
|
||||||
|
HASTA DATE null
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: GTFS_CALENDAR */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists GTFS_CALENDAR (
|
||||||
|
ID_LINEA INT4 not null,
|
||||||
|
MONDAY BOOL null,
|
||||||
|
TUESDAY BOOL null,
|
||||||
|
WEDNESDAY BOOL null,
|
||||||
|
THURSDAY BOOL null,
|
||||||
|
FRIDAY BOOL null,
|
||||||
|
SALURDAY BOOL null,
|
||||||
|
SUNDAY BOOL null,
|
||||||
|
constraint PK_GTFS_CALENDAR primary key (ID_LINEA)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: GTFS_FREQUENCIE */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists GTFS_FREQUENCIE (
|
||||||
|
ID_TRIPS INT4 null,
|
||||||
|
START_TIME TIME null,
|
||||||
|
END_TIME TIME null,
|
||||||
|
HEADWAY_SECS int null,
|
||||||
|
EXACT_TIME int null
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Index: INDEX_FREQUENCIE */
|
||||||
|
/*==============================================================*/
|
||||||
|
create index INDEX_FREQUENCIE on GTFS_FREQUENCIE (
|
||||||
|
ID_TRIPS
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: GTFS_ROUTES */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists GTFS_ROUTES (
|
||||||
|
ID_ROUTES INT4 not null,
|
||||||
|
ID_OPERADOR INT4 null,
|
||||||
|
ID_ROUTE_TYPE int null,
|
||||||
|
SHORT_NAME varchar(100) null,
|
||||||
|
LONG_NAME varchar(300) null,
|
||||||
|
DESCRIPCION varchar(500) null,
|
||||||
|
ROUTE_COLOR VARCHAR(6) null,
|
||||||
|
ROUTE_TEXT_COLOR VARCHAR(6) null,
|
||||||
|
ROUTE_SORT_ORDER int null,
|
||||||
|
constraint PK_GTFS_ROUTES primary key (ID_ROUTES)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: GTFS_ROUTE_TYPE */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists GTFS_ROUTE_TYPE (
|
||||||
|
ID_ROUTE_TYPE int not null,
|
||||||
|
DESCRIPCION varchar(100) null,
|
||||||
|
constraint PK_GTFS_ROUTE_TYPE primary key (ID_ROUTE_TYPE)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: GTFS_SHAPE */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists GTFS_SHAPE (
|
||||||
|
ID_SHAPES INT4 not null,
|
||||||
|
SHAPE_PT_LAT geometry null,
|
||||||
|
SHAPE_PT_LON geometry null,
|
||||||
|
SHAPE_PT_SEQUENCE int null,
|
||||||
|
SHAOE_DIST_TRAVELED float null,
|
||||||
|
constraint PK_GTFS_SHAPE primary key (ID_SHAPES)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: GTFS_STOP_TIMES */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists GTFS_STOP_TIMES (
|
||||||
|
ID_PARADERO INT4 not null,
|
||||||
|
ID_TRIPS INT4 not null,
|
||||||
|
ARRIVAL_TIME TIME null,
|
||||||
|
STOP_SEQUENCE int null,
|
||||||
|
STOP_HEADSIGN varchar(100) null,
|
||||||
|
constraint PK_GTFS_STOP_TIMES primary key (ID_PARADERO, ID_TRIPS)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: GTFS_TRIPS */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists GTFS_TRIPS (
|
||||||
|
ID_TRIPS INT4 not null,
|
||||||
|
ID_ROUTES INT4 null,
|
||||||
|
ID_LINEA INT4 null,
|
||||||
|
ID_SHAPES INT4 null,
|
||||||
|
ID_TRIPS_REGRESO INT4 null,
|
||||||
|
TRIP_HEADSIGN varchar(100) null,
|
||||||
|
SHORT_NAME varchar(100) null,
|
||||||
|
DIRECCION_ID int null,
|
||||||
|
constraint PK_GTFS_TRIPS primary key (ID_TRIPS)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: LINEA */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists LINEA (
|
||||||
|
ID_LINEA INT4 not null,
|
||||||
|
ID_OPERADOR INT4 null,
|
||||||
|
IID_TIPO_TRANSPORTE INT4 null,
|
||||||
|
ID_REGION INT4 null,
|
||||||
|
VIGENTE BOOL null,
|
||||||
|
NOMBRE VARCHAR(100) null,
|
||||||
|
URL varchar(300) null,
|
||||||
|
constraint PK_LINEA primary key (ID_LINEA)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: OPERADOR */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists OPERADOR (
|
||||||
|
ID_OPERADOR INT4 not null,
|
||||||
|
ID_REGION INT4 null,
|
||||||
|
VIGENTE BOOL null,
|
||||||
|
constraint PK_OPERADOR primary key (ID_OPERADOR)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: PARADERO */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists PARADERO (
|
||||||
|
ID_PARADERO INT4 not null,
|
||||||
|
ID_COMUNA INT4 null,
|
||||||
|
ID_TIPO_PARADERO INT4 null,
|
||||||
|
VIGENTE BOOL null,
|
||||||
|
STOP_CODE varchar(100) null,
|
||||||
|
STOP_NAME varchar(100) null,
|
||||||
|
STOP_DESC varchar(300) null,
|
||||||
|
STOP_LAT geometry null,
|
||||||
|
STOP_LON geometry null,
|
||||||
|
constraint PK_PARADERO primary key (ID_PARADERO)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: PARADERO_IMAGEN */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists PARADERO_IMAGEN (
|
||||||
|
ID_PARADERO INT4 not null,
|
||||||
|
IMAGEN BYTEA null,
|
||||||
|
constraint PK_PARADERO_IMAGEN primary key (ID_PARADERO)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: PERSONA */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists PERSONA (
|
||||||
|
RUT NUMERIC(12) not null,
|
||||||
|
ID_TIPO_TRATAMIENTO INT4 null,
|
||||||
|
ID_COMUNA INT4 null,
|
||||||
|
DV CHAR(1) null,
|
||||||
|
NOMBRES VARCHAR(100) null,
|
||||||
|
APELLIDO_A VARCHAR(100) null,
|
||||||
|
APELLIDO_B VARCHAR(100) null,
|
||||||
|
FONO VARCHAR(100) null,
|
||||||
|
EMAIL VARCHAR(100) null,
|
||||||
|
FECHA_NACIMIENTO DATE null,
|
||||||
|
DIRECCION VARCHAR(100) null,
|
||||||
|
constraint PK_PERSONA primary key (RUT)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: REGION */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists REGION (
|
||||||
|
ID_REGION INT4 not null,
|
||||||
|
NOMBRE_REGION VARCHAR(100) not null,
|
||||||
|
constraint PK_REGION primary key (ID_REGION)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: ROL */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists ROL (
|
||||||
|
ID_ROL INT4 not null,
|
||||||
|
NOMBRE_ROL varchar(100) not null,
|
||||||
|
constraint PK_ROL primary key (ID_ROL)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: ROL_APLICACION */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists ROL_APLICACION (
|
||||||
|
ID_APLICACION INT4 not null,
|
||||||
|
ID_ROL INT4 not null,
|
||||||
|
SOLO_VISUALIZAR BOOL null,
|
||||||
|
ID_ROL_APP SERIAL4 not null,
|
||||||
|
CONSTRAINT rol_aplicacion_pk PRIMARY KEY (ID_ROL_APP)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX rol_aplicacion_id_aplicacion_idx ON ROL_APLICACION USING btree (ID_APLICACION, ID_ROL);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: TIPO_DISPOSITIVO */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists TIPO_DISPOSITIVO (
|
||||||
|
ID_DISPOSITIVO INT4 null,
|
||||||
|
ID_TIPO_DISPOSITIVO INT4 null
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: TIPO_PARADERO */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists TIPO_PARADERO (
|
||||||
|
ID_TIPO_PARADERO INT4 not null,
|
||||||
|
DESCRIPCION VARCHAR(100) null,
|
||||||
|
constraint PK_TIPO_PARADERO primary key (ID_TIPO_PARADERO)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: TIPO_TRANSPORTE */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists TIPO_TRANSPORTE (
|
||||||
|
IID_TIPO_TRANSPORTE INT4 not null,
|
||||||
|
DESCRIPCION VARCHAR(50) null,
|
||||||
|
constraint PK_TIPO_TRANSPORTE primary key (IID_TIPO_TRANSPORTE)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: TIPO_TRATAMIENTO_PERSONA */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists TIPO_TRATAMIENTO_PERSONA (
|
||||||
|
ID_TIPO_TRATAMIENTO INT4 not null,
|
||||||
|
TRATAMIENTO varchar(50) null,
|
||||||
|
constraint PK_TIPO_TRATAMIENTO_PERSONA primary key (ID_TIPO_TRATAMIENTO)
|
||||||
|
);
|
||||||
|
|
||||||
|
comment on table TIPO_TRATAMIENTO_PERSONA is
|
||||||
|
'Establece el tratamiento de como dirigirse hacia una persona:
|
||||||
|
Ejemplo
|
||||||
|
Señor
|
||||||
|
Señora
|
||||||
|
Srta';
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: TIPO_VEHICULO */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists TIPO_VEHICULO (
|
||||||
|
ID_TIPO_VEHICULO int not null,
|
||||||
|
DESCRIPCION varchar(100) null,
|
||||||
|
constraint PK_TIPO_VEHICULO primary key (ID_TIPO_VEHICULO)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: USUARIO */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists USUARIO (
|
||||||
|
LOGIN VARCHAR(20) not null,
|
||||||
|
RUT NUMERIC(12) null,
|
||||||
|
CLAVE VARCHAR(20) null,
|
||||||
|
VIGENTE bool null,
|
||||||
|
constraint PK_USUARIO primary key (LOGIN)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: USUARIO_ROL */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists USUARIO_ROL (
|
||||||
|
LOGIN VARCHAR(20) null,
|
||||||
|
ID_ROL INT4 null,
|
||||||
|
VIGENTE BOOL null
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: VEHICULO */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists VEHICULO (
|
||||||
|
PPU VARCHAR(10) not null,
|
||||||
|
ID_TIPO_VEHICULO int null,
|
||||||
|
VIGENTE BOOL null,
|
||||||
|
constraint PK_VEHICULO primary key (PPU)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* Table: VEHICULO_LINEA */
|
||||||
|
/*==============================================================*/
|
||||||
|
create table if not exists VEHICULO_LINEA (
|
||||||
|
PATENTE VARCHAR(10) null,
|
||||||
|
ID_LINEA INT4 null,
|
||||||
|
VIGENTE BOOL null
|
||||||
|
);
|
||||||
|
|
||||||
|
/*==============================================================*/
|
||||||
|
/* View: VW_PARADERO_LINEA */
|
||||||
|
/*==============================================================*/
|
||||||
|
create or replace view VW_PARADERO_LINEA as
|
||||||
|
select;
|
||||||
|
|
||||||
|
alter table COMUNA
|
||||||
|
add constraint FK_COMUNA_REFERENCE_REGION foreign key (ID_REGION)
|
||||||
|
references REGION (ID_REGION)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table CONDUCTOR
|
||||||
|
add constraint FK_CONDUCTO_REFERENCE_VEHICULO foreign key (PATENTE)
|
||||||
|
references VEHICULO (PPU)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table CONDUCTOR
|
||||||
|
add constraint FK_CONDUCTO_REFERENCE_PERSONA foreign key (RUT)
|
||||||
|
references PERSONA (RUT)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table DISPOSITIVO
|
||||||
|
add constraint FK_DISPOSIT_REFERENCE_PARADERO foreign key (ID_PARADERO)
|
||||||
|
references PARADERO (ID_PARADERO)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table FUNCIONARIO
|
||||||
|
add constraint FK_FUNCIONA_REFERENCE_PERSONA foreign key (RUT)
|
||||||
|
references PERSONA (RUT)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table FUNCIONARIO
|
||||||
|
add constraint FK_FUNCIONA_REFERENCE_OPERADOR foreign key (ID_OPERADOR)
|
||||||
|
references OPERADOR (ID_OPERADOR)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_CALENDAR
|
||||||
|
add constraint FK_GTFS_CAL_REFERENCE_LINEA foreign key (ID_LINEA)
|
||||||
|
references LINEA (ID_LINEA)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_FREQUENCIE
|
||||||
|
add constraint FK_GTFS_FRE_REFERENCE_GTFS_TRI foreign key (ID_TRIPS)
|
||||||
|
references GTFS_TRIPS (ID_TRIPS)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_ROUTES
|
||||||
|
add constraint FK_GTFS_ROU_REFERENCE_OPERADOR foreign key (ID_OPERADOR)
|
||||||
|
references OPERADOR (ID_OPERADOR)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_ROUTES
|
||||||
|
add constraint FK_GTFS_ROU_REFERENCE_GTFS_ROU foreign key (ID_ROUTE_TYPE)
|
||||||
|
references GTFS_ROUTE_TYPE (ID_ROUTE_TYPE)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_STOP_TIMES
|
||||||
|
add constraint FK_GTFS_STO_REFERENCE_PARADERO foreign key (ID_PARADERO)
|
||||||
|
references PARADERO (ID_PARADERO)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_STOP_TIMES
|
||||||
|
add constraint FK_GTFS_STO_REFERENCE_GTFS_TRI foreign key (ID_TRIPS)
|
||||||
|
references GTFS_TRIPS (ID_TRIPS)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_TRIPS
|
||||||
|
add constraint FK_GTFS_TRI_REFERENCE_GTFS_ROU foreign key (ID_ROUTES)
|
||||||
|
references GTFS_ROUTES (ID_ROUTES)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_TRIPS
|
||||||
|
add constraint FK_GTFS_TRI_REFERENCE_LINEA foreign key (ID_LINEA)
|
||||||
|
references LINEA (ID_LINEA)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_TRIPS
|
||||||
|
add constraint FK_GTFS_TRI_REFERENCE_GTFS_SHA foreign key (ID_SHAPES)
|
||||||
|
references GTFS_SHAPE (ID_SHAPES)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table GTFS_TRIPS
|
||||||
|
add constraint FK_GTFS_TRI_REFERENCE_GTFS_TRI foreign key (ID_TRIPS_REGRESO)
|
||||||
|
references GTFS_TRIPS (ID_TRIPS)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table LINEA
|
||||||
|
add constraint FK_LINEA_REFERENCE_OPERADOR foreign key (ID_OPERADOR)
|
||||||
|
references OPERADOR (ID_OPERADOR)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table LINEA
|
||||||
|
add constraint FK_LINEA_REFERENCE_TIPO_TRA foreign key (IID_TIPO_TRANSPORTE)
|
||||||
|
references TIPO_TRANSPORTE (IID_TIPO_TRANSPORTE)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table LINEA
|
||||||
|
add constraint FK_LINEA_REFERENCE_REGION foreign key (ID_REGION)
|
||||||
|
references REGION (ID_REGION)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table OPERADOR
|
||||||
|
add constraint FK_OPERADOR_REFERENCE_REGION foreign key (ID_REGION)
|
||||||
|
references REGION (ID_REGION)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table PARADERO
|
||||||
|
add constraint FK_PARADERO_REFERENCE_COMUNA foreign key (ID_COMUNA)
|
||||||
|
references COMUNA (ID_COMUNA)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table PARADERO
|
||||||
|
add constraint FK_PARADERO_REFERENCE_TIPO_PAR foreign key (ID_TIPO_PARADERO)
|
||||||
|
references TIPO_PARADERO (ID_TIPO_PARADERO)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table PARADERO_IMAGEN
|
||||||
|
add constraint FK_PARADERO_REFERENCE_PARADERO foreign key (ID_PARADERO)
|
||||||
|
references PARADERO (ID_PARADERO)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table PERSONA
|
||||||
|
add constraint FK_PERSONA_REFERENCE_COMUNA foreign key (ID_COMUNA)
|
||||||
|
references COMUNA (ID_COMUNA)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table PERSONA
|
||||||
|
add constraint FK_PERSONA_REFERENCE_TIPO_TRA foreign key (ID_TIPO_TRATAMIENTO)
|
||||||
|
references TIPO_TRATAMIENTO_PERSONA (ID_TIPO_TRATAMIENTO)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table ROL_APLICACION
|
||||||
|
add constraint FK_ROL_APLI_REFERENCE_APLICACI foreign key (ID_APLICACION)
|
||||||
|
references APLICACION (ID_APLICACION)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table ROL_APLICACION
|
||||||
|
add constraint FK_ROL_APLI_REFERENCE_ROL foreign key (ID_ROL)
|
||||||
|
references ROL (ID_ROL)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table TIPO_DISPOSITIVO
|
||||||
|
add constraint FK_TIPO_DIS_REFERENCE_DISPOSIT foreign key (ID_DISPOSITIVO)
|
||||||
|
references DISPOSITIVO (ID_DISPOSITIVO)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table USUARIO
|
||||||
|
add constraint FK_USUARIO_REFERENCE_PERSONA foreign key (RUT)
|
||||||
|
references PERSONA (RUT)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table USUARIO_ROL
|
||||||
|
add constraint FK_USUARIO__REFERENCE_USUARIO foreign key (LOGIN)
|
||||||
|
references USUARIO (LOGIN)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table USUARIO_ROL
|
||||||
|
add constraint FK_USUARIO__REFERENCE_ROL foreign key (ID_ROL)
|
||||||
|
references ROL (ID_ROL)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table VEHICULO
|
||||||
|
add constraint FK_VEHICULO_REFERENCE_TIPO_VEH foreign key (ID_TIPO_VEHICULO)
|
||||||
|
references TIPO_VEHICULO (ID_TIPO_VEHICULO)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table VEHICULO_LINEA
|
||||||
|
add constraint FK_VEHICULO_REFERENCE_VEHICULO foreign key (PATENTE)
|
||||||
|
references VEHICULO (PPU)
|
||||||
|
on delete restrict on update restrict;
|
||||||
|
|
||||||
|
alter table VEHICULO_LINEA
|
||||||
|
add constraint FK_VEHICULO_REFERENCE_LINEA foreign key (ID_LINEA)
|
||||||
|
references LINEA (ID_LINEA)
|
||||||
|
on delete restrict on update restrict;
|
|
@ -0,0 +1,70 @@
|
||||||
|
version: "3"
|
||||||
|
name: transporte
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
app:
|
||||||
|
image: python:3.11-alpine
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
environment:
|
||||||
|
- PORT=4000
|
||||||
|
- DBHOST=db
|
||||||
|
- DBPORT=5432
|
||||||
|
- DBNAME=database
|
||||||
|
- DBSCHEMA=desarrollo1
|
||||||
|
- DBUSER=postgres
|
||||||
|
- DBPASS=password
|
||||||
|
- SECRET_JWT="kf6Jc!f30Z!1k1N0#!%#"
|
||||||
|
ports:
|
||||||
|
- 4000:4000
|
||||||
|
volumes:
|
||||||
|
- ../:/app
|
||||||
|
- venv:/root/venv
|
||||||
|
working_dir: /app
|
||||||
|
command: sh -c "
|
||||||
|
[ -d /root/venv/bin ] || ( \
|
||||||
|
python -m venv /root/venv/ \
|
||||||
|
&& . /root/venv/bin/activate \
|
||||||
|
&& pip install -r requirements.txt \
|
||||||
|
) ;
|
||||||
|
|
||||||
|
. /root/venv/bin/activate ;
|
||||||
|
|
||||||
|
cd /app ;
|
||||||
|
[ -d project ] || django-admin startproject project ;
|
||||||
|
[ -f .env ] || ( [ -f .env.develop ] && cp .env.develop .env ) ;
|
||||||
|
chmod -R o+w project/ ;
|
||||||
|
python project/manage.py runserver 0.0.0.0:$$PORT
|
||||||
|
"
|
||||||
|
|
||||||
|
# REF: https://github.com/postgis/docker-postgis/tree/master/14-3.3
|
||||||
|
db:
|
||||||
|
image: postgres:14-alpine-geometry
|
||||||
|
build:
|
||||||
|
context: ./postgres-geometry
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
volumes:
|
||||||
|
- db:/var/lib/postgresql/data
|
||||||
|
- ./backups:/docker-entrypoint-initdb.d
|
||||||
|
#- ./01_create_tables.sql:/docker-entrypoint-initdb.d/01_create_tables.sql
|
||||||
|
ports:
|
||||||
|
- 5436:5432
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: password
|
||||||
|
POSTGRES_DB: database
|
||||||
|
PGDATA: /var/lib/postgresql/data/pgdata
|
||||||
|
|
||||||
|
adminer:
|
||||||
|
image: adminer
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
environment:
|
||||||
|
ADMINER_DEFAULT_SERVER: db
|
||||||
|
ADMINER_DEFAULT_USER: postgres
|
||||||
|
ADMINER_DEFAULT_PASSWORD: password
|
||||||
|
ADMINER_DESIGN: lucas-sandery
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db:
|
||||||
|
venv:
|
|
@ -0,0 +1,129 @@
|
||||||
|
FROM postgres:14-alpine3.15
|
||||||
|
|
||||||
|
LABEL maintainer="PostGIS Project - https://postgis.net"
|
||||||
|
|
||||||
|
ENV POSTGIS_VERSION 3.2.1
|
||||||
|
ENV POSTGIS_SHA256 1e9cc4c4f390e4c3be4f5c125a72f39dfa847412332952429952cbd731ac9ba3
|
||||||
|
|
||||||
|
RUN set -eux \
|
||||||
|
\
|
||||||
|
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
|
||||||
|
set -eux ; \
|
||||||
|
#
|
||||||
|
# using only v3.15
|
||||||
|
#
|
||||||
|
#GEOS: https://pkgs.alpinelinux.org/packages?name=geos&branch=v3.15 \
|
||||||
|
export GEOS_ALPINE_VER=3.10 ; \
|
||||||
|
#GDAL: https://pkgs.alpinelinux.org/packages?name=gdal&branch=v3.15 \
|
||||||
|
export GDAL_ALPINE_VER=3.4 ; \
|
||||||
|
#PROJ: https://pkgs.alpinelinux.org/packages?name=proj&branch=v3.15 \
|
||||||
|
export PROJ_ALPINE_VER=8.2 ; \
|
||||||
|
#
|
||||||
|
elif [ $(printf %.1s "$POSTGIS_VERSION") == 2 ]; then \
|
||||||
|
set -eux ; \
|
||||||
|
#
|
||||||
|
# using older branches v3.13; v3.14 for GEOS,GDAL,PROJ
|
||||||
|
#
|
||||||
|
#GEOS: https://pkgs.alpinelinux.org/packages?name=geos&branch=v3.13 \
|
||||||
|
export GEOS_ALPINE_VER=3.8 ; \
|
||||||
|
#GDAL: https://pkgs.alpinelinux.org/packages?name=gdal&branch=v3.14 \
|
||||||
|
export GDAL_ALPINE_VER=3.2 ; \
|
||||||
|
#PROJ: https://pkgs.alpinelinux.org/packages?name=proj&branch=v3.14 \
|
||||||
|
export PROJ_ALPINE_VER=7.2 ; \
|
||||||
|
#
|
||||||
|
\
|
||||||
|
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.14/main' >> /etc/apk/repositories ; \
|
||||||
|
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.14/community' >> /etc/apk/repositories ; \
|
||||||
|
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> /etc/apk/repositories ; \
|
||||||
|
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.13/community' >> /etc/apk/repositories ; \
|
||||||
|
\
|
||||||
|
else \
|
||||||
|
set -eux ; \
|
||||||
|
echo ".... unknown \$POSTGIS_VERSION ...." ; \
|
||||||
|
exit 1 ; \
|
||||||
|
fi \
|
||||||
|
\
|
||||||
|
&& apk add --no-cache --virtual .fetch-deps \
|
||||||
|
ca-certificates \
|
||||||
|
openssl \
|
||||||
|
tar \
|
||||||
|
\
|
||||||
|
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
|
||||||
|
&& echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \
|
||||||
|
&& mkdir -p /usr/src/postgis \
|
||||||
|
&& tar \
|
||||||
|
--extract \
|
||||||
|
--file postgis.tar.gz \
|
||||||
|
--directory /usr/src/postgis \
|
||||||
|
--strip-components 1 \
|
||||||
|
&& rm postgis.tar.gz \
|
||||||
|
\
|
||||||
|
&& apk add --no-cache --virtual .build-deps \
|
||||||
|
\
|
||||||
|
gdal-dev~=${GDAL_ALPINE_VER} \
|
||||||
|
geos-dev~=${GEOS_ALPINE_VER} \
|
||||||
|
proj-dev~=${PROJ_ALPINE_VER} \
|
||||||
|
\
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
clang-dev \
|
||||||
|
file \
|
||||||
|
g++ \
|
||||||
|
gcc \
|
||||||
|
gettext-dev \
|
||||||
|
json-c-dev \
|
||||||
|
libtool \
|
||||||
|
libxml2-dev \
|
||||||
|
llvm-dev \
|
||||||
|
make \
|
||||||
|
pcre-dev \
|
||||||
|
perl \
|
||||||
|
protobuf-c-dev \
|
||||||
|
\
|
||||||
|
# build PostGIS
|
||||||
|
\
|
||||||
|
&& cd /usr/src/postgis \
|
||||||
|
&& gettextize \
|
||||||
|
&& ./autogen.sh \
|
||||||
|
&& ./configure \
|
||||||
|
--with-pcredir="$(pcre-config --prefix)" \
|
||||||
|
&& make -j$(nproc) \
|
||||||
|
&& make install \
|
||||||
|
\
|
||||||
|
# regress check
|
||||||
|
&& mkdir /tempdb \
|
||||||
|
&& chown -R postgres:postgres /tempdb \
|
||||||
|
&& su postgres -c 'pg_ctl -D /tempdb init' \
|
||||||
|
&& su postgres -c 'pg_ctl -D /tempdb start' \
|
||||||
|
&& cd regress \
|
||||||
|
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
|
||||||
|
#&& make -j$(nproc) check RUNTESTFLAGS=--dumprestore PGUSER=postgres \
|
||||||
|
#&& make garden PGUSER=postgres \
|
||||||
|
\
|
||||||
|
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \
|
||||||
|
&& su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \
|
||||||
|
&& su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \
|
||||||
|
\
|
||||||
|
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \
|
||||||
|
&& rm -rf /tempdb \
|
||||||
|
&& rm -rf /tmp/pgis_reg \
|
||||||
|
# add .postgis-rundeps
|
||||||
|
&& apk add --no-cache --virtual .postgis-rundeps \
|
||||||
|
\
|
||||||
|
gdal~=${GDAL_ALPINE_VER} \
|
||||||
|
geos~=${GEOS_ALPINE_VER} \
|
||||||
|
proj~=${PROJ_ALPINE_VER} \
|
||||||
|
\
|
||||||
|
json-c \
|
||||||
|
libstdc++ \
|
||||||
|
pcre \
|
||||||
|
protobuf-c \
|
||||||
|
# clean
|
||||||
|
&& cd / \
|
||||||
|
&& rm -rf /usr/src/postgis \
|
||||||
|
&& apk del .fetch-deps .build-deps \
|
||||||
|
# print PostGIS_Full_Version() for the log. ( experimental & internal )
|
||||||
|
&& cat /_pgis_full_version.txt
|
||||||
|
|
||||||
|
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
|
||||||
|
COPY ./update-postgis.sh /usr/local/bin
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Perform all actions as $POSTGRES_USER
|
||||||
|
export PGUSER="$POSTGRES_USER"
|
||||||
|
|
||||||
|
# Create the 'template_postgis' template db
|
||||||
|
"${psql[@]}" <<- 'EOSQL'
|
||||||
|
CREATE DATABASE template_postgis IS_TEMPLATE true;
|
||||||
|
EOSQL
|
||||||
|
|
||||||
|
# Load PostGIS into both template_database and $POSTGRES_DB
|
||||||
|
for DB in template_postgis "$POSTGRES_DB"; do
|
||||||
|
echo "Loading PostGIS extensions into $DB"
|
||||||
|
"${psql[@]}" --dbname="$DB" <<-'EOSQL'
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;
|
||||||
|
EOSQL
|
||||||
|
done
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Perform all actions as $POSTGRES_USER
|
||||||
|
export PGUSER="$POSTGRES_USER"
|
||||||
|
|
||||||
|
POSTGIS_VERSION="${POSTGIS_VERSION%%+*}"
|
||||||
|
|
||||||
|
# Load PostGIS into both template_database and $POSTGRES_DB
|
||||||
|
for DB in template_postgis "$POSTGRES_DB" "${@}"; do
|
||||||
|
echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION"
|
||||||
|
psql --dbname="$DB" -c "
|
||||||
|
-- Upgrade PostGIS (includes raster)
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION';
|
||||||
|
ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION';
|
||||||
|
|
||||||
|
-- Upgrade Topology
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION';
|
||||||
|
ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION';
|
||||||
|
|
||||||
|
-- Install Tiger dependencies in case not already installed
|
||||||
|
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
|
||||||
|
-- Upgrade US Tiger Geocoder
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION';
|
||||||
|
ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION';
|
||||||
|
"
|
||||||
|
done
|
|
@ -0,0 +1,212 @@
|
||||||
|
"codigo";"texto1";"texto2";"texto3";"texto4";"bgcolor1";"color1";"bgcolor2";"color2"
|
||||||
|
"02D";"San Vicente - Puerto";"Colón - Av. Grecia";"Cerro Amarillo";"Diego Portales";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"02D";"San Vicente - Puerto";"Colón - Av. Grecia";"Cerro Amarillo";"02K";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"02K";"Puerto - Thno";"San Vicente";"Nueva Los Lobos";"Los Copihues";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"02K";"Puerto - Thno";"San Vicente";"Nueva Los Lobos";"02A";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"02A";"Colón - Puerto";"San Vicente";"Nueva Los Lobos";"Centinela";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"02A";"Colón - Puerto";"San Vicente";"Nueva Los Lobos";"02P";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"02P";"San Vicente";"Puerto - Colón";"Lan C - Floresta";"Peñuelas";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"02P";"San Vicente";"Puerto - Colón";"Lan C - Floresta";"02C";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"02C";"Arenal Cementerio 2";"Hospital Higueras";"Colón ";"Peñuelas";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"02C";"Arenal Cementerio 2";"Hospital Higueras";"Colón ";"02L";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"02L";"Arenal Cementerio 2";"Hospital Higueras";"Colón ";"Diego Portales";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"02L";"Arenal Cementerio 2";"Hospital Higueras";"Colón ";"10D";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"10D";"San Martin";"Mall - Autopista";"Puente de Arco";"Las Canchas";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10A";"8 Oriente - San Martín";"Mall - Autopista";"Thno - San Vicente";"CENTINELA";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10A";"8 Oriente - San Martín";"Mall - Autopista";"Thno - San Vicente";"10B";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"10B";"San Martín";"Mall-Autopista";"Thno-S.Vicente";"Lobos Viejos";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10B";"San Martín";"Mall-Autopista";"Thno-S.Vicente";"10C";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"10C";"8 Oriente - San Martín";"Mall - Autopista";"Thno - S.Vicente";"LAS CANCHAS";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10C";"8 Oriente - San Martín";"Mall - Autopista";"Thno - S.Vicente";"10M";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"10M";"Autopista - Mall";"Concep. - Chigte.";"8 Oriente";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10O";"Bilbao - Autopista";"Mall - Concep.";"Chigte - O'higgins";"POBL. PORVENIR";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10P";"Autopista-Mall";"Concep- - Chigte";"8 Oriente";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10J";"8 Oriente - San Martín";"Autopista - Thno.";"Avda. Del Pescador";"CENTINELA";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10L";"Avda Del Pescador";"Mall - Chigte";"8 Oriente";"Los Bloques";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10N";"Autopista - Mall";"Concep. - Chigte";"8 Oriente";"LOS BLOQUES";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10T";"8 Oriente - San Martín";"Autopista - mall";"Thno - Las Canchas";"TUMBES";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"10K";"Las Canchas - Thno";"Mall - Autopista";"8 Oriente - Chigte";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"11E";"8 Oriente - San Martín";"Autopista - Mall";"J. Repullo - Sta. Marta";"TALCAHUANO";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"11F";"San Martín";"Mall- Autopista";"Higueras-Bilbao";"Talcahuano";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"11Q";"Santa Marta - Mall";"Autopista - O´Higgins";"8 Oriente - Chigte";"Los Bloques";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"11R";"Bilbao-Hosp. Higueras";"Autopista-Mall";"O´Higgins-Chigte";"PORVENIR";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"11C";"8 Oriente - San Martín";"Autopista - Mall";"Repullo - San Marcos";"TALCAHUANO";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"11M";"San Marcos - J. Repullo";"Mall - O´Higgins";"8 Oriente - Chigte";"LOS BLOQUES";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"12Q";"Prat-Vega";"Club Hípico";"Industrias";"Puerto";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"12R";"Prat-Vega";"Boldos-Bremen";"Industrias";"Puerto";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"12A";"Club Hípico";"Vega-Prat";"Chiguayante";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"12B";"Bremen-Boldos";"Vega-Prat";"Chiguayante";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"13G";"8 Oriente - S. Martin";"Mall - Trébol - Autopista";"Directo - Thno";"PTA. LEONES";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"13S";"Autopista - Mall";"Tribunales - P. Vald";"8 Oriente - Chgte";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"14H";"San Martín";"Mall-Autopista";"Directo-Thno";"San Vicente";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"14Z";"San Martín - Hospital";"Plaza Acevedo";"A Las Puertas";"Term.Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"14T";"Autopista-Mall";"O'Higgins-Tribunales";" 8 Oriente - Los Altos - Chgte";"Coquimbo";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"14U";"O´Higgins";"Tribunales - P. Valdivia";"Chgte - O´Higgins - Los Altos";"Policlinico - Coquimbo";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"16I";"8 Oriente - San Martín";"Mall-Autopista";"Santa Marta - Consultorio";"San Vicente";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"16V";"Santa Marta - Consultorio";"Mall - O´Higgins";"8 Oriente - Chiguayante";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"16H";"8 Oriente - San Martín";"Mall-Autopista";"S. Marcos - Consultorio";"San Vicente";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"16K";"M. Montt - Consultorio";"San Marcos - Mall - Paicavi ";"O'Higgins - 8 Oriente";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"17A";"Centro - O´Higgins";"P. Valdivia - Prat - Carrera";"Pza. Acevedo - Penco Chico";"Cº Verde Bajo";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"17O";"Centro - 8 Oriente";"San Martín - Hospital";"Pza. Acevedo - Collao - UBB";"NONGUEN";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"17M";"Centro - O´Higgins";"P. Valdivia - Prat - Carrera";"Pza. Acevedo - Fanaloza";"MONTAHUE - PENCO";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"17W";"Centro - O´Higgins";"P.De Valdivia - Chgte";"Pob. Porvenir";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"17X";"Centro - O´Higgins";"P. Valdivia - 8 Oriente";"Chgte. - Pob. Porvenir";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"17C";"Montahue - Centro";"O´Higgins - P. De valdivia";"Chgte - Porvenir";"LEONERA";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"18P";"San Martín";"Hospital";"Collao-UBB";"Palomares";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"18Y";"O´Higgins- Centro";"P.Devaldivia";"Chiguayante";"Hualqui";"rgb(204,138,0)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"20V";"Puente Llacolén";"Los Carrera - Mall";"Autopista-Thno";"Pta. Los Leones";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"20J";"Puente Llacolén";"San Martín";"Mall - Autopista";"Pta. Los Leones";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"20A";"Autopista-Mall";"O´Higgins";"Puente Llacolén";"Boca Sur";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"20L";"Autopista-Mall";"Los Carrera";"Puente Llacolén";"Boca Sur";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"20Z";"Pioneros- P Llacolén";"Los Carreras";"Mall- Autopista";"Pta. Los Leones";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"20W";"Autopista - Mall";"Av. Los Carrera";"Pte Llacolén- Pioneros";"San Pedro De La Costa";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"20T";"O'carrol - Pioneros";"Pte. Llacolén - Av. Los Carrera";"Mall - Autopista";"Pta. Los Leones";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"20M";"Autopista - Mall";"O""Higgins - Pte Llacolén";"Pioneros - O'carrol";"San Pedro De La Costa";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"21Q";"Puente Llacolén";"San Martín";"Hospital-Puertas";"Term. Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"21B";"Centro-O´Higgins";"Puente Llacolén";"Spring Hill";"Candelaria";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22D";"O´Higgins";"Puente Llacolén";"Boca Sur";"Michaihue";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22K";"Puente Llacolén";"Los Carrera - Collao";"Ubb-Nonguen";"Araucana";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22R";"Puente Llacolén";"San Martín";"Hospital-Collao";"U.Bio Bio";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22S";"Puente Llacolén";"S.Martín-Collao";"Ubb - Nonguén";"Araucana";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22X";"Puente Llacolén";"San Martín";"Hospital";"Galvarino";"rgb(198,0,126)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22J";"Pioneros - P.Llacolén";"San Martín";"Gral Novoa - Los Lirios";"Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22C";"O´Higgins";"Puente Llacolén";"P.Aguirre Cerda";"Lomas - Coloane";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22N";"Los Carrera";"Puente Llacolén";"Boca Sur";"Michaihue";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22E";"O´Higgins";"Puente Llacolén";"Fuera De La Villa";"Candelaria";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"22O";"Los Carrera";"Pte. Llacolén";"Los Pioneros";"San Pedro De La Costa";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23L";"Puente Llacolén";"Los Carrera";"Collao-UBB";"Nonguen";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23E";"Sta.Beatriz - Pioneros";"Pte. Llacolén";"Los Carrera";"PTA. TERMINAL COLLAO";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23V";"Los Carrera";"Pte. Llacolén";"Pioneros - Sta.Beatriz";"MICHAIHUE";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23A";"Puente Nuevo";"Vega-Maipú";"Hosp. Trabajador";"Term. Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23P";"Los Carrera";"Puente Llacolén";"Boca Sur";"Michaihue";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23Q";"Carrera-Vega";"Candelaria";"Boca Sur";"Michaihue";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"23N";"Los Pioneros";"Pte. Llacolén";"Los Carrera";"Pta. Terminal Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23T";"Los Carrera";"Pte. Llacolén";"Los Pioneros";"San Pedro De La Costa";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23B";"Sta. Beatriz-Verluys";"Pte. Llacolén";"Los Carrera";"Pta. Terminal Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23S";"Los Carrera-Pte.Llacolén";"V. Victoria-Sta. Beatriz";"V. San Sebastián";"Av. Michaihue";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23C";"S. Henríquez-Escritores";"Sn. Pedro Viejo - Pte. Bicent";"Mall Biobío - Los Carrera";"Pta. Terminal Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"23H";"Los Carrera-Mall Biobío";"Pte. Bicent.- S. Pedro Viejo";"Outlet Mall - Los Escritores";"Silva Henríquez";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"24M";"Villa- P.Llacolén";"Los Carrera";"Collao-Los Lirios";"Los Fresnos";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"24T";"Villa-P.Llacolén";"San Martín";"Collao - Los Lirios";"Los Fresnos";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"24F";"O´Higgins";"Puente Llacolén";"Por Villa S.Pedro";"Candelaria";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"24R";"Los Carrera";"Puente Llacolén";"Por Villa S.Pedro";"Candelaria";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"30M";"Freire - Vega";"Bremen - Hualpén";"Lan B - Higueras";"INDUSTRIAS";"rgb(155,39,67)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"30N";"Penco Chico";"Freire - Lan B";"Bremen - Hualpén";"INDUSTRIAS";"rgb(155,39,67)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"30R";"O´Higgins- Prat";"Vega - Colón";"V.San Martín";"Higueras";"rgb(155,39,67)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"30Q";"O´Higgins- Vega";"Mall- Autopista";"V. San Martín";"Higueras";"rgb(155,39,67)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"30B";"Colón -Vega";"Los Carrera";"Plaza Acevedo";"Penco Lirquen";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"30C";"Autopista- Mall";"Freire- Centro";"Prat- Carrera";"Penco Lirquen";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"30D";"Hualpén";"Vega - Carrera";"Penco - Lirquén";"RIOS DE CHILE";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"30E";"Hualpén";"Vega - Prat";"Carrera - Lirquén";"PENCO CHICO";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"31D";"O´Higgins-Prat";"Vga- Colón";"Talcahuano";"Lobos Viejos";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"31F";"Colón- Vega";"Prat -Carrera";"Penco";"Lirquen";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"32G";"Colón -Vega";"Prat- Carrera";"Penco- Lirquén";"Rios De Chile";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"32E";"O'higgins - Prat";"Vega - Colon";"Talcahuano";"Lobos Viejos";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"32K";" Hospital Higueras";" Colón - Vega";" Montahue - Lirquén";"RIOS DE CHILE";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"32J";"Lirquén - Montahue";"O'Higgins - Vega";"Hospital Higueras";"LOBOS VIEJOS";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"40G";"Autopista- Mall";"O´Higgins";"Puente Llacolén";"Candelaria";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"40B";"Vega- Maipú";"P.Acevedo- Ubb";"Araucana- Valle";"Nonguen";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"40N";"San Martín";"Autopista -Mall";"Lan C- Bremen";"4 Esquinas";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"40P";"Freire- Prat";"Vega- Lan C";"Bremen -Cañería";"4 Esquinas";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"41Q";"Autopista- Mall";"Paicaví -Freire";"Prat- Lider";"Concepción";"rgb(198,0,126)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"41C";"Vega- Prat";"Maipú -Paicaví";"Hospital -Puertas";"Term. Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"41V";"Prat -Maipú";"Mall - Autopista";"Lan C - P.Aylwin";"Hualpencillo";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"41R";"Centro - Freire";"Vega- Lan B";"Los Boldos";"Hualpencillo";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"42U";"C.Hípico - Vega";"San Martín";"Hospital -Puertas";"Term. Collao";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"42F";"Club Hípico";"Autopista - Mall";"O´Higgins- Prat";"Concepción";"rgb(198,0,126)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"42H";"Centro -Freire";"Vega - C.Hipico";"Finlandia";"Hualpen - 4 Esq";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"42W";"Prat - Maipú";"Mall -Autopista";"Club Hípico";"Hualpen - 4 Esq";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"43T";"O´Higgins";"Tucapel - Freire";"Vega -Bremen";"Hualpencillo";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"43J";"Vega - Maipú";"Janequeo";"C.Henriquez";"Sta. Sabina";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"44E";"Heras-Rengo";"Chacab.- C.Henríq.";"V.Cap.-Torreones";"Lomas-Mall";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"44U";"Torreones-Freire";"Vega-Ramuntcho";"Grecia- D.Portales";"Hualpencillo";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"44A";"Heras-Rengo";"Chacabuco ";"C.Henruq.-V.Cap.";"Lomas-Mall";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"44B";"Freire-Vega";"Ramuntcho";"Grecia- D.Portales";"Hualpencillo";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"50S";"Autopista- Mall";"O´Higgins";"Prat- Vega";"Concepción";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"50U";"Vega -Mall";"Denavi Sur - Bosque";"V.S Martín- Estadio";"Higueras - Gaete";"rgb(155,39,67)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"52A";"Freire -Prat";"Vega -Colón";"Talcahuano";"Pta. Leones";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"52D";"Colón - Vega";"Prat -Maipú";"Collao -UBB";"Palomares";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"56O";"O´Higgins";"Vega - Colón";"Talcahuano";"Pta. Los Leones";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"56V";"Colón - Vega";"San Martín";"Los Lirios - Los Fresnos";"T. Collao - Hospital";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"57Y";"Autopista - Mall";"Paicaví";"O'higgins - Prat";"CONCEPCIÓN";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"57P";"O'higgins - Prat";"Vega - Colón";"Hosp. Higueras";"SAN VICENTE";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"60X";"Paicaví - Freire";"Prat - Vega";"Lan C - Grecia";"Hualpencillo";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"60Y";"Freire - Vega";"Lan C - Grecia";"Consultorio";"Padre Hurtado";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"60Z";"V.Cap - Ejército";"A.Pinto - Freire";"Lider Prat";"P. Valdivia";"rgb(137,141,141)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"60K";"Maipú - Paicaví";"Bº Norte - Santa Sabina";"Princesas - Lomas";"Sta. Sabina";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"60L";"Maipú - Paicaví";"Bº Norte - Princesas";"Portal - Lomas";"Sta. Sabina";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"60M";"Maipú -Tucapel";"Ventus - T. Merino";"B. Modelo - S. Sabina";"Consultorio Sta Sabina";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"62H";"Higueras -Colón";"Vega - Los Carrera";"Penco- C Verde";"Lirquen";"rgb(0,140,149)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"62M";"O´Higgins -Prat";"Vega -Higueras";"Hospital";"SAN VICENTE";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"62O";"Higueras -Colón";"Vega -Maipú";"C.Henriquez";"Villa Cap";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"62N";"O´Higgins- Prat";"Vega -Higueras";"Hospital";"SAN VICENTE";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"62V";"Higueras - St. Marta";"Vega -Maipú";"C.Henriquez";"Villa Cap";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"62S";"O´Higgins- Prat";"Vega - St. Marta";"Hospital - Higueras";"SAN VICENTE";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"63I";"Rengo - Centro";"Puente Llacolén";"San Pedro Viejo";"Recodo";"rgb(0,119,73)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"63K";"C.Henriquez";"Freire -Prat";"Cementerio";"J.Pablo II";"rgb(255,199,44)";"rgb(0,0,0)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"63F";"Rengo - Centro";"Chacabuco - Hospital";" C. Henríquez";"CHILLANCITO";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"63G";"Puente Llacolén";"Lincoyán";"Ejército";"B.Norte";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"63P";"Prat -Maipú";"C.Henriquez";"Villa Cap";"B. Norte";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"63H";"Chacabuco";"Hospital - Lincoyán";"Ejército";"B. NORTE";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"63L";"Rengo - Chacabuco";"Hospital - C.Henríquez";"Andalién - Bellavista";"San Sebastián";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"63B";"Andalién - C. Henríquez";"Hospital - Chacabuco";"Lincoyán - Ejército";"Barrio Norte";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"65Q";"P.del Río - Maipú";"P. Acevedo";"V. Cap - T. Merino";"STA. SABINA";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"65R";"Prat - Maipú";"Pelantaro - C. Henriquez";"V.Cap - Campos Bellavista";"Sta. Sabina";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"65D";"P. Acevedo - Freire";"P. del Río";"Cementerio - Vega";"P.SAAVEDRA.";"rgb(255,199,44)";"rgb(0,0,0)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"65E";"Freire -Prat";"Vega- Los Boldos";"Floresta - P. Hurtado";"Peñuelas";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"65S";"Costanera - Maipú";"Pelantaro - C.Henríquez";"V. Cap - Torreones";"STA. SABINA";"rgb(45,41,38)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"65F";"C.Henríquez-Lientur";"Freire-Costanera";"Directo Easy Jumbo";"ALTO COSTANERA";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"70I";"O´Higgins -Vega";"Colón -Thno";"P.Arco -N.Lobos";"Centinela";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"70J";"O´Higgins - Vega";"Colón - Talcahuano";"Pte. Arco - N. Los Lobos";"Los Copihues";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"70K";"O´Higgins -Vega";"Mall -Autopista";"Thno -Pte .Arco";"Los Copihues";"rgb(203,51,59)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"70H";"Autopista -Mall";"Carrera -Serrano";"Maipú - Collao";"Va.Nonguen";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"70F";"Colon - Vega";"Maipú - Collao";"Ubb - Valle";"Nonguen";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"70G";"Colón - Vega";"Maipú - Collao";"UBB - Palomares";"Km10";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"71I";"Vega -Maipú";"Plaza Acevedo";"Ubb- Zoológico";"V. Nonguen";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"71Z";"Freire -Prat";"Hualpencillo";"Bremen- Cañeria";"4 Esquinas - Lenga";"rgb(236,105,7)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"72J";"O´Higgins";"P.De Valdivia";"Clínicas";"Lonco";"rgb(137,141,141)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"72K";"O´Higgins";"Pedro De Valdivia";"Clinicas";"Lonco";"rgb(137,141,141)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"72W";"San Martín";"Hospital - Collao";"U.B.B. - Valle";"NONGUÉN";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"72Z";"San Martín";"Hospital - Collao";"U.B.B.";"VALLE NOBLE";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"80K";"San Martín";"Mall -Autopista";"Talcahuano";"San Vicente";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"80L";"San Martín";"Mall -Autopista";"Talcahuano";"San Vicente";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"80H";"Autopista- Mall";"O´Higgins";"Chiguayante";"Hualqui";"rgb(204,138,0)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"80Z";"Autopista- Mall";"O´Higgins";"Chiguayante";"Valle Piedra";"rgb(0,119,200)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"80J";"Santa Josefina";"San Martin - Mall";"Autopista - Thno";"San Vicente";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"80Q";"Autopista- Mall";"O'higgins - Chgte";"Santa Josefina";"Hualqui";"rgb(204,138,0)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"81C";"Industrias -Lan C";"Vega -Prat";"Chiguayante";"Hualqui";"rgb(204,138,0)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"81S";"Prat -Vega";"Hualpencillo";"Lan C- Industrias";"Puerto";"rgb(16,6,159)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"90E";"Alemparte- Maipú";"A Las Puertas";"Terminal Collao";"Los Lagos";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"90Y";"Rengo - Chacab.";"Hospital";"Collao -Los Lirios";"Los Queules";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"90J";"Chacab. -Tucapel";"Carrera -Prat";"Alemparte";"Pq.Central";"rgb(255,199,44)";"rgb(0,0,0)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"90X";"O´Higgins -Prat";"Maipú - Tucapel";"Laguna Redonda";"Pq. Central";"rgb(255,199,44)";"rgb(0,0,0)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"B01R";"San Martín";"Tucapel";"EIM Concepción";"Estación - Tribunales";"rgb(236,105,7)";"rgb(0,0,0)";"rgb(236,105,7)";"rgb(255,255,255)"
|
||||||
|
"B01I";"San Martín";"Tucapel";"EIM Concepción";"Estación - Tribunales";"rgb(236,105,7)";"rgb(0,0,0)";"rgb(236,105,7)";"rgb(255,255,255)"
|
||||||
|
"B02R";"Mall - Paicavi";"O'Higgins";"Lider Prat";"Centro Concepción";"rgb(236,105,7)";"rgb(0,0,0)";"rgb(236,105,7)";"rgb(255,255,255)"
|
||||||
|
"B02I";"San Martín";"Paicaví - Mall";"Brisas Del Sol";"Mall - Casino";"rgb(236,105,7)";"rgb(0,0,0)";"rgb(236,105,7)";"rgb(255,255,255)"
|
||||||
|
"B02I";"San Martín";"Paicaví - Mall";"Brisas Del Sol";"300r";"rgb(236,105,7)";"rgb(0,0,0)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"300r";"Concepción";"Vega Monumental";"Ruta 160";"Lota ";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"300r";"Concepción";"Vega Monumental";"Ruta 160";"301r";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"301r";"Concepción";"Vega Monumental";"Ruta 160";"Lota ";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"301r";"Concepción";"Vega Monumental";"Ruta 160";"302r";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"302r";"Concepción";"Vega Monumental";"Ruta 160";"Lota ";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"302r";"Concepción";"Vega Monumental";"Ruta 160";"303r";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"303r";"Concepción";"Vega Monumental";"Ruta 160";"Lota ";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"303r";"Concepción";"Vega Monumental";"Ruta 160";"304r";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"304r";"Concepción";"Vega Monumental";"Ruta 160";"Lota ";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"304r";"Concepción";"Vega Monumental";"Ruta 160";"305r";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"305r";"Concepción";"Vega Monumental";"Ruta 160";"Colcura";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"305r";"Concepción";"Vega Monumental";"Ruta 160";"300i";"rgb(0,30,96)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"300i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"Concepción";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"300i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"301i";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"301i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"Concepción";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"301i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"302i";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"302i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"Concepción";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"302i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"303i";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"303i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"Concepción";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"303i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"304i";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"304i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"Concepción";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"304i";"Lota-Coronel";"Ruta 160";"Pte. Juan Pablo II";"305i";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(0,0,0)";"rgb(0,0,0)"
|
||||||
|
"305i";"Lota - Coronel";"Ruta 160";"Pte. Juan Pablo II";"Concepción";"rgb(152,29,151)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"201i";"Est Biotrén JP II";"Vega Monumental";"Av. Los Carrera";"CONCEPCIÓN";"rgb(198,0,126)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
||||||
|
"201r";"Colo Colo";"Vega Monumental";"Av. Pedro de Valdivia";"SANTA JUANA";"rgb(59,162,220)";"rgb(255,255,255)";"rgb(255,215,0)";"rgb(0,0,0)"
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
import openpyxl
|
||||||
|
import warnings
|
||||||
|
import csv
|
||||||
|
warnings.filterwarnings("ignore")
|
||||||
|
|
||||||
|
|
||||||
|
def read_excel():
|
||||||
|
# Ruta al archivo Excel (puedes ajustar esto según tu estructura de archivos)
|
||||||
|
file_path = 'paletas.xlsx'
|
||||||
|
|
||||||
|
# Abre el archivo Excel
|
||||||
|
wb = openpyxl.load_workbook(file_path, data_only=True)
|
||||||
|
|
||||||
|
# Selecciona una hoja específica o la hoja activa (por defecto)
|
||||||
|
sheet = wb['LUR'] # Puedes usar wb['NombreDeLaHoja'] para seleccionar una hoja específica
|
||||||
|
|
||||||
|
# Itera a través de las filas y columnas del archivo Excel
|
||||||
|
texto1 = ''
|
||||||
|
texto2 = ''
|
||||||
|
texto3 = ''
|
||||||
|
texto4 = ''
|
||||||
|
bgcolor1 = ''
|
||||||
|
bgcolor2 = ''
|
||||||
|
color1 = ''
|
||||||
|
color2 = ''
|
||||||
|
|
||||||
|
archivo_csv = 'LUR.csv'
|
||||||
|
|
||||||
|
with open(archivo_csv, 'w', newline='', encoding='latin-1') as f:
|
||||||
|
escritor = csv.writer(f, delimiter=';', quoting=csv.QUOTE_ALL)
|
||||||
|
escritor.writerow(['codigo','texto1','texto2','texto3','texto4','bgcolor1','color1','bgcolor2','color2'])
|
||||||
|
|
||||||
|
for row in sheet.iter_rows(values_only=True):
|
||||||
|
if row[0] is not None:
|
||||||
|
codigo = row[0]
|
||||||
|
texto1 = ''
|
||||||
|
texto2 = ''
|
||||||
|
texto3 = ''
|
||||||
|
texto4 = ''
|
||||||
|
|
||||||
|
if texto1 == '':
|
||||||
|
texto1 = row[3] or ''
|
||||||
|
bgcolor1 = f'rgb({row[5] or 0},{row[6] or 0},{row[7] or 0})'
|
||||||
|
color1 = f'rgb({row[9] or 0},{row[10] or 0},{row[11] or 0})'
|
||||||
|
elif texto2 == '':
|
||||||
|
texto2 = row[3] or ''
|
||||||
|
elif texto3 == '':
|
||||||
|
texto3 = row[3] or ''
|
||||||
|
else:
|
||||||
|
texto4 = row[3] or ''
|
||||||
|
bgcolor2 = f'rgb({row[5] or 0},{row[6] or 0},{row[7] or 0})'
|
||||||
|
color2 = f'rgb({row[9] or 0},{row[10] or 0},{row[11] or 0})'
|
||||||
|
|
||||||
|
if texto4 != '':
|
||||||
|
escritor.writerow([codigo,texto1,texto2,texto3,texto4,bgcolor1,color1,bgcolor2,color2])
|
||||||
|
|
||||||
|
# No olvides cerrar el archivo después de usarlo
|
||||||
|
wb.close()
|
||||||
|
|
||||||
|
# Tu código para renderizar una respuesta, redireccionar, o lo que necesites
|
||||||
|
|
||||||
|
read_excel()
|
|
@ -0,0 +1,81 @@
|
||||||
|
|
||||||
|
@server = http://localhost:3000/api
|
||||||
|
@token = {{login.response.body.$.token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name login
|
||||||
|
POST {{server}}/auth/
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"username": "usuario1",
|
||||||
|
"password": "usuario1"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name list
|
||||||
|
GET {{server}}/dispositivos?id_paradero=39530
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name url_public_paradero
|
||||||
|
GET {{server}}/paraderos/info-public/39530
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name whoami_existente
|
||||||
|
POST {{server}}/dispositivos/whoami/
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"whoami": {
|
||||||
|
"idDispositivo": "TTM543870hyt",
|
||||||
|
"KeyAutorizacion": "token"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name whoami_no_existe
|
||||||
|
POST {{server}}/dispositivos/whoami/
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"whoami": {
|
||||||
|
"idDispositivo": "otro",
|
||||||
|
"KeyAutorizacion": "token"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name get_info_device
|
||||||
|
POST {{server}}/dispositivos/getInfoDevice/
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"GetInfoDevice": {
|
||||||
|
"idDispositivo": "TTM543870hyt",
|
||||||
|
"KeyAutorizacion":"token"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{server}}/lineas/proto?id_paradero=45086
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{server}}/lineas/buses_proto/?id_linea=730-0
|
||||||
|
Authorization: Bearer {{token}}
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
@server = http://localhost:4000/api
|
||||||
|
@token = {{login.response.body.$.token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name login
|
||||||
|
POST {{server}}/auth/
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"username": "0",
|
||||||
|
"password": "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{server}}/letreros-lur
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{server}}/letreros-lur/50U
|
||||||
|
Authorization: Bearer {{token}}
|
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
@server = http://localhost:4000/api
|
||||||
|
@token = {{login.response.body.$.token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name login
|
||||||
|
POST {{server}}/auth/
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"username": "0",
|
||||||
|
"password": "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{server}}/auth/
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{server}}/aplicaciones/?ordering=-id_aplicacion
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{server}}/paraderos-image/??id_paradero=42318
|
||||||
|
Authorization: Bearer {{token}}
|
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
@server = http://localhost:3000/api
|
||||||
|
@token = {{login.response.body.$.token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name login
|
||||||
|
POST {{server}}/auth/
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"username": "usuario1",
|
||||||
|
"password": "usuario1"
|
||||||
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
# @name protodata
|
||||||
|
GET {{server}}/proto/status
|
||||||
|
Authorization: Bearer {{token}}
|
|
@ -0,0 +1,18 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
from api import models
|
||||||
|
# from .models import Usuario, Rol, UsuarioRol
|
||||||
|
# from .models import Aplicacion, RolAplicacion
|
||||||
|
# from .models import Persona, TipoTratamientoPersona
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
|
# admin.site.register(Usuario)
|
||||||
|
# admin.site.register(UsuarioRol)
|
||||||
|
# admin.site.register(Persona)
|
||||||
|
# admin.site.register(TipoTratamientoPersona)
|
||||||
|
# admin.site.register(Rol)
|
||||||
|
# admin.site.register(RolAplicacion)
|
||||||
|
# admin.site.register(Aplicacion)
|
||||||
|
|
||||||
|
@admin.register(models.ParaderoImagen)
|
||||||
|
class ParaderoImagenAdmin(admin.ModelAdmin):
|
||||||
|
search_fields = ('id_paradero',)
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ApiConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'api'
|
|
@ -0,0 +1,9 @@
|
||||||
|
from rest_framework.exceptions import APIException
|
||||||
|
|
||||||
|
class NotAuthorized(APIException):
|
||||||
|
status_code = 401
|
||||||
|
default_detail = 'Acceso negado'
|
||||||
|
|
||||||
|
class JWTExpired(APIException):
|
||||||
|
status_code = 400
|
||||||
|
default_detail = 'Token ya no es valido'
|
|
@ -0,0 +1,60 @@
|
||||||
|
from django.urls import resolve
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from .models import Usuario, Persona
|
||||||
|
from decouple import config
|
||||||
|
import jwt
|
||||||
|
import logging
|
||||||
|
|
||||||
|
private_key = config('SECRET_JWT')
|
||||||
|
|
||||||
|
class ApiMiddleware:
|
||||||
|
def __init__(self, get_response):
|
||||||
|
self.get_response = get_response
|
||||||
|
|
||||||
|
def __call__(self, request):
|
||||||
|
# se omite esta regla si no es api
|
||||||
|
if request.path[0:5] != '/api/':
|
||||||
|
response = self.get_response(request)
|
||||||
|
return response
|
||||||
|
|
||||||
|
# se omite esta regla en login
|
||||||
|
if request.path == '/api/auth/' and request.method == 'POST':
|
||||||
|
response = self.get_response(request)
|
||||||
|
return response
|
||||||
|
|
||||||
|
match = resolve(request.path)
|
||||||
|
logging.error(match)
|
||||||
|
# se omite esta regla al mostrar imagen de paradero
|
||||||
|
if match.url_name == 'paradero_imagen-detail' and request.method == 'GET':
|
||||||
|
response = self.get_response(request)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
if not request.headers.get('Authorization'):
|
||||||
|
return HttpResponse('Debe indicar el token de autorización', status = 400)
|
||||||
|
|
||||||
|
authorization = request.headers.get('Authorization').split(' ')
|
||||||
|
token = authorization[1]
|
||||||
|
|
||||||
|
try:
|
||||||
|
decoded = jwt.decode(token, private_key, algorithms=["HS256"])
|
||||||
|
except jwt.ExpiredSignatureError:
|
||||||
|
return HttpResponse('token ya no es valido', status = 400)
|
||||||
|
except jwt.InvalidTokenError:
|
||||||
|
return HttpResponse('token es invalido', status = 400)
|
||||||
|
|
||||||
|
if decoded['login'] != '0':
|
||||||
|
usuario = Usuario.objects.filter(login = decoded['login'], vigente = True).values().first()
|
||||||
|
if not usuario:
|
||||||
|
return HttpResponse('Usuario ya no vigente', status = 400)
|
||||||
|
|
||||||
|
persona = Persona.objects.filter(rut = usuario['rut_id']).values().first()
|
||||||
|
if not persona:
|
||||||
|
return HttpResponse('No existe información de la persona', status = 500)
|
||||||
|
|
||||||
|
request.jwt_info = { 'login': usuario['login'], 'persona': persona }
|
||||||
|
else:
|
||||||
|
request.jwt_info = { 'login': '0', 'persona': None }
|
||||||
|
|
||||||
|
response = self.get_response(request)
|
||||||
|
return response
|
|
@ -0,0 +1,416 @@
|
||||||
|
# This is an auto-generated Django model module.
|
||||||
|
# You'll have to do the following manually to clean this up:
|
||||||
|
# * Rearrange models' order
|
||||||
|
# * Make sure each model has one field with primary_key=True
|
||||||
|
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
|
||||||
|
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
|
||||||
|
# Feel free to rename the models, but don't rename db_table values or field names.
|
||||||
|
from django.db import models
|
||||||
|
from .validaciones import rut_valido
|
||||||
|
|
||||||
|
|
||||||
|
class Aplicacion(models.Model):
|
||||||
|
id_aplicacion = models.IntegerField(primary_key=True)
|
||||||
|
nombre_app = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'aplicacion'
|
||||||
|
|
||||||
|
|
||||||
|
class Comuna(models.Model):
|
||||||
|
id_comuna = models.IntegerField(primary_key=True)
|
||||||
|
id_region = models.ForeignKey('Region', models.DO_NOTHING, db_column='id_region', blank=True, null=True)
|
||||||
|
nombre_comuna = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'comuna'
|
||||||
|
|
||||||
|
|
||||||
|
class Conductor(models.Model):
|
||||||
|
patente = models.OneToOneField('Vehiculo', models.DO_NOTHING, db_column='patente', primary_key=True)
|
||||||
|
rut = models.ForeignKey('Persona', models.DO_NOTHING, db_column='rut', blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'conductor'
|
||||||
|
|
||||||
|
|
||||||
|
class Dispositivo(models.Model):
|
||||||
|
id_dispositivo = models.CharField(primary_key=True, max_length=100)
|
||||||
|
id_paradero = models.ForeignKey('Paradero', models.DO_NOTHING, db_column='id_paradero', blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
ultima_conexion = models.DateField(blank=True, null=True)
|
||||||
|
id_tipo_dispositivo = models.ForeignKey('TipoDispositivo', models.DO_NOTHING, db_column='id_tipo_dispositivo')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'dispositivo'
|
||||||
|
|
||||||
|
|
||||||
|
class Funcionario(models.Model):
|
||||||
|
rut = models.OneToOneField('Persona', models.DO_NOTHING, db_column='rut', primary_key=True)
|
||||||
|
id_operador = models.ForeignKey('Operador', models.DO_NOTHING, db_column='id_operador', blank=True, null=True)
|
||||||
|
desde = models.DateField(blank=True, null=True)
|
||||||
|
hasta = models.DateField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'funcionario'
|
||||||
|
|
||||||
|
|
||||||
|
class GtfsFrequencie(models.Model):
|
||||||
|
id_trip = models.ForeignKey('GtfsTrips', models.DO_NOTHING, db_column='id_trip', blank=True, null=True)
|
||||||
|
start_time = models.TimeField(blank=True, null=True)
|
||||||
|
end_time = models.TimeField(blank=True, null=True)
|
||||||
|
headway_secs = models.IntegerField(blank=True, null=True)
|
||||||
|
exact_time = models.IntegerField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'gtfs_frequencie'
|
||||||
|
|
||||||
|
|
||||||
|
class GtfsPosiciones(models.Model):
|
||||||
|
id = models.UUIDField(primary_key=True)
|
||||||
|
trip_id = models.UUIDField()
|
||||||
|
route_id = models.IntegerField()
|
||||||
|
direction_id = models.SmallIntegerField(blank=True, null=True)
|
||||||
|
start_time = models.TimeField(blank=True, null=True)
|
||||||
|
start_date = models.DateField(blank=True, null=True)
|
||||||
|
schedule_relationship = models.SmallIntegerField(blank=True, null=True)
|
||||||
|
vehicle_license_plate = models.CharField(max_length=10, blank=True, null=True)
|
||||||
|
latitude = models.FloatField(blank=True, null=True)
|
||||||
|
longitude = models.FloatField(blank=True, null=True)
|
||||||
|
bearing = models.IntegerField(blank=True, null=True)
|
||||||
|
odometer = models.IntegerField(blank=True, null=True)
|
||||||
|
speed = models.FloatField(blank=True, null=True)
|
||||||
|
stop_sequence = models.IntegerField(blank=True, null=True)
|
||||||
|
stop_id = models.IntegerField(blank=True, null=True)
|
||||||
|
arrival_time = models.BigIntegerField(blank=True, null=True)
|
||||||
|
hora_llegada = models.DateTimeField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'gtfs_posiciones'
|
||||||
|
|
||||||
|
|
||||||
|
class GtfsRouteType(models.Model):
|
||||||
|
id_route_type = models.DecimalField(primary_key=True, max_digits=2, decimal_places=0)
|
||||||
|
descripcion = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'gtfs_route_type'
|
||||||
|
|
||||||
|
|
||||||
|
class GtfsShape(models.Model):
|
||||||
|
id_shape = models.DecimalField(max_digits=18, decimal_places=0)
|
||||||
|
shape_pt_lat = models.FloatField(blank=True, null=True)
|
||||||
|
shape_pt_lon = models.FloatField(blank=True, null=True)
|
||||||
|
shape_pt_sequence = models.IntegerField(blank=True, null=True)
|
||||||
|
shape_dist_traveled = models.FloatField(blank=True, null=True)
|
||||||
|
id_gtfs_pk = models.AutoField(primary_key=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'gtfs_shape'
|
||||||
|
unique_together = (('id_shape', 'shape_dist_traveled'),)
|
||||||
|
|
||||||
|
|
||||||
|
class GtfsStopTimes(models.Model):
|
||||||
|
id_paradero = models.OneToOneField('Paradero', models.DO_NOTHING, db_column='id_paradero', primary_key=True) # The composite primary key (id_paradero, id_trip) found, that is not supported. The first column is selected.
|
||||||
|
id_trip = models.ForeignKey('GtfsTrips', models.DO_NOTHING, db_column='id_trip')
|
||||||
|
arrival_time = models.CharField(max_length=15, blank=True, null=True)
|
||||||
|
stop_sequence = models.IntegerField(blank=True, null=True)
|
||||||
|
stop_headsign = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
departure_time = models.CharField(max_length=15, blank=True, null=True)
|
||||||
|
drop_off_type = models.IntegerField(blank=True, null=True)
|
||||||
|
shape_dist_traveled = models.FloatField(blank=True, null=True)
|
||||||
|
timepoint = models.IntegerField(blank=True, null=True)
|
||||||
|
pickup_type = models.IntegerField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'gtfs_stop_times'
|
||||||
|
unique_together = (('id_paradero', 'id_trip'),)
|
||||||
|
|
||||||
|
|
||||||
|
class GtfsTrips(models.Model):
|
||||||
|
id_trip = models.CharField(primary_key=True, max_length=150)
|
||||||
|
id_linea = models.CharField(max_length=150, blank=True, null=True)
|
||||||
|
id_shape = models.IntegerField(blank=True, null=True)
|
||||||
|
id_trip_regreso = models.ForeignKey('self', models.DO_NOTHING, db_column='id_trip_regreso', blank=True, null=True)
|
||||||
|
trip_headsign = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
trip_short_name = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
direction_id = models.IntegerField(blank=True, null=True)
|
||||||
|
service_id = models.CharField(max_length=50, blank=True, null=True, db_comment='de calendario')
|
||||||
|
block_id = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'gtfs_trips'
|
||||||
|
|
||||||
|
|
||||||
|
class LetreroLUR(models.Model):
|
||||||
|
codigo = models.CharField(primary_key=True, max_length=10)
|
||||||
|
linea1 = models.CharField(max_length=50)
|
||||||
|
linea2 = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
linea3 = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
linea4 = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
bgcolor1 = models.CharField(max_length=20, blank=True, null=True)
|
||||||
|
color1 = models.CharField(max_length=20, blank=True, null=True)
|
||||||
|
bgcolor2 = models.CharField(max_length=20, blank=True, null=True)
|
||||||
|
color2 = models.CharField(max_length=20, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'letrero_lur'
|
||||||
|
|
||||||
|
|
||||||
|
class Linea(models.Model):
|
||||||
|
id_linea = models.CharField(primary_key=True, max_length=150)
|
||||||
|
id_operador = models.ForeignKey('Operador', models.DO_NOTHING, db_column='id_operador', blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
route_short_name = models.CharField(max_length=150, blank=True, null=True)
|
||||||
|
route_desc = models.CharField(max_length=150, blank=True, null=True)
|
||||||
|
route_type = models.ForeignKey(GtfsRouteType, models.DO_NOTHING, db_column='route_type', blank=True, null=True)
|
||||||
|
route_url = models.CharField(max_length=150, blank=True, null=True)
|
||||||
|
route_color = models.CharField(max_length=150, blank=True, null=True)
|
||||||
|
route_text_color = models.CharField(max_length=150, blank=True, null=True)
|
||||||
|
route_long_name = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'linea'
|
||||||
|
|
||||||
|
|
||||||
|
class LineaParadero(models.Model):
|
||||||
|
id_linea_paradero = models.AutoField(primary_key=True)
|
||||||
|
id_linea = models.ForeignKey(Linea, models.DO_NOTHING, db_column='id_linea')
|
||||||
|
id_paradero = models.ForeignKey('Paradero', models.DO_NOTHING, db_column='id_paradero', blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'linea_paradero'
|
||||||
|
|
||||||
|
|
||||||
|
class Operador(models.Model):
|
||||||
|
id_operador = models.CharField(primary_key=True, max_length=150)
|
||||||
|
id_region = models.ForeignKey('Region', models.DO_NOTHING, db_column='id_region', blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
nombre_operador = models.CharField(max_length=150, blank=True, null=True)
|
||||||
|
agency_url = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
agency_timezone = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
agency_lang = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
agency_phone = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
agency_fare_url = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'operador'
|
||||||
|
|
||||||
|
|
||||||
|
class Paradero(models.Model):
|
||||||
|
id_paradero = models.CharField(primary_key=True, max_length=50)
|
||||||
|
id_comuna = models.ForeignKey(Comuna, models.DO_NOTHING, db_column='id_comuna', blank=True, null=True)
|
||||||
|
id_tipo_paradero = models.ForeignKey('TipoParadero', models.DO_NOTHING, db_column='id_tipo_paradero', blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
stop_code = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
stop_name = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
stop_desc = models.CharField(max_length=300, blank=True, null=True)
|
||||||
|
stop_lat = models.FloatField(blank=True, null=True)
|
||||||
|
stop_lon = models.FloatField(blank=True, null=True)
|
||||||
|
zone_id = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
stop_url = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
location_type = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
parent_station = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
stop_timezonene_id = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
wheelchair_boarding = models.DecimalField(max_digits=2, decimal_places=0, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'paradero'
|
||||||
|
|
||||||
|
|
||||||
|
class ParaderoImagen(models.Model):
|
||||||
|
id_paradero_imagen = models.AutoField(primary_key=True)
|
||||||
|
id_paradero = models.ForeignKey(Paradero, models.DO_NOTHING, db_column='id_paradero')
|
||||||
|
imagen = models.BinaryField(blank=True, null=True)
|
||||||
|
content_type = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'paradero_imagen'
|
||||||
|
|
||||||
|
|
||||||
|
class Persona(models.Model):
|
||||||
|
rut = models.DecimalField(primary_key=True, max_digits=12, decimal_places=0)
|
||||||
|
id_tipo_tratamiento = models.ForeignKey('TipoTratamientoPersona', models.DO_NOTHING, db_column='id_tipo_tratamiento', blank=True, null=True)
|
||||||
|
id_comuna = models.ForeignKey(Comuna, models.DO_NOTHING, db_column='id_comuna', blank=True, null=True)
|
||||||
|
dv = models.CharField(max_length=1, blank=True, null=True)
|
||||||
|
nombres = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
apellido_a = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
apellido_b = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
fono = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
email = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
fecha_nacimiento = models.DateField(blank=True, null=True)
|
||||||
|
direccion = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'persona'
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
# validacion se realiza solo si se esta creando el registro
|
||||||
|
if self._state.adding:
|
||||||
|
rut_completo = f'{self.rut}-{self.dv}'
|
||||||
|
if not rut_valido(rut_completo):
|
||||||
|
raise Exception(f'RUT {rut_completo}, no es valido!')
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class Region(models.Model):
|
||||||
|
id_region = models.IntegerField(primary_key=True)
|
||||||
|
nombre_region = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'region'
|
||||||
|
|
||||||
|
|
||||||
|
class Rol(models.Model):
|
||||||
|
id_rol = models.IntegerField(primary_key=True)
|
||||||
|
nombre_rol = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'rol'
|
||||||
|
|
||||||
|
|
||||||
|
class RolAplicacion(models.Model):
|
||||||
|
id_aplicacion = models.ForeignKey(Aplicacion, models.DO_NOTHING, db_column='id_aplicacion')
|
||||||
|
id_rol = models.ForeignKey(Rol, models.DO_NOTHING, db_column='id_rol')
|
||||||
|
solo_visualizar = models.BooleanField(blank=True, null=True)
|
||||||
|
id_rol_app = models.AutoField(primary_key=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'rol_aplicacion'
|
||||||
|
unique_together = (('id_aplicacion', 'id_rol'),)
|
||||||
|
|
||||||
|
|
||||||
|
class SpatialRefSys(models.Model):
|
||||||
|
srid = models.IntegerField(primary_key=True)
|
||||||
|
auth_name = models.CharField(max_length=256, blank=True, null=True)
|
||||||
|
auth_srid = models.IntegerField(blank=True, null=True)
|
||||||
|
srtext = models.CharField(max_length=2048, blank=True, null=True)
|
||||||
|
proj4text = models.CharField(max_length=2048, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'spatial_ref_sys'
|
||||||
|
|
||||||
|
|
||||||
|
class TipoDispositivo(models.Model):
|
||||||
|
id_tipo_dispositivo = models.IntegerField(primary_key=True)
|
||||||
|
descripcion = models.CharField(max_length=50)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'tipo_dispositivo'
|
||||||
|
|
||||||
|
|
||||||
|
class TipoParadero(models.Model):
|
||||||
|
id_tipo_paradero = models.IntegerField(primary_key=True)
|
||||||
|
descripcion = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'tipo_paradero'
|
||||||
|
|
||||||
|
|
||||||
|
class TipoTransporte(models.Model):
|
||||||
|
id_tipo_transporte = models.IntegerField(primary_key=True)
|
||||||
|
descripcion = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'tipo_transporte'
|
||||||
|
|
||||||
|
|
||||||
|
class TipoTratamientoPersona(models.Model):
|
||||||
|
id_tipo_tratamiento = models.IntegerField(primary_key=True)
|
||||||
|
tratamiento = models.CharField(max_length=50, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'tipo_tratamiento_persona'
|
||||||
|
db_table_comment = 'Establece el tratamiento de como dirigirse hacia una persona:\r\nEjemplo\r\nSeñor\r\nSeñora\r\nSrta'
|
||||||
|
|
||||||
|
|
||||||
|
class TipoVehiculo(models.Model):
|
||||||
|
id_tipo_vehiculo = models.IntegerField(primary_key=True)
|
||||||
|
descripcion = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'tipo_vehiculo'
|
||||||
|
|
||||||
|
|
||||||
|
class Usuario(models.Model):
|
||||||
|
login = models.CharField(primary_key=True, max_length=60)
|
||||||
|
rut = models.ForeignKey(Persona, models.DO_NOTHING, db_column='rut', blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
superuser = models.BooleanField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'usuario'
|
||||||
|
|
||||||
|
|
||||||
|
class UsuarioClave(models.Model):
|
||||||
|
login = models.OneToOneField(Usuario, models.DO_NOTHING, db_column='login', primary_key=True)
|
||||||
|
clave = models.CharField(max_length=60, blank=True, null=True)
|
||||||
|
clave_anterior = models.CharField(max_length=60, blank=True, null=True)
|
||||||
|
fecha_modificacion = models.DateField(blank=True, null=True)
|
||||||
|
codigo = models.DecimalField(max_digits=8, decimal_places=0, blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'usuario_clave'
|
||||||
|
|
||||||
|
|
||||||
|
class UsuarioRol(models.Model):
|
||||||
|
login = models.ForeignKey(Usuario, models.DO_NOTHING, db_column='login', blank=True, null=True)
|
||||||
|
id_rol = models.ForeignKey(Rol, models.DO_NOTHING, db_column='id_rol', blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'usuario_rol'
|
||||||
|
|
||||||
|
|
||||||
|
class Vehiculo(models.Model):
|
||||||
|
ppu = models.CharField(primary_key=True, max_length=10)
|
||||||
|
id_tipo_vehiculo = models.ForeignKey(TipoVehiculo, models.DO_NOTHING, db_column='id_tipo_vehiculo', blank=True, null=True)
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'vehiculo'
|
||||||
|
|
||||||
|
|
||||||
|
class VehiculoLinea(models.Model):
|
||||||
|
patente = models.OneToOneField(Vehiculo, models.DO_NOTHING, db_column='patente', primary_key=True) # The composite primary key (patente, id_linea) found, that is not supported. The first column is selected.
|
||||||
|
id_linea = models.ForeignKey(Linea, models.DO_NOTHING, db_column='id_linea')
|
||||||
|
vigente = models.BooleanField(blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'vehiculo_linea'
|
||||||
|
unique_together = (('patente', 'id_linea'),)
|
|
@ -0,0 +1,43 @@
|
||||||
|
from rest_framework.schemas import AutoSchema
|
||||||
|
import coreapi
|
||||||
|
|
||||||
|
class AuthSchema(AutoSchema):
|
||||||
|
manual_fields = []
|
||||||
|
|
||||||
|
def get_manual_fields(self, path, method):
|
||||||
|
custom_fields = []
|
||||||
|
if method.lower() == 'post':
|
||||||
|
custom_fields = [
|
||||||
|
coreapi.Field('username', required=True, location='form', description='Usuario'),
|
||||||
|
coreapi.Field('password', required=True, location='form', description='Contraseña'),
|
||||||
|
]
|
||||||
|
return self._manual_fields + custom_fields
|
||||||
|
|
||||||
|
class UsuarioSchema(AutoSchema):
|
||||||
|
manual_fields = []
|
||||||
|
|
||||||
|
def get_manual_fields(self, path, method):
|
||||||
|
custom_fields = []
|
||||||
|
if method.lower() == 'post':
|
||||||
|
custom_fields = [
|
||||||
|
coreapi.Field('rut', required=True, location='form', description='RUT'),
|
||||||
|
coreapi.Field('nombres', required=True, location='form', description='Nombres'),
|
||||||
|
coreapi.Field('apellido_a', required=True, location='form', description='Apellido A'),
|
||||||
|
coreapi.Field('apellido_b', required=True, location='form', description='Apellido B'),
|
||||||
|
coreapi.Field('email', required=True, location='form', description='Correo Electrónico'),
|
||||||
|
coreapi.Field('login', required=True, location='form', description='Usuario'),
|
||||||
|
coreapi.Field('clave', required=True, location='form', description='Contraseña'),
|
||||||
|
coreapi.Field('vigente', location='form', description='Vigente'),
|
||||||
|
]
|
||||||
|
return self._manual_fields + custom_fields
|
||||||
|
|
||||||
|
class ParaderoImageSchema(AutoSchema):
|
||||||
|
manual_fields = []
|
||||||
|
|
||||||
|
def get_manual_fields(self, path, method):
|
||||||
|
custom_fields = []
|
||||||
|
if method.lower() == 'post':
|
||||||
|
custom_fields=[
|
||||||
|
coreapi.Field('imagen', required=True, location='formData', type='file', description='Imagen a Subir')
|
||||||
|
]
|
||||||
|
return self._manual_fields + custom_fields
|
|
@ -0,0 +1,132 @@
|
||||||
|
from rest_framework import serializers
|
||||||
|
from django.forms.models import model_to_dict
|
||||||
|
from django.core.serializers import serialize
|
||||||
|
|
||||||
|
from . import models
|
||||||
|
|
||||||
|
class AplicacionSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Aplicacion
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class DispositivoSerializer(serializers.ModelSerializer):
|
||||||
|
tipo_dispositivo = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
def get_tipo_dispositivo(self, row):
|
||||||
|
return model_to_dict(row.id_tipo_dispositivo)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.Dispositivo
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TipoDispositivoSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.TipoDispositivo
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TipoParaderoSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.TipoParadero
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TipoTransporteSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.TipoTransporte
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TipoVehiculoSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.TipoVehiculo
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TipoTratamientoPersonaSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.TipoTratamientoPersona
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class PersonaSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Persona
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class ComunaSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Comuna
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class RegionSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Region
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class ParaderoSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Paradero
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class ParaderoImagenSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.ParaderoImagen
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def to_representation(self, instance):
|
||||||
|
representation = super().to_representation(instance)
|
||||||
|
del representation['imagen']
|
||||||
|
request = self.context.get('request')
|
||||||
|
representation['url'] = request.build_absolute_uri(f'/api/paraderos-image/{instance.id_paradero_imagen}/')
|
||||||
|
return representation
|
||||||
|
|
||||||
|
class OperadorSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Operador
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class LineaSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Linea
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class LineaParaderoSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.LineaParadero
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class UsuarioSerializer(serializers.ModelSerializer):
|
||||||
|
# muestro informacion de persona en un objeto aparte
|
||||||
|
persona = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.Usuario
|
||||||
|
fields = '__all__'
|
||||||
|
read_only_fields = ['login']
|
||||||
|
|
||||||
|
def get_persona(self, row):
|
||||||
|
return model_to_dict(row.rut)
|
||||||
|
|
||||||
|
def to_representation(self, instance):
|
||||||
|
representation = super().to_representation(instance)
|
||||||
|
|
||||||
|
# Elimina el campo que deseas después de la actualización
|
||||||
|
if 'clave' in representation:
|
||||||
|
del representation['clave']
|
||||||
|
|
||||||
|
return representation
|
||||||
|
|
||||||
|
class AuthSerializer(serializers.Serializer):
|
||||||
|
username = serializers.CharField(required=True)
|
||||||
|
password = serializers.CharField(required=True, style={'input_type':'password'})
|
||||||
|
|
||||||
|
class RolSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Rol
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class RolAplicacionSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.RolAplicacion
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class LetreroLUR_Serializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.LetreroLUR
|
||||||
|
fields = '__all__'
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
|
@ -0,0 +1,38 @@
|
||||||
|
from django.urls import path, include
|
||||||
|
from rest_framework import routers
|
||||||
|
# from api import views
|
||||||
|
from api.views import usuario, auth, aplicacion, tipo, persona, comuna, region, paradero, rol, rolaplicacion
|
||||||
|
from api.views import mapa, linea, letrero_lur, operador
|
||||||
|
from api.views import paradero_imagen, linea_paradero
|
||||||
|
from api.views import dispositivo
|
||||||
|
from api.views import proto
|
||||||
|
|
||||||
|
router = routers.DefaultRouter()
|
||||||
|
router.register('aplicaciones', aplicacion.AplicacionViewSet)
|
||||||
|
router.register('usuarios', usuario.UsuarioViewSet)
|
||||||
|
router.register('personas', persona.PersonaViewSet)
|
||||||
|
router.register('dispositivos', dispositivo.DispositivoViewSet)
|
||||||
|
router.register('tipos/persona', tipo.TipoTratamientoPersonaViewSet)
|
||||||
|
router.register('tipos/transporte', tipo.TipoTransporteViewSet)
|
||||||
|
router.register('tipos/dispositivo', tipo.TipoDispositivoViewSet)
|
||||||
|
router.register('tipos/paradero', tipo.TipoParaderoViewSet)
|
||||||
|
router.register('tipos/vehiculo', tipo.TipoVehiculoViewSet)
|
||||||
|
router.register('comunas', comuna.ComunaViewSet)
|
||||||
|
router.register('regiones', region.RegionViewSet)
|
||||||
|
router.register('paraderos', paradero.ParaderoViewSet)
|
||||||
|
router.register('paraderos-image', paradero_imagen.ParaderoImagenListView, basename='paradero_imagen')
|
||||||
|
router.register('lineas', linea.LineaViewSet)
|
||||||
|
router.register('lineas-paradero', linea_paradero.LineaParaderoViewSet)
|
||||||
|
router.register('letreros-lur', letrero_lur.LetreroLUR_ViewSet)
|
||||||
|
router.register('operadores', operador.OperadorViewSet)
|
||||||
|
router.register('roles', rol.RolViewSet)
|
||||||
|
router.register('rolyaplicacion', rolaplicacion.RolAplicacionViewSet, basename='rol_aplicacion')
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', include(router.urls)),
|
||||||
|
path('auth/', auth.jwt_login, name='auth'),
|
||||||
|
path('mapas/paraderos/', mapa.paraderos, name='mapa-paraderos'),
|
||||||
|
path('mapas/rutas/', mapa.rutas, name='mapa-rutas'),
|
||||||
|
path('paraderos/info-public/<int:pk>/', paradero.info_public, name='paradero-infopublic'),
|
||||||
|
path('proto/status/', proto.status, name='proto_status'),
|
||||||
|
]
|
|
@ -0,0 +1,20 @@
|
||||||
|
def rut_valido(rut):
|
||||||
|
rut = rut.replace(".", "").replace("-", "") # Eliminar puntos y guiones
|
||||||
|
if len(rut) < 2:
|
||||||
|
return False
|
||||||
|
verificador = rut[-1]
|
||||||
|
numero = rut[:-1]
|
||||||
|
try:
|
||||||
|
suma = 0
|
||||||
|
contador = 0
|
||||||
|
for i in range(len(numero) - 1, -1, -1):
|
||||||
|
suma += int(numero[i]) * (2 + contador)
|
||||||
|
contador = (contador + 1) % 6
|
||||||
|
digito_verificador = 11 - suma % 11
|
||||||
|
if digito_verificador == 11:
|
||||||
|
digito_verificador = 0
|
||||||
|
if digito_verificador == 10:
|
||||||
|
digito_verificador = "k"
|
||||||
|
return str(digito_verificador) == verificador.lower()
|
||||||
|
except ValueError:
|
||||||
|
return False
|
|
@ -0,0 +1,7 @@
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from .. import models, serializers
|
||||||
|
|
||||||
|
class AplicacionViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Aplicacion.objects.all()
|
||||||
|
serializer_class = serializers.AplicacionSerializer
|
||||||
|
ordering_fields = '__all__'
|
|
@ -0,0 +1,58 @@
|
||||||
|
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.http import JsonResponse
|
||||||
|
|
||||||
|
from rest_framework.decorators import action, api_view, schema
|
||||||
|
|
||||||
|
from .. import models, schemas
|
||||||
|
from decouple import config
|
||||||
|
import json
|
||||||
|
import jwt
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
|
private_key = config('SECRET_JWT')
|
||||||
|
|
||||||
|
# Views jwt
|
||||||
|
@csrf_exempt
|
||||||
|
@action(detail=False, methods=['post','get'])
|
||||||
|
@api_view(['GET','POST'])
|
||||||
|
@schema(schemas.AuthSchema())
|
||||||
|
def jwt_login(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
count = models.Usuario.objects.filter(vigente = True).count()
|
||||||
|
logging.error(f'count usuario vigente = {count}')
|
||||||
|
|
||||||
|
# validar username y password
|
||||||
|
input = json.loads(request.body)
|
||||||
|
username = input['username']
|
||||||
|
password = input['password']
|
||||||
|
usuario = None
|
||||||
|
|
||||||
|
if count > 0:
|
||||||
|
usuario = models.Usuario.objects.filter(login = username, vigente = True).values().first()
|
||||||
|
elif username == '0' and password == '0':
|
||||||
|
usuario = { 'login': '0', 'clave': '0' }
|
||||||
|
|
||||||
|
if not usuario:
|
||||||
|
return HttpResponse('Acceso no valido', status=400)
|
||||||
|
|
||||||
|
if username != '0':
|
||||||
|
clave = models.UsuarioClave.objects.filter(login = username).first()
|
||||||
|
if not clave or clave.clave != password:
|
||||||
|
return HttpResponse('Acceso no valido', status=400)
|
||||||
|
|
||||||
|
ahora = datetime.utcnow()
|
||||||
|
manana = ahora + timedelta(days=1)
|
||||||
|
manana = manana.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
'iat': ahora,
|
||||||
|
'exp': manana, # ahora + timedelta(minutes=60),
|
||||||
|
'login': usuario['login']
|
||||||
|
}
|
||||||
|
token = jwt.encode(payload, private_key, algorithm="HS256")
|
||||||
|
return JsonResponse({ 'token': token })
|
||||||
|
elif request.method == 'GET':
|
||||||
|
return JsonResponse(request.jwt_info)
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from .. import models, serializers
|
||||||
|
from django.db import models as dj_models
|
||||||
|
|
||||||
|
class ComunaViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Comuna.objects.all()
|
||||||
|
serializer_class = serializers.ComunaSerializer
|
||||||
|
|
||||||
|
def create(self, request, *args, **kwargs):
|
||||||
|
# se indica que si no se indico el id, entonces sea el maximo + 1
|
||||||
|
if not request.data.get('id_comuna', None):
|
||||||
|
max_id = models.Comuna.objects.aggregate(dj_models.Max('id_comuna'))['id_comuna__max']
|
||||||
|
new_id = max_id + 1 if max_id is not None else 1
|
||||||
|
request.data['id_comuna'] = new_id
|
||||||
|
|
||||||
|
return super().create(request, *args, **kwargs)
|
|
@ -0,0 +1,89 @@
|
||||||
|
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from django.http import JsonResponse
|
||||||
|
from django.db.models import F
|
||||||
|
from django.db import connection
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from rest_framework.decorators import action
|
||||||
|
from .. import models, serializers
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class DispositivoViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Dispositivo.objects.all()
|
||||||
|
serializer_class = serializers.DispositivoSerializer
|
||||||
|
filter_backends = [DjangoFilterBackend]
|
||||||
|
filterset_fields = ['id_paradero', 'id_tipo_dispositivo']
|
||||||
|
|
||||||
|
|
||||||
|
@action(detail=False, methods=['post'])
|
||||||
|
def whoami(self, request, pk=None):
|
||||||
|
input = json.loads(request.body)
|
||||||
|
whoami = input['whoami']
|
||||||
|
|
||||||
|
record = models.Paradero.objects \
|
||||||
|
.filter(dispositivo__id_dispositivo=whoami['idDispositivo']) \
|
||||||
|
.annotate(nro_paradero=F('id_paradero'), nombre_paradero=F('stop_name')) \
|
||||||
|
.first()
|
||||||
|
|
||||||
|
if (record):
|
||||||
|
return JsonResponse({
|
||||||
|
"WhoamiResponse": {
|
||||||
|
"NroParadero": record.nro_paradero,
|
||||||
|
"NombreParadero": record.nombre_paradero,
|
||||||
|
"Status": "OK"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
# retorna json de no existente
|
||||||
|
return JsonResponse({
|
||||||
|
"WhoamiResponse": {
|
||||||
|
"Status": "NOK",
|
||||||
|
"errorString": "Dispositivo no identificado"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@action(detail=False, methods=['post'])
|
||||||
|
def getInfoDevice(self, request, pk=None):
|
||||||
|
input = json.loads(request.body)
|
||||||
|
getInfoDevice = input['GetInfoDevice']
|
||||||
|
|
||||||
|
|
||||||
|
record = models.Paradero.objects \
|
||||||
|
.filter(dispositivo__id_dispositivo=getInfoDevice['idDispositivo']) \
|
||||||
|
.annotate(nro_paradero=F('id_paradero'), nombre_paradero=F('stop_name')) \
|
||||||
|
.first()
|
||||||
|
|
||||||
|
query = "SELECT json_data \
|
||||||
|
from gtfs_posiciones_json \
|
||||||
|
where stop_id = %s"
|
||||||
|
|
||||||
|
params = [ record.nro_paradero ]
|
||||||
|
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute(query, params)
|
||||||
|
row = cursor.fetchone()
|
||||||
|
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
detalle_lineas = []
|
||||||
|
|
||||||
|
for linea in row[0]:
|
||||||
|
# logging.error(linea['linea'])
|
||||||
|
data_linea = {
|
||||||
|
'Linea': linea['linea'],
|
||||||
|
'Descripcion': linea['Descripcion'],
|
||||||
|
'TipoLocomocion': linea['tipo_locomocion'],
|
||||||
|
'colorFondo': linea['colorFondo'],
|
||||||
|
'colorLetra': linea['colorLetra'],
|
||||||
|
'Llegadas': linea['Llegadas']
|
||||||
|
}
|
||||||
|
detalle_lineas.append(data_linea)
|
||||||
|
|
||||||
|
return JsonResponse({
|
||||||
|
"GetInfoDeviceResponse": {
|
||||||
|
"DetalleLineas": detalle_lineas,
|
||||||
|
"MensajeParadero": "No considerar, uso futuro"
|
||||||
|
}
|
||||||
|
})
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.decorators import action
|
||||||
|
from .. import models, serializers
|
||||||
|
|
||||||
|
class LetreroLUR_ViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.LetreroLUR.objects.all()
|
||||||
|
serializer_class = serializers.LetreroLUR_Serializer
|
|
@ -0,0 +1,116 @@
|
||||||
|
|
||||||
|
from rest_framework import viewsets
|
||||||
|
# from rest_framework.response import Response
|
||||||
|
from rest_framework.decorators import action
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from django.db import connection
|
||||||
|
from .. import models, serializers
|
||||||
|
from django.http import JsonResponse
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class LineaViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Linea.objects.all()
|
||||||
|
serializer_class = serializers.LineaSerializer
|
||||||
|
filter_backends = [DjangoFilterBackend]
|
||||||
|
filterset_fields = ['id_operador', 'route_short_name', 'route_long_name', 'vigente']
|
||||||
|
|
||||||
|
|
||||||
|
@action(detail=False, methods=['get'])
|
||||||
|
def proto(self, request, pk=None):
|
||||||
|
id_paradero = request.GET['id_paradero']
|
||||||
|
|
||||||
|
query = "SELECT json_data \
|
||||||
|
from gtfs_posiciones_json \
|
||||||
|
where stop_id = %s"
|
||||||
|
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute(query, [ id_paradero ])
|
||||||
|
row = cursor.fetchone()
|
||||||
|
|
||||||
|
return JsonResponse(row[0], safe=False)
|
||||||
|
|
||||||
|
|
||||||
|
@action(detail=False, methods=['get'])
|
||||||
|
def paraderos(self, request, pk=None):
|
||||||
|
pk = request.GET['id_linea']
|
||||||
|
|
||||||
|
paraderos = models.Paradero.objects \
|
||||||
|
.filter(vigente=True, lineaparadero__id_linea=pk) \
|
||||||
|
.values('id_paradero','stop_lat','stop_lon','stop_name') \
|
||||||
|
.all()
|
||||||
|
return JsonResponse(list(paraderos), safe=False)
|
||||||
|
|
||||||
|
|
||||||
|
@action(detail=False, methods=['get'])
|
||||||
|
def buses(self, request, pk=None):
|
||||||
|
pk = request.GET['id_linea']
|
||||||
|
|
||||||
|
query = "SELECT distinct \
|
||||||
|
l.route_color, \
|
||||||
|
l.route_text_color, \
|
||||||
|
gp.vehicle_license_plate as Patente_vehiculo, \
|
||||||
|
speed::numeric(5,2) as speed, \
|
||||||
|
gp.longitude::numeric, \
|
||||||
|
gp.latitude::numeric \
|
||||||
|
from gtfs_posiciones gp \
|
||||||
|
inner join linea l on (trim(gp.route_id)||'-'||trim(gp.direction_id::varchar)) = l.id_linea \
|
||||||
|
where l.id_linea = %s"
|
||||||
|
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute(query, [ pk ])
|
||||||
|
rows = cursor.fetchall()
|
||||||
|
|
||||||
|
buses = []
|
||||||
|
for row in rows:
|
||||||
|
buses.append({
|
||||||
|
'route_color': row[0],
|
||||||
|
'route_text_color': row[1],
|
||||||
|
'Patente_vehiculo': row[2],
|
||||||
|
'speed': row[3],
|
||||||
|
'longitude': row[4],
|
||||||
|
'latitude': row[5],
|
||||||
|
})
|
||||||
|
|
||||||
|
return JsonResponse(buses, safe=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@action(detail=False, methods=['get'])
|
||||||
|
def buses_proto(self, request, pk=None):
|
||||||
|
pk = request.GET['id_linea']
|
||||||
|
|
||||||
|
linea = models.Linea.objects \
|
||||||
|
.filter(id_linea=pk) \
|
||||||
|
.first()
|
||||||
|
|
||||||
|
logging.error(linea)
|
||||||
|
|
||||||
|
detalle_buses = []
|
||||||
|
paraderos = models.Paradero.objects \
|
||||||
|
.filter(vigente=True, lineaparadero__id_linea=pk) \
|
||||||
|
.values('id_paradero') \
|
||||||
|
.all()
|
||||||
|
|
||||||
|
query = "SELECT json_data \
|
||||||
|
from gtfs_posiciones_json \
|
||||||
|
where stop_id = %s"
|
||||||
|
|
||||||
|
for p in paraderos:
|
||||||
|
id_paradero = p['id_paradero']
|
||||||
|
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute(query, [ id_paradero ])
|
||||||
|
datajson = cursor.fetchone()
|
||||||
|
|
||||||
|
if datajson != None:
|
||||||
|
buses = list(filter(lambda rowjson: rowjson['Descripcion'] == linea.route_short_name, datajson[0]))
|
||||||
|
for bus in buses:
|
||||||
|
for llegada in bus['Llegadas']:
|
||||||
|
data_bus = {
|
||||||
|
'patente': llegada['patente'],
|
||||||
|
'estimada_gps': llegada['EstimadaGPS'],
|
||||||
|
'distancia_gps': llegada['DistanciaGPS'],
|
||||||
|
}
|
||||||
|
detalle_buses.append(data_bus)
|
||||||
|
|
||||||
|
return JsonResponse(detalle_buses, safe=False)
|
|
@ -0,0 +1,11 @@
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from api.serializers import LineaParaderoSerializer
|
||||||
|
from api.models import LineaParadero
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class LineaParaderoViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = LineaParadero.objects.all()
|
||||||
|
serializer_class = LineaParaderoSerializer
|
||||||
|
filter_backends = [DjangoFilterBackend]
|
||||||
|
filterset_fields = ['id_linea', 'id_paradero']
|
|
@ -0,0 +1,87 @@
|
||||||
|
|
||||||
|
from django.http import JsonResponse
|
||||||
|
from rest_framework.decorators import action, api_view, schema
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.db.models import F, Subquery, Value
|
||||||
|
from django.db.models.functions import Coalesce
|
||||||
|
|
||||||
|
from ..models import Paradero, ParaderoImagen
|
||||||
|
from ..models import Linea, GtfsShape, GtfsTrips
|
||||||
|
from logging import error
|
||||||
|
|
||||||
|
google_api_key = 'AIzaSyDnFO9w_SsodjBuY5tOK8-kQJns_l5klQ4'
|
||||||
|
center = {'lat': -36.8077884, 'lng': -73.0775401}
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
@action(detail=False, methods=['get'])
|
||||||
|
@api_view(['GET'])
|
||||||
|
def paraderos(request):
|
||||||
|
zoom = 17
|
||||||
|
marks = []
|
||||||
|
|
||||||
|
paraderos = Paradero.objects.filter(vigente=True)
|
||||||
|
for p in paraderos:
|
||||||
|
|
||||||
|
marks.append({
|
||||||
|
'position': { 'lat': p.stop_lat, 'lng': p.stop_lon },
|
||||||
|
'id_paradero': p.id_paradero,
|
||||||
|
'title': 'Paradero #' + str(p.id_paradero),
|
||||||
|
'location': p.stop_name,
|
||||||
|
'id_comuna': p.id_comuna,
|
||||||
|
'id_tipo_paradero': p.id_tipo_paradero,
|
||||||
|
})
|
||||||
|
|
||||||
|
return JsonResponse({
|
||||||
|
'google_api_key': google_api_key,
|
||||||
|
'zoom': zoom,
|
||||||
|
'center': center,
|
||||||
|
'marks': marks
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
@action(detail=False, methods=['get'])
|
||||||
|
@api_view(['GET'])
|
||||||
|
def rutas(request):
|
||||||
|
id_linea = request.GET.get('id_linea')
|
||||||
|
|
||||||
|
"""
|
||||||
|
SELECT gs.shape_pt_lat, gs.shape_pt_lon, gs.shape_pt_sequence
|
||||||
|
FROM gtfs_shape gs
|
||||||
|
WHERE gs.id_shape in (
|
||||||
|
SELECT DISTINCT id_shape
|
||||||
|
FROM gtfs_trips gt
|
||||||
|
WHERE gt.id_linea = '2990'
|
||||||
|
)
|
||||||
|
ORDER BY gs.id_shape, gs.sequence_coalesce
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
# Subquery para obtener los id_shape distintos de gtfs_trips
|
||||||
|
subquery = GtfsTrips.objects.filter(id_linea = id_linea).values('id_shape').distinct()
|
||||||
|
|
||||||
|
# Consulta principal con inner join y ordenamiento
|
||||||
|
queryset = GtfsShape.objects.annotate(
|
||||||
|
id_shape_subquery=Subquery(subquery),
|
||||||
|
shape_pt_sequence_coalesce=Coalesce('shape_pt_sequence', Value(0))
|
||||||
|
).filter(id_shape=F('id_shape_subquery')).order_by('shape_pt_sequence_coalesce')
|
||||||
|
|
||||||
|
result = queryset.values('shape_pt_lat', 'shape_pt_lon', 'shape_pt_sequence')
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Subconsulta interna
|
||||||
|
subquery = GtfsTrips.objects.filter(id_linea=id_linea).values('id_shape').distinct()[:1]
|
||||||
|
|
||||||
|
# Consulta principal
|
||||||
|
query = GtfsShape.objects.filter(id_shape__in=subquery).order_by('id_shape', 'shape_pt_sequence')
|
||||||
|
|
||||||
|
# Obtener los campos requeridos
|
||||||
|
query = query.values('shape_pt_lat', 'shape_pt_lon', 'shape_pt_sequence')
|
||||||
|
|
||||||
|
# Ejecutar la consulta
|
||||||
|
resultados = query.all()
|
||||||
|
|
||||||
|
return JsonResponse({
|
||||||
|
'google_api_key': google_api_key,
|
||||||
|
'positions': list(resultados)
|
||||||
|
})
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.decorators import action
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from .. import models, serializers
|
||||||
|
|
||||||
|
class OperadorViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Operador.objects.all()
|
||||||
|
serializer_class = serializers.OperadorSerializer
|
||||||
|
filter_backends = [DjangoFilterBackend]
|
||||||
|
filterset_fields = ['id_region', 'nombre_operador', 'vigente']
|
|
@ -0,0 +1,24 @@
|
||||||
|
from django.http import JsonResponse
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from api.serializers import ParaderoSerializer
|
||||||
|
from api.models import Paradero
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class ParaderoViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Paradero.objects.all()
|
||||||
|
serializer_class = ParaderoSerializer
|
||||||
|
|
||||||
|
|
||||||
|
def info_public(request, pk):
|
||||||
|
|
||||||
|
if hasattr(request.META,'HTTP_REFERER'):
|
||||||
|
referer = request.META['HTTP_REFERER']
|
||||||
|
else:
|
||||||
|
protocol = request.scheme
|
||||||
|
host = request.META['HTTP_HOST']
|
||||||
|
port = request.META['SERVER_PORT']
|
||||||
|
referer = f'{protocol}://{host}:{port}'
|
||||||
|
|
||||||
|
return JsonResponse({
|
||||||
|
'url_public': f'{referer}/public/infoStop?codigoParadero={pk}'
|
||||||
|
})
|
|
@ -0,0 +1,34 @@
|
||||||
|
from rest_framework import generics, viewsets
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from django.http import HttpResponse, JsonResponse
|
||||||
|
from api.models import ParaderoImagen, Paradero
|
||||||
|
from api.serializers import ParaderoImagenSerializer
|
||||||
|
|
||||||
|
class ParaderoImagenListView(generics.ListAPIView, viewsets.ModelViewSet):
|
||||||
|
queryset = ParaderoImagen.objects.all()
|
||||||
|
serializer_class = ParaderoImagenSerializer
|
||||||
|
filter_backends = [DjangoFilterBackend]
|
||||||
|
filterset_fields = ['id_paradero', 'content_type']
|
||||||
|
|
||||||
|
def retrieve(self, request, pk):
|
||||||
|
data = ParaderoImagen.objects.filter(id_paradero_imagen = pk).first()
|
||||||
|
response = HttpResponse(content_type=data.content_type)
|
||||||
|
response['Content-Disposition'] = 'inline'
|
||||||
|
response.write(data.imagen)
|
||||||
|
return response
|
||||||
|
|
||||||
|
def create(self, request, pk = None):
|
||||||
|
imagen = request.FILES['imagen']
|
||||||
|
id_paradero = request.data.get('id_paradero')
|
||||||
|
content_type = imagen.content_type
|
||||||
|
imagen_bytea = imagen.read()
|
||||||
|
|
||||||
|
paradero = Paradero.objects.filter(id_paradero = id_paradero).first()
|
||||||
|
|
||||||
|
paradero_imagen = ParaderoImagen(
|
||||||
|
id_paradero = paradero,
|
||||||
|
imagen = imagen_bytea,
|
||||||
|
content_type = content_type
|
||||||
|
)
|
||||||
|
paradero_imagen.save()
|
||||||
|
return JsonResponse({ 'ok': True })
|
|
@ -0,0 +1,20 @@
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from .. import models, serializers
|
||||||
|
from django.http import HttpResponse
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class PersonaViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Persona.objects.all()
|
||||||
|
serializer_class = serializers.PersonaSerializer
|
||||||
|
|
||||||
|
def destroy(self, request, pk=None):
|
||||||
|
return HttpResponse('No permitido eliminar', status=405)
|
||||||
|
|
||||||
|
def create(self, request):
|
||||||
|
try:
|
||||||
|
super().create(request)
|
||||||
|
except Exception as e:
|
||||||
|
# logging.warning(e.detail['rut'][0])
|
||||||
|
if e.detail['rut']:
|
||||||
|
return HttpResponse(e.detail['rut'][0], status=400)
|
||||||
|
return HttpResponse(e, status=400)
|
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from rest_framework.decorators import action, api_view
|
||||||
|
from api.utils import gtfs_realtime_pb2
|
||||||
|
from project.settings import BASE_DIR
|
||||||
|
from django.http import JsonResponse
|
||||||
|
import logging
|
||||||
|
|
||||||
|
def status(request):
|
||||||
|
nombre_archivo_proto = f'{BASE_DIR}/api/utils/demo.proto'
|
||||||
|
with open(nombre_archivo_proto, 'rb') as proto_file:
|
||||||
|
feed = gtfs_realtime_pb2.FeedMessage()
|
||||||
|
feed.ParseFromString(proto_file.read())
|
||||||
|
|
||||||
|
data = {} #get_object(feed)
|
||||||
|
# logging.error(dir(feed))
|
||||||
|
# logging.error(feed.header)
|
||||||
|
# logging.error(dir(feed.entity))
|
||||||
|
logging.error(feed.entity[0])
|
||||||
|
# logging.error(dir(feed.entity[0].trip_update))
|
||||||
|
|
||||||
|
return JsonResponse(data, safe=False)
|
||||||
|
|
||||||
|
|
||||||
|
def get_object(obj1, obj2 = {}, level = 1):
|
||||||
|
attributes = dir(obj1)
|
||||||
|
for attr in attributes:
|
||||||
|
if attr[0:1] != '_':
|
||||||
|
try:
|
||||||
|
for elem in obj1[attr]:
|
||||||
|
logging.error(elem)
|
||||||
|
except:
|
||||||
|
logging.error(attr)
|
||||||
|
pass
|
||||||
|
return obj2
|
||||||
|
|
||||||
|
|
||||||
|
def is_subscriptable(obj):
|
||||||
|
return hasattr(obj, '__getitem__')
|
||||||
|
|
||||||
|
def is_iterable(obj):
|
||||||
|
try:
|
||||||
|
iter(obj)
|
||||||
|
return True
|
||||||
|
except TypeError:
|
||||||
|
return False
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from .. import models, serializers
|
||||||
|
|
||||||
|
class RegionViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Region.objects.all()
|
||||||
|
serializer_class = serializers.RegionSerializer
|
|
@ -0,0 +1,6 @@
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from .. import models, serializers
|
||||||
|
|
||||||
|
class RolViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Rol.objects.all()
|
||||||
|
serializer_class = serializers.RolSerializer
|
|
@ -0,0 +1,16 @@
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from .. import models, serializers
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class RolAplicacionViewSet(viewsets.ModelViewSet):
|
||||||
|
serializer_class = serializers.RolAplicacionSerializer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
id_rol = self.request.query_params.get('id_rol') # Obtener el valor del parámetro id_rol desde la solicitud
|
||||||
|
|
||||||
|
if id_rol is not None:
|
||||||
|
return models.RolAplicacion.objects.filter(id_rol=id_rol)
|
||||||
|
|
||||||
|
return models.RolAplicacion.objects.all()
|
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from .. import models, serializers
|
||||||
|
|
||||||
|
class TipoTratamientoPersonaViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.TipoTratamientoPersona.objects.all()
|
||||||
|
serializer_class = serializers.TipoTratamientoPersonaSerializer
|
||||||
|
|
||||||
|
class TipoDispositivoViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.TipoDispositivo.objects.all()
|
||||||
|
serializer_class = serializers.TipoDispositivoSerializer
|
||||||
|
|
||||||
|
class TipoParaderoViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.TipoParadero.objects.all()
|
||||||
|
serializer_class = serializers.TipoParaderoSerializer
|
||||||
|
|
||||||
|
class TipoTransporteViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.TipoTransporte.objects.all()
|
||||||
|
serializer_class = serializers.TipoTransporteSerializer
|
||||||
|
|
||||||
|
class TipoVehiculoViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.TipoVehiculo.objects.all()
|
||||||
|
serializer_class = serializers.TipoVehiculoSerializer
|
|
@ -0,0 +1,151 @@
|
||||||
|
|
||||||
|
from django.db import transaction
|
||||||
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
from rest_framework import viewsets
|
||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
from .. import models, schemas, serializers
|
||||||
|
import json
|
||||||
|
import datetime
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class UsuarioViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = models.Usuario.objects.all()
|
||||||
|
serializer_class = serializers.UsuarioSerializer
|
||||||
|
schema = schemas.UsuarioSchema()
|
||||||
|
|
||||||
|
def retrieve(self, request, pk=None):
|
||||||
|
data = super().retrieve(request, pk)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def create(self, request):
|
||||||
|
try:
|
||||||
|
with transaction.atomic():
|
||||||
|
input = json.loads(request.body)
|
||||||
|
|
||||||
|
# validaciones se realiza a nivel del model
|
||||||
|
|
||||||
|
persona = models.Persona.objects.filter(rut = input['rut']).first()
|
||||||
|
id_tipo_tratamiento = input.get('id_tipo_tratamiento',None)
|
||||||
|
if not id_tipo_tratamiento:
|
||||||
|
id_tipo_tratamiento = None
|
||||||
|
|
||||||
|
if not persona:
|
||||||
|
persona = models.Persona(
|
||||||
|
rut = input['rut'],
|
||||||
|
dv = input['dv'],
|
||||||
|
nombres = input['nombres'],
|
||||||
|
apellido_a = input.get('apellido_a',None),
|
||||||
|
apellido_b = input.get('apellido_b',None),
|
||||||
|
email = input.get('email',None),
|
||||||
|
id_tipo_tratamiento = id_tipo_tratamiento
|
||||||
|
)
|
||||||
|
persona.save()
|
||||||
|
else:
|
||||||
|
persona.nombres = input['nombres']
|
||||||
|
persona.apellido_a = input.get('apellido_a',None)
|
||||||
|
persona.apellido_b = input.get('apellido_b',None)
|
||||||
|
persona.email = input.get('email',None)
|
||||||
|
persona.id_tipo_tratamiento = id_tipo_tratamiento
|
||||||
|
persona.save()
|
||||||
|
|
||||||
|
usuario = models.Usuario(
|
||||||
|
rut = persona,
|
||||||
|
login = input['login'],
|
||||||
|
vigente = input.get('vigente', False),
|
||||||
|
)
|
||||||
|
usuario.save()
|
||||||
|
|
||||||
|
logging.error(f'clave = {input["clave"]}')
|
||||||
|
if input['clave']:
|
||||||
|
logging.error('Modificar clave de usuario')
|
||||||
|
clave = models.UsuarioClave.objects.filter(login = usuario.login).first()
|
||||||
|
if clave:
|
||||||
|
logging.error('Clave Usuario ya existe')
|
||||||
|
clave.clave_anterior = clave.clave
|
||||||
|
clave.clave = input['clave']
|
||||||
|
clave.fecha_modificacion = datetime.datetime.now()
|
||||||
|
clave.save()
|
||||||
|
else:
|
||||||
|
logging.error('Clave Usuario se creará')
|
||||||
|
clave = models.UsuarioClave(
|
||||||
|
login = usuario.login,
|
||||||
|
clave = input['clave'],
|
||||||
|
fecha_modificacion = datetime.datetime.now()
|
||||||
|
)
|
||||||
|
clave.save()
|
||||||
|
|
||||||
|
return Response({
|
||||||
|
'rut': persona.rut,
|
||||||
|
'dv': persona.dv,
|
||||||
|
'nombres': persona.nombres,
|
||||||
|
'apellido_a': persona.apellido_a,
|
||||||
|
'apellido_b': persona.apellido_b,
|
||||||
|
'email': persona.email,
|
||||||
|
'login': usuario.login,
|
||||||
|
'vigente': usuario.vigente,
|
||||||
|
})
|
||||||
|
|
||||||
|
except ValueError as e:
|
||||||
|
transaction.rollback()
|
||||||
|
return HttpResponse(str(e), status = 400)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
transaction.rollback()
|
||||||
|
print(e)
|
||||||
|
return HttpResponse(str(e), status = 500)
|
||||||
|
|
||||||
|
def update(self, request, *args, **kwargs):
|
||||||
|
input = json.loads(request.body)
|
||||||
|
logging.error(input)
|
||||||
|
try:
|
||||||
|
pk = input['rut']
|
||||||
|
with transaction.atomic():
|
||||||
|
|
||||||
|
# validaciones se realiza a nivel del model
|
||||||
|
|
||||||
|
persona = models.Persona.objects.filter(rut = pk).first()
|
||||||
|
|
||||||
|
usuario = models.Usuario.objects.filter(rut = pk).first()
|
||||||
|
usuario.vigente = input.get('vigente', False)
|
||||||
|
usuario.save()
|
||||||
|
|
||||||
|
logging.error(f'clave = {input["clave"]}')
|
||||||
|
if input['clave']:
|
||||||
|
logging.error('Modificar clave de usuario')
|
||||||
|
clave = models.UsuarioClave.objects.filter(login = usuario.login).first()
|
||||||
|
if clave:
|
||||||
|
logging.error('Clave Usuario ya existe')
|
||||||
|
clave.clave_anterior = clave.clave
|
||||||
|
clave.clave = input['clave']
|
||||||
|
clave.fecha_modificacion = datetime.datetime.now()
|
||||||
|
clave.save()
|
||||||
|
else:
|
||||||
|
logging.error('Clave Usuario se creará')
|
||||||
|
clave = models.UsuarioClave(
|
||||||
|
login = usuario,
|
||||||
|
clave = input['clave'],
|
||||||
|
fecha_modificacion = datetime.datetime.now()
|
||||||
|
)
|
||||||
|
clave.save()
|
||||||
|
|
||||||
|
return Response({
|
||||||
|
'rut': persona.rut,
|
||||||
|
'dv': persona.dv,
|
||||||
|
'nombres': persona.nombres,
|
||||||
|
'apellido_a': persona.apellido_a,
|
||||||
|
'apellido_b': persona.apellido_b,
|
||||||
|
'email': persona.email,
|
||||||
|
'login': usuario.login,
|
||||||
|
'vigente': usuario.vigente,
|
||||||
|
})
|
||||||
|
|
||||||
|
except ValueError as e:
|
||||||
|
transaction.rollback()
|
||||||
|
return HttpResponse(str(e), status = 400)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
transaction.rollback()
|
||||||
|
print(e)
|
||||||
|
return HttpResponse(str(e), status = 500)
|
After Width: | Height: | Size: 9.7 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 36 KiB |
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>...</title>
|
||||||
|
<script type="module" crossorigin src="/assets/index-8b0562d6.js"></script>
|
||||||
|
<link rel="stylesheet" href="/assets/index-f6f10183.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
"""Django's command-line utility for administrative tasks."""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Run administrative tasks."""
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
|
||||||
|
try:
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
except ImportError as exc:
|
||||||
|
raise ImportError(
|
||||||
|
"Couldn't import Django. Are you sure it's installed and "
|
||||||
|
"available on your PYTHONPATH environment variable? Did you "
|
||||||
|
"forget to activate a virtual environment?"
|
||||||
|
) from exc
|
||||||
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
ASGI config for project project.
|
||||||
|
|
||||||
|
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
|
||||||
|
|
||||||
|
application = get_asgi_application()
|
|
@ -0,0 +1,172 @@
|
||||||
|
"""
|
||||||
|
Django settings for project project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 4.2.2.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from decouple import config
|
||||||
|
|
||||||
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production
|
||||||
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
|
SECRET_KEY = 'django-insecure-ozq@8*t6cy&$lmu@qsvz+l6omsfncj6r1w)s**rtl3vd&j8_#b'
|
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = [ '*' ]
|
||||||
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'rest_framework',
|
||||||
|
'coreapi',
|
||||||
|
'corsheaders',
|
||||||
|
'django_filters',
|
||||||
|
'api',
|
||||||
|
]
|
||||||
|
|
||||||
|
MIDDLEWARE = [
|
||||||
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
'corsheaders.middleware.CorsMiddleware',
|
||||||
|
'api.middlewares.ApiMiddleware',
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'project.urls'
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'DIRS': [ BASE_DIR / 'dist' ],
|
||||||
|
'APP_DIRS': True,
|
||||||
|
'OPTIONS': {
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
WSGI_APPLICATION = 'project.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
'HOST': config('DBHOST', 'localhost'),
|
||||||
|
'PORT': config('DBPORT', 5432),
|
||||||
|
'USER': config('DBUSER','postgres'),
|
||||||
|
'PASSWORD': config('DBPASS','password'),
|
||||||
|
'NAME': config('DBNAME','database'),
|
||||||
|
'OPTIONS': {
|
||||||
|
'options': '-c search_path=' + config('DBSCHEMA', 'public')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'es-cl'
|
||||||
|
|
||||||
|
TIME_ZONE = 'America/Santiago'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_URL = 'static/'
|
||||||
|
|
||||||
|
# Default primary key field type
|
||||||
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
REST_FRAMEWORK = {
|
||||||
|
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
|
||||||
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
|
||||||
|
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend', 'rest_framework.filters.OrderingFilter'],
|
||||||
|
}
|
||||||
|
CORS_ORIGIN_ALLOW_ALL = True
|
||||||
|
# CORS_ORIGIN_ALLOW_ALL = False
|
||||||
|
# CORS_ORIGIN_WHITELIST = [
|
||||||
|
# "http://localhost:3000",
|
||||||
|
# "http://ubuntu.home:3000",
|
||||||
|
# "http://transporte.hz.kursor.cl",
|
||||||
|
# "http://transporte-backend.hz.kursor.cl",
|
||||||
|
# ]
|
||||||
|
|
||||||
|
|
||||||
|
# PARA VISUALIZAR LAS SENTENCIAS SQL QUE SE REALIZAN
|
||||||
|
"""
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'handlers': {
|
||||||
|
'console': {
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
'django.db.backends': {
|
||||||
|
'handlers': ['console'],
|
||||||
|
'level': 'DEBUG', # Puedes ajustar el nivel de registro según tu necesidad.
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
"""
|
|
@ -0,0 +1,36 @@
|
||||||
|
"""
|
||||||
|
URL configuration for project project.
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
||||||
|
Examples:
|
||||||
|
Function views
|
||||||
|
1. Add an import: from my_app import views
|
||||||
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||||
|
Class-based views
|
||||||
|
1. Add an import: from other_app.views import Home
|
||||||
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||||
|
Including another URLconf
|
||||||
|
1. Import the include() function: from django.urls import include, path
|
||||||
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
|
"""
|
||||||
|
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import path, include
|
||||||
|
from rest_framework.documentation import include_docs_urls
|
||||||
|
from django.conf import settings
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
from .views import frontend
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
# FRONTEND
|
||||||
|
path('', frontend, name='home'),
|
||||||
|
|
||||||
|
# BACKEND
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
path('api/', include('api.urls')),
|
||||||
|
path('docs/', include_docs_urls(title = 'API Documentation')),
|
||||||
|
]
|
||||||
|
|
||||||
|
urlpatterns += static('assets/', document_root=f'{settings.BASE_DIR}/dist/assets')
|
||||||
|
urlpatterns += static('avatars/', document_root=f'{settings.BASE_DIR}/dist/avatars')
|
|
@ -0,0 +1,7 @@
|
||||||
|
from django.template.loader import get_template
|
||||||
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
def frontend(request):
|
||||||
|
plantilla = get_template('index.html')
|
||||||
|
documento = plantilla.render()
|
||||||
|
return HttpResponse(documento)
|
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
WSGI config for project project.
|
||||||
|
|
||||||
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
|
@ -0,0 +1,59 @@
|
||||||
|
|
||||||
|
# Dependencias
|
||||||
|
|
||||||
|
* **Django**: framework django
|
||||||
|
* **psycopg2-binary**: permite uso de base datos postgres
|
||||||
|
* **djangorestframework**: permite crear rest api json
|
||||||
|
* **django-cors-headers**: requerido para desarrollo de frontend, permite acceso desde una dominio distinto al backend
|
||||||
|
* **django-filter**: permite filtrar resultado usando paraquetros en querystring
|
||||||
|
* **coreapi**: genera documentación de rest api
|
||||||
|
* **python-decouple**: lee archivo .env para variables de ambiente
|
||||||
|
* **PyJWT**: permite generar json-web-token
|
||||||
|
* **pymongo**: permite conectarse a base datos mongo
|
||||||
|
* **Pillow**: permite imagenar imagenes
|
||||||
|
* **openpyxl**: permite generar archivos excel
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
|
||||||
|
Para iniciar la aplicacion usando docker
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
cd <carpeta del proyecto>/docker
|
||||||
|
docker compose up -d
|
||||||
|
~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Script para levantar aplicacion python
|
||||||
|
|
||||||
|
**start.sh**
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
#!/bin/sh
|
||||||
|
cd /app
|
||||||
|
|
||||||
|
# si no existe directorio de ambiente, se crea
|
||||||
|
if [ ! -d /app/libs ]; then
|
||||||
|
python -m venv libs
|
||||||
|
. ./libs/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
# activar ambiente con dependencias
|
||||||
|
. ./libs/bin/activate
|
||||||
|
|
||||||
|
# si no existe un proyecto inicial, lo crea
|
||||||
|
if [ ! -d /app/project ]; then
|
||||||
|
django-admin startproject project
|
||||||
|
fi
|
||||||
|
|
||||||
|
# iniciar servidor con puerto 8000
|
||||||
|
python /app/project/manage.py runserver 0.0.0.0:8000
|
||||||
|
~~~
|
||||||
|
|
||||||
|
# Extraer models de base de datos
|
||||||
|
|
||||||
|
~~~bash
|
||||||
|
python manage.py inspectdb > api/models.py
|
||||||
|
~~~
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
Django
|
||||||
|
psycopg2-binary
|
||||||
|
djangorestframework
|
||||||
|
django-cors-headers
|
||||||
|
django-filter
|
||||||
|
coreapi
|
||||||
|
python-decouple
|
||||||
|
PyJWT
|
||||||
|
pymongo
|
||||||
|
Pillow
|
||||||
|
openpyxl
|
||||||
|
google
|