2023-06-24 13:35:17 -04:00
# 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
2023-07-17 15:43:15 -04:00
from . validaciones import rut_valido
2023-06-24 13:35:17 -04:00
class Aplicacion ( models . Model ) :
id_aplicacion = models . IntegerField ( primary_key = True )
2023-07-10 18:44:42 -04:00
nombre_app = models . CharField ( max_length = 100 , blank = True , null = True )
2023-06-24 13:35:17 -04:00
vigente = models . BooleanField ( blank = True , null = True )
class Meta :
managed = False
2023-07-10 18:44:42 -04:00
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 . ForeignKey ( ' Vehiculo ' , models . DO_NOTHING , db_column = ' patente ' , blank = True , null = 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 . IntegerField ( primary_key = True )
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 )
class Meta :
managed = False
db_table = ' dispositivo '
class Funcionario ( models . Model ) :
rut = models . ForeignKey ( ' Persona ' , models . DO_NOTHING , db_column = ' rut ' , blank = True , null = 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 GtfsCalendar ( models . Model ) :
2023-08-27 11:08:46 -04:00
service_id = models . CharField ( primary_key = True , max_length = 150 )
2023-07-10 18:44:42 -04:00
monday = models . BooleanField ( blank = True , null = True )
tuesday = models . BooleanField ( blank = True , null = True )
wednesday = models . BooleanField ( blank = True , null = True )
thursday = models . BooleanField ( blank = True , null = True )
friday = models . BooleanField ( blank = True , null = True )
2023-08-27 11:08:46 -04:00
saturday = models . BooleanField ( blank = True , null = True )
2023-07-10 18:44:42 -04:00
sunday = models . BooleanField ( blank = True , null = True )
2023-08-27 11:08:46 -04:00
start_date = models . DateField ( blank = True , null = True )
end_date = models . DateField ( blank = True , null = True )
2023-07-10 18:44:42 -04:00
class Meta :
managed = False
db_table = ' gtfs_calendar '
2023-08-27 11:08:46 -04:00
class GtfsCalendarDates ( models . Model ) :
service_id = models . DecimalField ( primary_key = True , max_digits = 8 , decimal_places = 0 ) # The composite primary key (service_id, date) found, that is not supported. The first column is selected.
date = models . CharField ( max_length = 10 )
exception_type = models . DecimalField ( max_digits = 2 , decimal_places = 0 , blank = True , null = True )
class Meta :
managed = False
db_table = ' gtfs_calendar_dates '
unique_together = ( ( ' service_id ' , ' date ' ) , )
2023-07-10 18:44:42 -04:00
class GtfsFrequencie ( models . Model ) :
2023-08-15 22:22:38 -04:00
id_trip = models . ForeignKey ( ' GtfsTrips ' , models . DO_NOTHING , db_column = ' id_trip ' , blank = True , null = True )
2023-07-10 18:44:42 -04:00
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 GtfsRouteType ( models . Model ) :
2023-08-27 11:08:46 -04:00
id_route_type = models . DecimalField ( primary_key = True , max_digits = 2 , decimal_places = 0 )
2023-07-10 18:44:42 -04:00
descripcion = models . CharField ( max_length = 100 , blank = True , null = True )
class Meta :
managed = False
db_table = ' gtfs_route_type '
class GtfsShape ( models . Model ) :
2023-08-15 22:22:38 -04:00
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 )
2023-07-10 18:44:42 -04:00
shape_pt_sequence = models . IntegerField ( blank = True , null = True )
2023-08-27 11:08:46 -04:00
shape_dist_traveled = models . FloatField ( blank = True , null = True )
id_gtfs_pk = models . AutoField ( primary_key = True )
2023-07-10 18:44:42 -04:00
class Meta :
managed = False
db_table = ' gtfs_shape '
2023-08-27 11:08:46 -04:00
unique_together = ( ( ' id_shape ' , ' shape_dist_traveled ' ) , )
2023-07-10 18:44:42 -04:00
class GtfsStopTimes ( models . Model ) :
2023-08-15 22:22:38 -04:00
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 ' )
2023-07-10 18:44:42 -04:00
arrival_time = models . TimeField ( blank = True , null = True )
stop_sequence = models . IntegerField ( blank = True , null = True )
stop_headsign = models . CharField ( max_length = 100 , blank = True , null = True )
class Meta :
managed = False
db_table = ' gtfs_stop_times '
2023-08-15 22:22:38 -04:00
unique_together = ( ( ' id_paradero ' , ' id_trip ' ) , )
2023-07-10 18:44:42 -04:00
class GtfsTrips ( models . Model ) :
2023-08-15 22:22:38 -04:00
id_trip = models . CharField ( primary_key = True , max_length = 150 )
id_linea = models . CharField ( max_length = 150 , blank = True , null = True )
2023-08-27 11:08:46 -04:00
id_shape = models . IntegerField ( blank = True , null = True )
2023-08-15 22:22:38 -04:00
id_trip_regreso = models . ForeignKey ( ' self ' , models . DO_NOTHING , db_column = ' id_trip_regreso ' , blank = True , null = True )
2023-07-10 18:44:42 -04:00
trip_headsign = models . CharField ( max_length = 100 , blank = True , null = True )
2023-08-27 11:08:46 -04:00
trip_short_name = models . CharField ( max_length = 100 , blank = True , null = True )
direction_id = models . IntegerField ( blank = True , null = True )
service_id = models . DecimalField ( max_digits = 8 , decimal_places = 0 , blank = True , null = True , db_comment = ' de calendario ' )
block_id = models . CharField ( max_length = 50 , blank = True , null = True )
2023-07-10 18:44:42 -04:00
class Meta :
managed = False
db_table = ' gtfs_trips '
2023-10-27 15:11:11 -03:00
class LetreroLUR ( models . Model ) :
codigo = models . CharField ( max_length = 10 , primary_key = True )
linea1 = models . CharField ( max_length = 50 , blank = False , null = False )
linea2 = models . CharField ( max_length = 50 )
linea3 = models . CharField ( max_length = 50 )
linea4 = models . CharField ( max_length = 50 )
bgcolor1 = models . CharField ( max_length = 20 )
color1 = models . CharField ( max_length = 20 )
bgcolor2 = models . CharField ( max_length = 20 )
color2 = models . CharField ( max_length = 20 )
class Meta :
managed = True
db_table = ' letrero_lur '
2023-07-10 18:44:42 -04:00
class Linea ( models . Model ) :
2023-08-27 11:08:46 -04:00
id_linea = models . CharField ( max_length = 150 , primary_key = True )
id_operador = models . ForeignKey ( ' Operador ' , models . DO_NOTHING , db_column = ' id_operador ' , 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 )
2023-07-10 18:44:42 -04:00
class Meta :
managed = False
db_table = ' linea '
class Operador ( models . Model ) :
2023-08-15 22:22:38 -04:00
id_operador = models . CharField ( primary_key = True , max_length = 150 )
2023-07-10 18:44:42 -04:00
id_region = models . ForeignKey ( ' Region ' , models . DO_NOTHING , db_column = ' id_region ' , blank = True , null = True )
vigente = models . BooleanField ( blank = True , null = True )
2023-08-15 22:22:38 -04:00
nombre_operador = models . CharField ( max_length = 150 , blank = True , null = True )
2023-08-27 11:08:46 -04:00
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 )
2023-07-10 18:44:42 -04:00
class Meta :
managed = False
db_table = ' operador '
class Paradero ( models . Model ) :
id_paradero = models . IntegerField ( primary_key = True )
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 )
2023-08-15 22:22:38 -04:00
stop_lat = models . FloatField ( blank = True , null = True )
stop_lon = models . FloatField ( blank = True , null = True )
2023-08-27 11:08:46 -04:00
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 )
2023-07-10 18:44:42 -04:00
class Meta :
managed = False
db_table = ' paradero '
class ParaderoImagen ( models . Model ) :
2023-09-07 11:00:44 -03:00
id_paradero_imagen = models . AutoField ( primary_key = True )
id_paradero = models . ForeignKey ( Paradero , models . DO_NOTHING , db_column = ' id_paradero ' , blank = False , null = False )
imagen = models . BinaryField ( blank = False , null = False )
content_type = models . CharField ( max_length = 50 , blank = False , null = False )
2023-07-10 18:44:42 -04:00
class Meta :
2023-10-09 17:25:35 -03:00
managed = True
2023-07-10 18:44:42 -04:00
db_table = ' paradero_imagen '
2023-06-24 13:35:17 -04:00
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 )
2023-07-10 18:44:42 -04:00
id_comuna = models . ForeignKey ( Comuna , models . DO_NOTHING , db_column = ' id_comuna ' , blank = True , null = True )
2023-06-24 13:35:17 -04:00
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 )
2023-07-10 18:44:42 -04:00
direccion = models . CharField ( max_length = 100 , blank = True , null = True )
2023-06-24 13:35:17 -04:00
class Meta :
managed = False
db_table = ' persona '
2023-07-17 15:43:15 -04:00
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 )
2023-06-24 13:35:17 -04:00
2023-08-15 22:22:38 -04:00
2023-07-10 18:44:42 -04:00
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 '
2023-06-24 13:35:17 -04:00
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 ) :
2023-08-30 00:06:40 -04:00
id_rol_app = models . AutoField ( primary_key = True )
id_aplicacion = models . ForeignKey ( Aplicacion , models . DO_NOTHING , db_column = ' id_aplicacion ' ) # The composite primary key (id_aplicacion, id_rol) found, that is not supported. The first column is selected.
2023-06-24 13:35:17 -04:00
id_rol = models . ForeignKey ( Rol , models . DO_NOTHING , db_column = ' id_rol ' )
solo_visualizar = models . BooleanField ( blank = True , null = True )
class Meta :
managed = False
db_table = ' rol_aplicacion '
unique_together = ( ( ' id_aplicacion ' , ' id_rol ' ) , )
2023-07-10 18:44:42 -04:00
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_dispositivo = models . ForeignKey ( Dispositivo , models . DO_NOTHING , db_column = ' id_dispositivo ' , blank = True , null = True )
id_tipo_dispositivo = models . IntegerField ( blank = True , null = True )
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 ) :
2023-08-15 22:22:38 -04:00
id_tipo_transporte = models . IntegerField ( primary_key = True )
2023-07-10 18:44:42 -04:00
descripcion = models . CharField ( max_length = 50 , blank = True , null = True )
class Meta :
managed = False
db_table = ' tipo_transporte '
2023-06-24 13:35:17 -04:00
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 '
2023-07-10 18:44:42 -04:00
db_table_comment = ' Establece el tratamiento de como dirigirse hacia una persona: \r \n Ejemplo \r \n Señor \r \n Señora \r \n Srta '
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 '
2023-06-24 13:35:17 -04:00
class Usuario ( models . Model ) :
2023-08-27 11:08:46 -04:00
login = models . CharField ( primary_key = True , max_length = 60 )
2023-06-24 13:35:17 -04:00
rut = models . ForeignKey ( Persona , models . DO_NOTHING , db_column = ' rut ' , blank = True , null = True )
vigente = models . BooleanField ( blank = True , null = True )
2023-08-27 11:08:46 -04:00
superuser = models . BooleanField ( blank = True , null = True )
2023-06-24 13:35:17 -04:00
class Meta :
managed = False
db_table = ' usuario '
2023-07-17 15:43:15 -04:00
def save ( self , * args , * * kwargs ) :
# validacion se realiza solo si se esta creando el registro
if self . _state . adding :
condition = models . Q ( login = self . login ) | models . Q ( rut = self . rut )
usuario = Usuario . objects . filter ( condition ) . first ( )
if usuario :
if usuario . login == self . login :
raise Exception ( f " Usuario [ { self . login } ] ya existe! " )
else :
raise Exception ( f " Usuario con RUT [ { self . rut } ] ya existe! " )
super ( ) . save ( * args , * * kwargs )
2023-06-24 13:35:17 -04:00
2023-08-27 11:08:46 -04:00
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 '
2023-06-24 13:35:17 -04:00
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 '
2023-07-10 18:44:42 -04:00
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 . ForeignKey ( Vehiculo , models . DO_NOTHING , db_column = ' patente ' , blank = True , null = True )
2023-08-15 22:22:38 -04:00
id_linea = models . CharField ( max_length = 150 , blank = True , null = True )
2023-07-10 18:44:42 -04:00
vigente = models . BooleanField ( blank = True , null = True )
class Meta :
managed = False
db_table = ' vehiculo_linea '