diff --git a/.gitignore b/.gitignore index 3d485cc..0cb3b27 100644 --- a/.gitignore +++ b/.gitignore @@ -59,9 +59,10 @@ target/ # Visual Studio Code Settings .settings/ -# SQLite 3 DB +# SQLite 3 DB & MySQL Backups *.db *.sqlite3 +*.mwb.bak # Node.js modules platforms/desktop/src/clients/admin/node_modules diff --git a/docs/modelo.mwb b/docs/modelo.mwb new file mode 100644 index 0000000..909c13b Binary files /dev/null and b/docs/modelo.mwb differ diff --git a/docs/modelo.pdf b/docs/modelo.pdf new file mode 100644 index 0000000..e5ad5a9 Binary files /dev/null and b/docs/modelo.pdf differ diff --git a/docs/modelo.svg b/docs/modelo.svg new file mode 100644 index 0000000..3012aeb --- /dev/null +++ b/docs/modelo.svg @@ -0,0 +1,5548 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/citasalud/apps/api/serializers.py b/src/citasalud/apps/api/serializers.py index 5c594bb..b47765f 100644 --- a/src/citasalud/apps/api/serializers.py +++ b/src/citasalud/apps/api/serializers.py @@ -6,22 +6,22 @@ class MedicoSerializer(serializers.ModelSerializer): """ Serializador para Médico """ - + class Meta: model = Medico class UsuarioSerializer(serializers.ModelSerializer): - + class Meta: model = Usuario # fields = ('id', 'username', 'profile','is_superuser') - def create(self, validated_data): - profile_data = validated_data.pop('profile') - user = User.objects.create(**validated_data) - Profile.objects.create(user=user, **profile_data) - return user + # def create(self, validated_data): + # profile_data = validated_data.pop('profile') + # user = Usuario.objects.create(**validated_data) + # Profile.objects.create(user=user, **profile_data) + # return user class EspecialidadSerializer(serializers.ModelSerializer): @@ -29,4 +29,4 @@ class EspecialidadSerializer(serializers.ModelSerializer): class Meta: model = Especialidad - fields = ('id', 'nombre') + # fields = ('id', 'nombre') diff --git a/src/citasalud/apps/api/views.py b/src/citasalud/apps/api/views.py index c0009b0..a97d0fd 100644 --- a/src/citasalud/apps/api/views.py +++ b/src/citasalud/apps/api/views.py @@ -4,10 +4,11 @@ from rest_framework import authentication, permissions from .serializers import UsuarioSerializer + class CurrentUserView(APIView): - authentication_classes = (authentication.TokenAuthentication,) + authentication_classes = (authentication.TokenAuthentication, authentication.SessionAuthentication) permission_classes = (permissions.IsAuthenticated,) - + def get(self, request): serializer = UsuarioSerializer(request.user) return Response(serializer.data) diff --git a/src/citasalud/apps/main/_migrations/0001_initial.py b/src/citasalud/apps/main/_migrations/0001_initial.py deleted file mode 100644 index dff84a0..0000000 --- a/src/citasalud/apps/main/_migrations/0001_initial.py +++ /dev/null @@ -1,86 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='CitaMedica', - fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('horario', models.DateTimeField(verbose_name=b'Hora de cita')), - ], - options={ - 'verbose_name': 'Cita m\xe9dica', - 'verbose_name_plural': 'Citas m\xe9dicas', - }, - ), - migrations.CreateModel( - name='Especialidad', - fields=[ - ('id', models.CharField(max_length=5, serialize=False, verbose_name=b'ID Especialidad', primary_key=True)), - ('nombre', models.CharField(max_length=32, verbose_name=b'Nombre')), - ], - options={ - 'ordering': ('id',), - 'verbose_name': 'Especialidad', - 'verbose_name_plural': 'Especialidades', - }, - ), - migrations.CreateModel( - name='Paciente', - fields=[ - ('nombre', models.CharField(max_length=32, verbose_name=b'Nombre')), - ('apellidos', models.CharField(max_length=32, verbose_name=b'Apellidos')), - ('telefono', models.CharField(max_length=9, verbose_name=b'Tel\xc3\xa9fono')), - ('nss', models.DecimalField(serialize=False, verbose_name=b'NSS', primary_key=True, decimal_places=0, max_digits=9)), - ], - options={ - 'verbose_name': 'Paciente', - 'verbose_name_plural': 'Pacientes', - }, - ), - migrations.CreateModel( - name='Personal', - fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('nombre', models.CharField(max_length=32, verbose_name=b'Nombre')), - ('apellidos', models.CharField(max_length=32, verbose_name=b'Apellidos')), - ('telefono', models.CharField(max_length=9, verbose_name=b'Tel\xc3\xa9fono')), - ('nregistropersonal', models.CharField(max_length=5, verbose_name=b'N\xc2\xb0 Registro personal')), - ], - options={ - 'abstract': False, - }, - ), - migrations.CreateModel( - name='Medico', - fields=[ - ('personal_ptr', models.OneToOneField(parent_link=True, auto_created=True, to='main.Personal')), - ('ncolegiado', models.CharField(max_length=5, serialize=False, verbose_name=b'N\xc2\xb0 Colegiado', primary_key=True)), - ('especialidades', models.ManyToManyField(related_name='especialidades', to='main.Especialidad', blank=True)), - ], - options={ - 'ordering': ('ncolegiado',), - 'verbose_name': 'M\xe9dico', - 'verbose_name_plural': 'M\xe9dicos', - }, - bases=('main.personal',), - ), - migrations.AddField( - model_name='citamedica', - name='paciente', - field=models.ForeignKey(to='main.Paciente'), - ), - migrations.AddField( - model_name='citamedica', - name='medico', - field=models.ForeignKey(to='main.Medico'), - ), - ] diff --git a/src/citasalud/apps/main/admin.py b/src/citasalud/apps/main/admin.py index 08ded34..fd4ccfd 100644 --- a/src/citasalud/apps/main/admin.py +++ b/src/citasalud/apps/main/admin.py @@ -2,10 +2,9 @@ from django.contrib import admin from .models import (Usuario, Especialidad, CitaMedica, Medico, - Paciente, Empleado, HistoriaClinica, Examen, - TipoExamen,) -from django.contrib.auth.admin import UserAdmin - + Paciente, Empleado, HistoriaClinica, Examen, + TipoExamen,) +# from django.contrib.auth.admin import UserAdmin admin.site.register(Usuario) admin.site.register(Especialidad) @@ -16,20 +15,3 @@ admin.site.register(HistoriaClinica) admin.site.register(Examen) admin.site.register(TipoExamen) - -# admin.site.register(Usuario, UsuarioAdmin) - -# class PersonalAdmin(admin.ModelAdmin): -# pass - - -# class PacienteAdmin(admin.ModelAdmin): -# pass - - -# class MedicoAdmin(admin.ModelAdmin): -# pass - - -# class CitaMedicaAdmin(admin.ModelAdmin): -# pass diff --git a/src/citasalud/apps/main/fixtures/admins.json b/src/citasalud/apps/main/fixtures/admins.json new file mode 100644 index 0000000..804eb77 --- /dev/null +++ b/src/citasalud/apps/main/fixtures/admins.json @@ -0,0 +1 @@ +[{"fields": {"username": "admin", "fecha_nacimiento": "1994-05-04", "first_name": "Richard", "last_name": "Cotrina", "apellido_materno": "", "is_active": true, "is_superuser": true, "ciudad": "", "is_staff": true, "last_login": null, "avatar": "/media/avatar/sin_imagen.png", "groups": [], "user_permissions": [], "password": "pbkdf2_sha256$20000$Gzp30JhioY4L$NPUURAvJ+7YZgxJavZGlC1voVhHcBedMeCEDsDvh6MU=", "telefono": "", "email": ""}, "model": "main.usuario", "pk": "76086783"}] diff --git a/src/citasalud/apps/main/fixtures/initial_data.json b/src/citasalud/apps/main/fixtures/especialidades.json similarity index 100% rename from src/citasalud/apps/main/fixtures/initial_data.json rename to src/citasalud/apps/main/fixtures/especialidades.json diff --git a/src/citasalud/apps/main/migrations/0001_initial.py b/src/citasalud/apps/main/migrations/0001_initial.py new file mode 100644 index 0000000..d5b8730 --- /dev/null +++ b/src/citasalud/apps/main/migrations/0001_initial.py @@ -0,0 +1,177 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from django.conf import settings +import citasalud.apps.main.customfields + + +class Migration(migrations.Migration): + + dependencies = [ + ('auth', '0006_require_contenttypes_0002'), + ] + + operations = [ + migrations.CreateModel( + name='Usuario', + fields=[ + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(null=True, verbose_name='last login', blank=True)), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('dni', citasalud.apps.main.customfields.DNIField(max_length=8, unique=True, serialize=False, verbose_name=b'DNI', primary_key=True)), + ('username', models.CharField(unique=True, max_length=16, verbose_name=b'Nombre de usuario')), + ('first_name', models.CharField(max_length=32, verbose_name=b'Nombre')), + ('last_name', models.CharField(max_length=16, verbose_name=b'Ap. Paterno')), + ('apellido_materno', models.CharField(max_length=16, verbose_name=b'Ap. Materno')), + ('fecha_nacimiento', models.DateField(verbose_name=b'Fecha de Nacimiento')), + ('telefono', models.CharField(max_length=9, verbose_name=b'Tel\xc3\xa9fono', blank=True)), + ('ciudad', models.CharField(max_length=128, verbose_name=b'Ciudad de origen')), + ('email', models.EmailField(unique=True, max_length=254, verbose_name=b'E-mail', blank=True)), + ('avatar', models.ImageField(default=b'/media/avatar/sin_imagen.png', upload_to=b'avatar', verbose_name=b'Imagen', blank=True)), + ('is_active', models.BooleanField(default=False)), + ('is_staff', models.BooleanField(default=False)), + ('groups', models.ManyToManyField(related_query_name='user', related_name='user_set', to='auth.Group', blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(related_query_name='user', related_name='user_set', to='auth.Permission', blank=True, help_text='Specific permissions for this user.', verbose_name='user permissions')), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='CitaMedica', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('horario', models.DateTimeField(verbose_name=b'Hora de cita')), + ('asistio', models.BooleanField()), + ], + options={ + 'verbose_name': 'Cita m\xe9dica', + 'verbose_name_plural': 'Citas m\xe9dicas', + }, + ), + migrations.CreateModel( + name='Empleado', + fields=[ + ('nregistropersonal', models.DecimalField(serialize=False, verbose_name=b'N\xc2\xb0 Registro de Personal', primary_key=True, decimal_places=0, max_digits=9)), + ('departamento', models.CharField(max_length=32, verbose_name=b'Departamento')), + ('cargo', models.CharField(max_length=32, verbose_name=b'Cargo')), + ], + ), + migrations.CreateModel( + name='Especialidad', + fields=[ + ('id', models.CharField(max_length=5, serialize=False, verbose_name=b'ID Especialidad', primary_key=True)), + ('nombre', models.CharField(max_length=128, verbose_name=b'Nombre')), + ], + options={ + 'ordering': ('id',), + 'verbose_name': 'Especialidad', + 'verbose_name_plural': 'Especialidades', + }, + ), + migrations.CreateModel( + name='Examen', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('fecha_solitud', models.DateField(verbose_name=b'Fecha de Solicitud')), + ('fecha_aplicacion', models.DateField(verbose_name=b'Fecha de aplicaci\xc3\xb3n')), + ('observacion', models.CharField(max_length=256, verbose_name=b'Observacion')), + ], + options={ + 'verbose_name': 'Examen', + 'verbose_name_plural': 'Ex\xe1menes', + }, + ), + migrations.CreateModel( + name='HistoriaClinica', + fields=[ + ('numero', models.CharField(max_length=5, serialize=False, verbose_name=b'N\xc2\xb0 H.C.', primary_key=True)), + ], + options={ + 'verbose_name': 'Historia Cl\xednica', + 'verbose_name_plural': 'Historias Cl\xednicas', + }, + ), + migrations.CreateModel( + name='Paciente', + fields=[ + ('nss', models.DecimalField(serialize=False, verbose_name=b'NSS', primary_key=True, decimal_places=0, max_digits=9)), + ('usuario', models.OneToOneField(related_name='paciente', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'Paciente', + 'verbose_name_plural': 'Pacientes', + }, + ), + migrations.CreateModel( + name='Resultado', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('documento', models.PositiveIntegerField(verbose_name=b'N\xc2\xb0 de Documento Asociado')), + ('descripcion', models.CharField(max_length=256, verbose_name=b'Descripci\xc3\xb3n')), + ('examen', models.ForeignKey(to='main.Examen')), + ], + ), + migrations.CreateModel( + name='TipoExamen', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('nombre', models.CharField(max_length=64, verbose_name=b'Examen')), + ('descripcion', models.CharField(max_length=128, verbose_name=b'Descripci\xc3\xb3n')), + ], + options={ + 'verbose_name': 'Tipo de examen', + 'verbose_name_plural': 'Tipos de examen', + }, + ), + migrations.CreateModel( + name='Medico', + fields=[ + ('empleado_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='main.Empleado')), + ('ncolegiado', models.PositiveIntegerField(verbose_name=b'N\xc2\xb0 Colegiado')), + ('especialidades', models.ManyToManyField(related_name='especialidades', to='main.Especialidad', blank=True)), + ], + options={ + 'ordering': ('ncolegiado',), + 'verbose_name': 'M\xe9dico', + 'verbose_name_plural': 'M\xe9dicos', + }, + bases=('main.empleado',), + ), + migrations.AddField( + model_name='historiaclinica', + name='paciente', + field=models.OneToOneField(to='main.Paciente'), + ), + migrations.AddField( + model_name='examen', + name='historia', + field=models.ForeignKey(to='main.Paciente'), + ), + migrations.AddField( + model_name='examen', + name='tipo_examen', + field=models.ForeignKey(to='main.TipoExamen'), + ), + migrations.AddField( + model_name='empleado', + name='superior', + field=models.ForeignKey(related_name='jefe', to='main.Empleado'), + ), + migrations.AddField( + model_name='empleado', + name='usuario', + field=models.OneToOneField(related_name='personal', to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='citamedica', + name='historia', + field=models.ForeignKey(to='main.HistoriaClinica'), + ), + migrations.AddField( + model_name='citamedica', + name='medico', + field=models.ForeignKey(to='main.Medico'), + ), + ] diff --git a/src/citasalud/apps/main/_migrations/0002_especialidades.py b/src/citasalud/apps/main/migrations/0002_especialidades.py similarity index 94% rename from src/citasalud/apps/main/_migrations/0002_especialidades.py rename to src/citasalud/apps/main/migrations/0002_especialidades.py index 668c747..6c61295 100644 --- a/src/citasalud/apps/main/_migrations/0002_especialidades.py +++ b/src/citasalud/apps/main/migrations/0002_especialidades.py @@ -4,7 +4,7 @@ from django.core.management import call_command fixture_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../fixtures')) -fixture_filename = 'initial_data.json' +fixture_filename = 'especialidades.json' def load_fixture(apps, schema_editor): diff --git a/src/citasalud/apps/main/migrations/0003_admins.py b/src/citasalud/apps/main/migrations/0003_admins.py new file mode 100644 index 0000000..180021b --- /dev/null +++ b/src/citasalud/apps/main/migrations/0003_admins.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from django.db import migrations +import os +from django.core.management import call_command + +fixture_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../fixtures')) +fixture_filename = 'admins.json' + + +def load_fixture(apps, schema_editor): + fixture_file = os.path.join(fixture_dir, fixture_filename) + call_command('loaddata', fixture_file) + + +def unload_fixture(apps, schema_editor): + "Brutally deleting all entries for this model..." + + MyModel = apps.get_model("citasalud", "Usuario") + MyModel.objects.all().delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0002_especialidades'), + ] + + operations = [ + migrations.RunPython(load_fixture, reverse_code=unload_fixture), + ] diff --git a/src/citasalud/apps/main/_migrations/__init__.py b/src/citasalud/apps/main/migrations/__init__.py similarity index 100% rename from src/citasalud/apps/main/_migrations/__init__.py rename to src/citasalud/apps/main/migrations/__init__.py diff --git a/src/citasalud/apps/main/models.py b/src/citasalud/apps/main/models.py index f9ca41f..ecf96e5 100644 --- a/src/citasalud/apps/main/models.py +++ b/src/citasalud/apps/main/models.py @@ -6,10 +6,8 @@ class UsuarioManager(BaseUserManager): - def create_user(self, username, dni, fecha_nacimiento, first_name,last_name,password =None): + def create_user(self, username, dni, fecha_nacimiento, first_name, last_name, password=None): """ - Creates and saves a User with the given email, date of - birth and password. """ if not dni: raise ValueError('Ingrese un n° DNI válido.') @@ -26,12 +24,11 @@ def create_user(self, username, dni, fecha_nacimiento, first_name,last_name,pass user.save(using=self._db) return user - def create_superuser(self,username,dni,fecha_nacimiento, first_name,last_name,password): + def create_superuser(self, username, dni, fecha_nacimiento, first_name, last_name, password): """ - Creates and saves a superuser with the given email, date of - birth and password. """ - user = self.create_user(username, + user = self.create_user( + username, dni=dni, password=password, first_name=first_name, @@ -43,10 +40,10 @@ def create_superuser(self,username,dni,fecha_nacimiento, first_name,last_name,pa user.is_staff = True user.save(using=self._db) return user - + class Usuario(AbstractBaseUser, PermissionsMixin): - dni = DNIField("DNI", unique=True , primary_key= True) + dni = DNIField("DNI", unique=True, primary_key=True) username = models.CharField("Nombre de usuario", max_length=16, unique=True) first_name = models.CharField("Nombre", max_length=32) last_name = models.CharField("Ap. Paterno", max_length=16) @@ -59,13 +56,13 @@ class Usuario(AbstractBaseUser, PermissionsMixin): email = models.EmailField("E-mail", unique=True, blank=True) avatar = models.ImageField("Imagen", upload_to="avatar", null=False, default="/media/avatar/sin_imagen.png", blank=True) - - is_active = models.BooleanField(default = False) - is_staff = models.BooleanField(default = False) + + is_active = models.BooleanField(default=False) + is_staff = models.BooleanField(default=False) objects = UsuarioManager() - - USERNAME_FIELD= 'username' - REQUIRED_FIELDS = ['dni', 'fecha_nacimiento','first_name' ,'last_name' ] + + USERNAME_FIELD = 'username' + REQUIRED_FIELDS = ['dni', 'fecha_nacimiento', 'first_name', 'last_name'] def get_name(self): return self.first_name.split(" ")[0] @@ -91,7 +88,7 @@ class Empleado(models.Model): class Medico(Empleado): ncolegiado = models.PositiveIntegerField("N° Colegiado") especialidades = models.ManyToManyField("Especialidad", blank=True, related_name='especialidades') - + def _tipo(self): return TIPO_MEDICO.ESPECIALISTA if self.especialidades else TIPO_MEDICO.GENERAL tipo = property(_tipo) @@ -107,7 +104,7 @@ class Meta: class Especialidad(models.Model): id = models.CharField("ID Especialidad", max_length=5, primary_key=True) - nombre = models.CharField("Nombre", max_length=64) + nombre = models.CharField("Nombre", max_length=128) def __unicode__(self): return "%s - %s" % (self.id, self.nombre) @@ -133,6 +130,10 @@ class TipoExamen(models.Model): nombre = models.CharField("Examen", max_length=64) descripcion = models.CharField("Descripción", max_length=128) + class Meta: + verbose_name = "Tipo de examen" + verbose_name_plural = "Tipos de examen" + class Resultado(models.Model): examen = models.ForeignKey("Examen") @@ -147,19 +148,27 @@ class Examen(models.Model): observacion = models.CharField("Observacion", max_length=256) historia = models.ForeignKey("Paciente") + class Meta: + verbose_name = "Examen" + verbose_name_plural = "Exámenes" + class Paciente(models.Model): usuario = models.OneToOneField(Usuario, unique=True, related_name="paciente") nss = PrimaryNumberField("NSS", digits=9) - + def __unicode__(self): return "%s (%s)" % (self.usuario.get_short_name(), self.nss) class Meta: verbose_name = "Paciente" verbose_name_plural = "Pacientes" - + class HistoriaClinica(models.Model): numero = models.CharField("N° H.C.", max_length=5, primary_key=True) - paciente = models.OneToOneField("Paciente", unique=True) \ No newline at end of file + paciente = models.OneToOneField("Paciente", unique=True) + + class Meta: + verbose_name = "Historia Clínica" + verbose_name_plural = "Historias Clínicas" diff --git a/src/citasalud/settings/__init__.py b/src/citasalud/settings/__init__.py index fdb0dea..4ea6552 100644 --- a/src/citasalud/settings/__init__.py +++ b/src/citasalud/settings/__init__.py @@ -85,20 +85,17 @@ 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + }, + 'mysql': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'citasalud', + 'USER': 'citasalud', + 'PASSWORD': 'citasalud', + 'HOST': 'dev', + 'PORT': '', } } -#DATABASES = { -# 'default': { -# 'ENGINE': 'django.db.backends.mysql', -# 'NAME': 'citasalud', -# 'USER': 'root', -# 'PASSWORD': 'LU7412369', -# 'HOST': 'dev', -# 'PORT': '', -# } -#} - # Internationalization # https://docs.djangoproject.com/en/1.7/topics/i18n/ diff --git a/src/citasalud/settings/djrf.py b/src/citasalud/settings/djrf.py index 686549a..4a887dc 100644 --- a/src/citasalud/settings/djrf.py +++ b/src/citasalud/settings/djrf.py @@ -2,9 +2,10 @@ # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. 'DEFAULT_PERMISSION_CLASSES': [ - 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' + 'rest_framework.permissions.IsAuthenticated' ], 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.TokenAuthentication', ) }