Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth Lab #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Binary file added hospital_project/doctors/photos/OIP.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions hospital_project/hospital/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'myapp.apps.MyAppConfig'
7 changes: 7 additions & 0 deletions hospital_project/hospital/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from .models import Clinic, Doctor

# Register your models here.

admin.site.register(Clinic)
admin.site.register(Doctor)
9 changes: 9 additions & 0 deletions hospital_project/hospital/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.apps import AppConfig


class HospitalConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'hospital'

def ready(self):
import hospital.signals
34 changes: 34 additions & 0 deletions hospital_project/hospital/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from django import forms
from .models import Profile, Reservation, Clinic, Doctor
from django.contrib.auth.forms import AuthenticationForm

class ProfileForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['name','phone_number', 'address']
widgets = {
'lab_results': forms.Textarea(attrs={'rows': 4}),
'other_info': forms.Textarea(attrs={'rows': 4}),
}

class ReservationForm(forms.ModelForm):
class Meta:
model = Reservation
fields = ['doctor', 'date', 'time_slot']

class CustomLoginForm(AuthenticationForm):
pass

class ClinicForm(forms.ModelForm):
class Meta:
model = Clinic
fields = ['name', 'description', 'working_hours', 'feature_image', 'doctors']

class DoctorForm(forms.ModelForm):
class Meta:
model = Doctor
fields = ['full_name', 'specialization', 'bio', 'photo']
widgets = {
'photo': forms.ClearableFileInput(attrs={'class': 'form-control-file'}),
'clinic': forms.Select(attrs={'class': 'form-control'}),
}
59 changes: 59 additions & 0 deletions hospital_project/hospital/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Generated by Django 5.0.6 on 2024-08-07 08:18

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Doctor',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('full_name', models.CharField(max_length=100)),
('specialization', models.CharField(choices=[('cardiology', 'Cardiology'), ('neurology', 'Neurology'), ('orthopedics', 'Orthopedics'), ('pediatrics', 'Pediatrics'), ('general_practice', 'General Practice')], max_length=100)),
('bio', models.TextField()),
('photo', models.ImageField(upload_to='doctors/photos/')),
],
),
migrations.CreateModel(
name='Clinic',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.TextField()),
('working_hours', models.CharField(choices=[('9 AM - 5 PM', '9 AM - 5 PM'), ('8 AM - 4 PM', '8 AM - 4 PM'), ('10 AM - 6 PM', '10 AM - 6 PM'), ('7 AM - 3 PM', '7 AM - 3 PM')], max_length=100)),
('feature_image', models.ImageField(upload_to='clinics/images/')),
('doctors', models.ManyToManyField(to='hospital.doctor')),
],
),
migrations.CreateModel(
name='Profile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('phone_number', models.CharField(max_length=20)),
('address', models.TextField()),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Reservation',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateField()),
('time_slot', models.TimeField()),
('created_at', models.DateTimeField(auto_now_add=True)),
('clinic', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hospital.clinic')),
('doctor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hospital.doctor')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 5.0.6 on 2024-08-07 16:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('hospital', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='profile',
name='blood_pressure',
field=models.CharField(blank=True, max_length=20, null=True),
),
migrations.AddField(
model_name='profile',
name='lab_results',
field=models.TextField(blank=True, null=True),
),
migrations.AddField(
model_name='profile',
name='other_info',
field=models.TextField(blank=True, null=True),
),
migrations.AddField(
model_name='profile',
name='profile_picture',
field=models.ImageField(blank=True, null=True, upload_to='profiles/'),
),
migrations.AddField(
model_name='profile',
name='pulse',
field=models.CharField(blank=True, max_length=20, null=True),
),
]
18 changes: 18 additions & 0 deletions hospital_project/hospital/migrations/0003_profile_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.6 on 2024-08-07 17:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('hospital', '0002_profile_blood_pressure_profile_lab_results_and_more'),
]

operations = [
migrations.AddField(
model_name='profile',
name='name',
field=models.CharField(default='Default Name', max_length=255),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.0.6 on 2024-08-07 18:09

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('hospital', '0003_profile_name'),
]

operations = [
migrations.RemoveField(
model_name='profile',
name='other_info',
),
migrations.RemoveField(
model_name='profile',
name='profile_picture',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0.6 on 2024-08-07 18:14

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('hospital', '0004_remove_profile_other_info_and_more'),
]

operations = [
migrations.RemoveField(
model_name='profile',
name='blood_pressure',
),
migrations.RemoveField(
model_name='profile',
name='lab_results',
),
migrations.RemoveField(
model_name='profile',
name='pulse',
),
]
Empty file.
60 changes: 60 additions & 0 deletions hospital_project/hospital/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver

# Create your models here.
SPECIALIZATIONS_CHOICES = [
('cardiology', 'Cardiology'),
('neurology', 'Neurology'),
('orthopedics', 'Orthopedics'),
('dermatologist', 'Dermatologist'),
('dentist', 'Dentist'),
]

WORKING_HOURS_CHOICES = [
('9 AM - 5 PM', '9 AM - 5 PM'),
('8 AM - 4 PM', '8 AM - 4 PM'),
('10 AM - 6 PM', '10 AM - 6 PM'),
('7 AM - 3 PM', '7 AM - 3 PM'),
]

class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
name = models.CharField(max_length=255, default='Default Name')
phone_number = models.CharField(max_length=20)
address = models.TextField()

def __str__(self):
return self.user.username

class Doctor(models.Model):
full_name = models.CharField(max_length=100)
specialization = models.CharField(max_length=100, choices=SPECIALIZATIONS_CHOICES)
bio = models.TextField()
photo = models.ImageField(upload_to='doctors/photos/')

def __str__(self):
return self.full_name

class Clinic(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
working_hours = models.CharField(max_length=100, choices=WORKING_HOURS_CHOICES)
feature_image = models.ImageField(upload_to='clinics/images/')
doctors = models.ManyToManyField(Doctor)

def __str__(self):
return self.name

class Reservation(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
clinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
doctor = models.ForeignKey(Doctor, on_delete=models.CASCADE)
date = models.DateField()
time_slot = models.TimeField()
created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
return f'Reservation for {self.user.username} with Dr. {self.doctor.full_name} at {self.clinic.name} on {self.date} at {self.time_slot}'

15 changes: 15 additions & 0 deletions hospital_project/hospital/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from .models import Profile


@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
instance.profile.save()
Binary file added hospital_project/hospital/static/OIP (1).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP (2).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP (3).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP (4).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP (5).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP (6).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP (7).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP (8).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP (9).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/OIP.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/R (1).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/R.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/doctor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hospital_project/hospital/static/download.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading