Skip to content

Commit 9609370

Browse files
author
=Nathanael Armstrong
committed
getting ready to start the last project etc.
1 parent 1fc7f65 commit 9609370

13 files changed

+136
-2
lines changed

mysql/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
path('',include('mysql_course.urls')),
3030
path('',include('mysql_CVB.urls')),
3131
path('',include('mysql_cart.urls')),
32+
path('',include('mysql_clinic.urls')),
3233
# Primarilly used by the mysql_CBV package
3334
path('accounts/',include('django.contrib.auth.urls')),
3435
path('accounts/403', nope_403)

mysql_clinic/__init__.py

Whitespace-only changes.

mysql_clinic/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

mysql_clinic/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class MysqlClinicConfig(AppConfig):
5+
name = 'mysql_clinic'

mysql_clinic/migrations/__init__.py

Whitespace-only changes.

mysql_clinic/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

mysql_clinic/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

mysql_clinic/urls.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.urls import path
2+
from mysql_clinic.views import Clinic_LP
3+
4+
# ▐▓▒░ ͶΔͲΞ ░▒▓▌
5+
6+
urlpatterns = [
7+
path('clinic',Clinic_LP),
8+
]

mysql_clinic/views.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from django.shortcuts import render
2+
from django.views.generic import View, ListView, DetailView, CreateView, UpdateView, DeleteView
3+
from django.http import HttpResponse
4+
5+
# Create your views here.
6+
class Clinic_LP(View):
7+
# we must declare this attribute if the django can pass it in from urls.py
8+
greetingMessage = ''
9+
temp = '<h1>We\'re underconstruction yo!</h1>'
10+
def get(self,request):
11+
self.greetingMessage = '<div>' + self.greetingMessage + '</div>'
12+
return HttpResponse(str(self.temp) + self.greetingMessage)
13+
14+
'''
15+
class ClinicListView(ListView):
16+
model = Students
17+
#default template_name = model_list.html - in our case: "student_list.html"
18+
template_name = 'studentlist.html'
19+
#default context_object_name = model_list - in our case: "student_list"
20+
context_object_name = 'students'
21+
#adding contextual data to the object: https://docs.djangoproject.com/en/3.1/topics/class-based-views/generic-display/
22+
def get_context_data(self, **kwargs):
23+
# Call the base implementation first to get a context
24+
context = super().get_context_data(**kwargs)
25+
# Add in a QuerySet of all the view
26+
context['heading'] = 'Student List'
27+
return context
28+
'''

mysql_hr/migrations/0008_project.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 3.1.5 on 2021-02-02 18:14
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('mysql_hr', '0007_auto_20210125_2208'),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='Project',
15+
fields=[
16+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17+
('projectName', models.CharField(max_length=50)),
18+
('programmers', models.ManyToManyField(to='mysql_hr.Employee')),
19+
],
20+
),
21+
]
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.1.5 on 2021-02-02 18:50
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('mysql_hr', '0008_project'),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='contactPhone',
16+
fields=[
17+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('type', models.CharField(max_length=10)),
19+
('number', models.CharField(max_length=10)),
20+
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mysql_hr.employee')),
21+
],
22+
),
23+
]
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.1.5 on 2021-02-02 21:47
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('mysql_hr', '0009_contactphone'),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Identification',
16+
fields=[
17+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('type', models.CharField(max_length=10)),
19+
('number', models.CharField(max_length=10)),
20+
('employee', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='mysql_hr.employee')),
21+
],
22+
),
23+
]

mysql_hr/models.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ class Employee(models.Model):
88
lastName=models.CharField(max_length=30)
99
salary=models.FloatField()
1010
email=models.CharField(max_length=254)
11-
1211
#anotehr way to display this a certain way in admin...
1312
#def __str__(self):
1413
# return self.email
1514

15+
class Project(models.Model):
16+
projectName = models.CharField(max_length=50)
17+
#many to many reference field
18+
programmers=models.ManyToManyField(Employee)
1619

1720
class Passenger(models.Model):
1821
first=models.CharField(max_length=30, default='', validators=[validators.MinLengthValidator(2, 'must be 2 characters or more.')])
@@ -24,4 +27,17 @@ class Passenger(models.Model):
2427
points=models.FloatField(default=0)
2528

2629
def __str__(self):
27-
return str(self.id) + " | " + str(self.first) + " " + str(self.last) + " ---> " + str(self.points)
30+
return str(self.id) + " | " + str(self.first) + " " + str(self.last) + " ---> " + str(self.points)
31+
32+
class ContactPhone(models.Model):
33+
type=models.CharField(max_length=10)
34+
number=models.CharField(max_length=10)
35+
# on deletions of an employee - the contactPhone should also be deleted.
36+
# ManytoOne relationship via ForeignKey
37+
owner=models.ForeignKey(Employee,on_delete=models.CASCADE, null=False)
38+
39+
class Identification(models.Model):
40+
type=models.CharField(max_length=10)
41+
number=models.CharField(max_length=10)
42+
# on deletions of an employee - the contactPhone should also be deleted.
43+
employee=models.OneToOneField(Employee,on_delete=models.CASCADE)

0 commit comments

Comments
 (0)