Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
update django and drf to latest versions, update models to match
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Rose committed Mar 5, 2019
1 parent 1d3d01e commit 58ec45b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
18 changes: 8 additions & 10 deletions pracman/practice/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-22 00:02
from __future__ import unicode_literals
# Generated by Django 2.1.7 on 2019-03-05 12:39

from django.conf import settings
import django.contrib.auth.models
Expand All @@ -15,7 +13,7 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('auth', '0008_alter_user_username_max_length'),
('auth', '0009_alter_user_last_name_max_length'),
]

operations = [
Expand All @@ -28,7 +26,7 @@ class Migration(migrations.Migration):
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
Expand All @@ -48,7 +46,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('at', models.DateTimeField()),
('created_at', models.DateTimeField(auto_now_add=True)),
('doctor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('doctor', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ('-at',),
Expand All @@ -74,17 +72,17 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='patient',
name='practice',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='practice.Practice'),
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='practice.Practice'),
),
migrations.AddField(
model_name='appointment',
name='patient',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='practice.Patient'),
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='practice.Patient'),
),
migrations.AddField(
model_name='doctor',
name='practice',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='doctors', to='practice.Practice'),
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='doctors', to='practice.Practice'),
),
migrations.AddField(
model_name='doctor',
Expand All @@ -93,6 +91,6 @@ class Migration(migrations.Migration):
),
migrations.AlterUniqueTogether(
name='appointment',
unique_together=set([('doctor', 'at')]),
unique_together={('doctor', 'at')},
),
]
8 changes: 4 additions & 4 deletions pracman/practice/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __str__(self):

class Doctor(AbstractUser):

practice = models.ForeignKey('practice.Practice', null=True, blank=True, related_name='doctors')
practice = models.ForeignKey('practice.Practice', null=True, blank=True, related_name='doctors', on_delete=models.PROTECT)

class Meta:
verbose_name_plural = 'Doctors'
Expand All @@ -24,7 +24,7 @@ class Meta:
class Patient(models.Model):

name = models.CharField(max_length=128)
practice = models.ForeignKey('practice.Practice')
practice = models.ForeignKey('practice.Practice', on_delete=models.PROTECT)
create_at = models.DateTimeField(auto_now_add=True)

objects = querysets.PatientQuerySet.as_manager()
Expand All @@ -35,8 +35,8 @@ def __str__(self):

class Appointment(models.Model):

doctor = models.ForeignKey('practice.Doctor')
patient = models.ForeignKey('practice.Patient')
doctor = models.ForeignKey('practice.Doctor', on_delete=models.PROTECT)
patient = models.ForeignKey('practice.Patient', on_delete=models.PROTECT)
at = models.DateTimeField()
created_at = models.DateTimeField(auto_now_add=True)

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Django==1.11.5
djangorestframework==3.6.4
Django==2.1.7
djangorestframework==3.9.1

0 comments on commit 58ec45b

Please sign in to comment.