Commit ef96bdd8 authored by Gab De Jesus's avatar Gab De Jesus

Updated fixtures and prof list to show courses

parent 2f2f54e4
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-07 00:50 # Generated by Django 1.11.5 on 2017-11-16 10:04
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings from django.conf import settings
......
This diff is collapsed.
No preview for this file type
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-07 00:51 # Generated by Django 1.11.5 on 2017-11-16 10:04
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
...@@ -13,6 +13,13 @@ class Migration(migrations.Migration): ...@@ -13,6 +13,13 @@ class Migration(migrations.Migration):
] ]
operations = [ operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=20, unique=True)),
],
),
migrations.CreateModel( migrations.CreateModel(
name='Prof', name='Prof',
fields=[ fields=[
...@@ -21,4 +28,9 @@ class Migration(migrations.Migration): ...@@ -21,4 +28,9 @@ class Migration(migrations.Migration):
('last_name', models.CharField(max_length=20)), ('last_name', models.CharField(max_length=20)),
], ],
), ),
migrations.AddField(
model_name='course',
name='prof',
field=models.ManyToManyField(to='profs.Prof'),
),
] ]
...@@ -13,4 +13,4 @@ class Course(models.Model): ...@@ -13,4 +13,4 @@ class Course(models.Model):
prof = models.ManyToManyField(Prof) prof = models.ManyToManyField(Prof)
def __str__ (self): def __str__ (self):
return self.name + " " + self.prof return self.name
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
<tr> <tr>
<th>Review #</th> <th>Review #</th>
<th>Review By</th> <th>Review By</th>
<th>Course</th>
<th>Professor</th>
<th>Rating</th> <th>Rating</th>
<th>Review</th> <th>Review</th>
<th>Created At</th> <th>Created At</th>
...@@ -21,6 +23,8 @@ ...@@ -21,6 +23,8 @@
<tr> <tr>
<th scope="row">{{ review.id }}</th> <th scope="row">{{ review.id }}</th>
<td>{{ review.user }}</td> <td>{{ review.user }}</td>
<td>{{ review.course }}</td>
<td>{{ review.prof.first_name }} {{review.prof.last_name}}</td>
<td>{{ review.rating }}</td> <td>{{ review.rating }}</td>
<td>{{ review.message }}</td> <td>{{ review.message }}</td>
<td>{{ review.created_at }}</td> <td>{{ review.created_at }}</td>
......
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.urls import reverse from django.urls import reverse
from profs.models import Prof from profs.models import Prof, Course
from profs.forms import ProfForm from profs.forms import ProfForm
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.models import User from django.contrib.auth.models import User
...@@ -50,6 +50,7 @@ def getProf(request, prof_id): ...@@ -50,6 +50,7 @@ def getProf(request, prof_id):
messages.error(request, "Error") messages.error(request, "Error")
return render(request, 'profs/prof.html') return render(request, 'profs/prof.html')
prof = Prof.objects.get(pk=prof_id) prof = Prof.objects.get(pk=prof_id)
reviews = Review.objects.filter(prof=prof) # prof_course = Course.objects.filter(prof__id = prof_id)
reviews = Review.objects.filter(prof = prof)
return render(request, 'profs/prof.html', {'review_form': ReviewForm, 'prof': prof, 'reviews': reviews}) return render(request, 'profs/prof.html', {'review_form': ReviewForm, 'prof': prof, 'reviews': reviews})
# return redirect(reverse('homepage')) # return redirect(reverse('homepage'))
[
{
"model": "profs.Prof",
"pk": 1,
"fields": {
"first_name": "Gab",
"last_name": "De Jesus"
}
},
{
"model": "profs.Prof",
"pk": 2,
"fields": {
"first_name": "Jayce",
"last_name": "Ching"
}
},
{
"model": "profs.Prof",
"pk": 3,
"fields": {
"first_name": "Josh",
"last_name": "Castillo"
}
},
{
"model": "profs.Prof",
"pk": 4,
"fields": {
"first_name": "Nate",
"last_name": "Kibanoff"
}
},
{
"model": "profs.Course",
"pk": 1,
"fields": {
"name": "CS 123",
"prof": [1]
}
},
{
"model": "profs.Course",
"pk": 2,
"fields": {
"name": "CS 129.1",
"prof": [1]
}
},
{
"model": "profs.Course",
"pk": 3,
"fields": {
"name": "CS 152",
"prof": [1]
}
},
{
"model": "profs.Course",
"pk": 4,
"fields": {
"name": "CS 21a",
"prof": [1]
}
},
{
"model": "auth.user",
"pk": 1,
"fields": {
"password": "pbkdf2_sha256$36000$WY4181pJ6jEZ$rLoJ0PUypo1TAohz14uhcw6U2qAMvoWT0ZP9Nx/GrRU=",
"last_login": "2017-11-05T05:17:10.767Z",
"is_superuser": true,
"username": "gab",
"first_name": "",
"last_name": "",
"email": "g@email.com",
"is_staff": true,
"is_active": true,
"date_joined": "2017-11-05T05:16:54.320Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 2,
"fields": {
"password": "pbkdf2_sha256$36000$CTc1bTGpb5XX$gqztJEFTYdhGP46roZA9f81aFgUHduUuhR3DtKJqQWA=",
"last_login": "2017-11-05T05:34:36.228Z",
"is_superuser": false,
"username": "test",
"first_name": "",
"last_name": "",
"email": "gabs@obf.ateneo.edu",
"is_staff": false,
"is_active": true,
"date_joined": "2017-11-05T05:17:50.362Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 3,
"fields": {
"password": "pbkdf2_sha256$36000$q8uanmkHZOq1$t+MMohk2JueruwP+PKKLHQr4bGV8v/8009AbRHLTy1k=",
"last_login": null,
"is_superuser": true,
"username": "Third User",
"first_name": "",
"last_name": "",
"email": "user@gmail.com",
"is_staff": true,
"is_active": true,
"date_joined": "2017-12-06T02:21:29.562Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 4,
"fields": {
"password": "pbkdf2_sha256$36000$q8uanmkHZOq1$t+MMohk2JueruwP+PKKLHQr4bGV8v/8009AbRHLTy1k=",
"last_login": null,
"is_superuser": true,
"username": "JustMonika",
"first_name": "",
"last_name": "",
"email": "lilmonix3@ddlc.moe",
"is_staff": true,
"is_active": true,
"date_joined": "2017-11-06T02:21:29.562Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 5,
"fields": {
"password": "pbkdf2_sha256$36000$B2d7YHRVEhCF$1uNgdZjsQnLHCrAbuyHzoAKME+Zsaxd9sk3WODX/F/o=",
"last_login": null,
"is_superuser": true,
"username": "jayce",
"first_name": "",
"last_name": "",
"email": "jayce@academe.me",
"is_staff": true,
"is_active": true,
"date_joined": "2017-11-06T02:24:13.352Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 6,
"fields": {
"password": "pbkdf2_sha256$36000$OwOm3XlXOtJC$F0HSveJ50XDP+fgYWhXjPYYJ+v5+uptanqOsMnKkup4=",
"last_login": null,
"is_superuser": true,
"username": "josh",
"first_name": "",
"last_name": "",
"email": "josh@academe.me",
"is_staff": true,
"is_active": true,
"date_joined": "2017-11-06T02:24:31.611Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 7,
"fields": {
"password": "pbkdf2_sha256$36000$m4DYavykXw30$nh9VdgTie8k8mz/qlrXpEZLeRHDKGUGE6LB1nGq/eUk=",
"last_login": null,
"is_superuser": true,
"username": "nate",
"first_name": "",
"last_name": "",
"email": "nate@academe.me",
"is_staff": true,
"is_active": true,
"date_joined": "2017-11-06T02:30:32.780Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 8,
"fields": {
"password": "pbkdf2_sha256$36000$9IKkqXDMimF6$n5bShF22TKEIabIz23rAds6c9vGfvpDeTUoigJqjkss=",
"last_login": null,
"is_superuser": true,
"username": "DjangoUnchained",
"first_name": "",
"last_name": "",
"email": "jjjajango@academe.me",
"is_staff": true,
"is_active": true,
"date_joined": "2017-11-06T02:32:33.714Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 9,
"fields": {
"password": "pbkdf2_sha256$36000$DmSZdYLL3gDk$VA42X4qGTkg57FWKXVs8jbBKpa3x26S/1yfEMuLVBj4=",
"last_login": null,
"is_superuser": true,
"username": "NameUser",
"first_name": "",
"last_name": "",
"email": "username@email.com",
"is_staff": true,
"is_active": true,
"date_joined": "2017-11-06T02:33:40.289Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 10,
"fields": {
"password": "pbkdf2_sha256$36000$znKBjfvb5mDG$YyW03jKMHmAsD3bRTnfCHsmhM/TThOhjDcfByvCfG88=",
"last_login": null,
"is_superuser": true,
"username": "WordPass",
"first_name": "",
"last_name": "",
"email": "password@email.com",
"is_staff": true,
"is_active": true,
"date_joined": "2017-11-06T02:34:07.822Z",
"groups": [],
"user_permissions": []
}
},
{
"model":"reviews.Review",
"pk":1,
"fields":{
"message":"legendary",
"created_at":"2017-11-05 05:40:11.094971+08:00",
"rating":5,
"prof":1,
"course":1,
"user":1
}
},
{
"model":"reviews.Review",
"pk":2,
"fields":{
"message":"easy a",
"created_at":"2017-11-05 05:50:11.094971+08:00",
"rating":5,
"prof":1,
"course":1,
"user":2
}
},
{
"model":"reviews.Review",
"pk":3,
"fields":{
"message":"chill",
"created_at":"2017-11-05 06:00:11.094971+08:00",
"rating":5,
"prof":1,
"course":1,
"user":3
}
},
{
"model":"reviews.Review",
"pk":4,
"fields":{
"message":"load rev",
"created_at":"2017-11-05 06:10:11.094971+08:00",
"rating":1,
"prof":1,
"course":1,
"user":1
}
},
{
"model":"reviews.Review",
"pk":5,
"fields":{
"message":"Easy A prof",
"created_at":"2017-11-05 06:20:11.094971+08:00",
"rating":5,
"prof":1,
"course":1,
"user":2
}
},
{
"model":"reviews.Review",
"pk":6,
"fields":{
"message":"mabait",
"created_at":"2017-11-05 06:30:11.094971+08:00",
"rating":5,
"prof":1,
"course":1,
"user":3
}
},
{
"model":"reviews.Review",
"pk":7,
"fields":{
"message":"explains really well",
"created_at":"2017-11-05 06:40:11.094971+08:00",
"rating":4,
"prof":1,
"course":1,
"user":1
}
},
{
"model":"reviews.Review",
"pk":8,
"fields":{
"message":"makes a lot of jokes",
"created_at":"2017-11-05 06:50:11.094971+08:00",
"rating":4,
"prof":1,
"course":1,
"user":2
}
},
{
"model":"reviews.Review",
"pk":9,
"fields":{
"message":"friendly with students",
"created_at":"2017-11-05 7:00:11.094971+08:00",
"rating":4,
"prof":1,
"course":1,
"user":3
}
},
{
"model":"reviews.Review",
"pk":10,
"fields":{
"message":"fair in giving grades",
"created_at":"2017-11-05 07:10:11.094971+08:00",
"rating":4,
"prof":1,
"course":1,
"user":1
}
}
]
\ No newline at end of file
[ [
{ {
"model": "profs.Prof", "model": "profs.Prof",
"pk": 1, "pk": 1,
"fields": { "fields": {
"first_name": "Gab", "first_name": "Gab",
"last_name": "De Jesus" "last_name": "De Jesus"
} }
}, },
{ {
"model": "profs.Prof", "model": "profs.Prof",
"pk": 2, "pk": 2,
"fields": { "fields": {
"first_name": "Jayce", "first_name": "Jayce",
"last_name": "Ching" "last_name": "Ching"
} }
}, },
{ {
"model": "profs.Prof", "model": "profs.Prof",
"pk": 3, "pk": 3,
"fields": { "fields": {
"first_name": "Josh", "first_name": "Josh",
"last_name": "Castillo" "last_name": "Castillo"
} }
}, },
{ {
"model": "profs.Prof", "model": "profs.Prof",
"pk": 4, "pk": 4,
"fields": { "fields": {
"first_name": "Nate", "first_name": "Nate",
"last_name": "Kibanoff" "last_name": "Kibanoff"
} }
} }
] ]
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
"created_at":"2017-11-05 05:40:11.094971+08:00", "created_at":"2017-11-05 05:40:11.094971+08:00",
"rating":5, "rating":5,
"prof":1, "prof":1,
"course":1,
"user":1 "user":1
} }
}, },
...@@ -17,7 +18,8 @@ ...@@ -17,7 +18,8 @@
"message":"easy a", "message":"easy a",
"created_at":"2017-11-05 05:50:11.094971+08:00", "created_at":"2017-11-05 05:50:11.094971+08:00",
"rating":5, "rating":5,
"prof":2, "prof":1,
"course":1,
"user":2 "user":2
} }
}, },
...@@ -28,7 +30,8 @@ ...@@ -28,7 +30,8 @@
"message":"chill", "message":"chill",
"created_at":"2017-11-05 06:00:11.094971+08:00", "created_at":"2017-11-05 06:00:11.094971+08:00",
"rating":5, "rating":5,
"prof":3, "prof":1,
"course":1,
"user":3 "user":3
} }
}, },
...@@ -39,7 +42,8 @@ ...@@ -39,7 +42,8 @@
"message":"load rev", "message":"load rev",
"created_at":"2017-11-05 06:10:11.094971+08:00", "created_at":"2017-11-05 06:10:11.094971+08:00",
"rating":1, "rating":1,
"prof":4, "prof":1,
"course":1,
"user":1 "user":1
} }
}, },
...@@ -51,6 +55,7 @@ ...@@ -51,6 +55,7 @@
"created_at":"2017-11-05 06:20:11.094971+08:00", "created_at":"2017-11-05 06:20:11.094971+08:00",
"rating":5, "rating":5,
"prof":1, "prof":1,
"course":1,
"user":2 "user":2
} }
}, },
...@@ -61,7 +66,8 @@ ...@@ -61,7 +66,8 @@
"message":"mabait", "message":"mabait",
"created_at":"2017-11-05 06:30:11.094971+08:00", "created_at":"2017-11-05 06:30:11.094971+08:00",
"rating":5, "rating":5,
"prof":2, "prof":1,
"course":1,
"user":3 "user":3
} }
}, },
...@@ -72,7 +78,8 @@ ...@@ -72,7 +78,8 @@
"message":"explains really well", "message":"explains really well",
"created_at":"2017-11-05 06:40:11.094971+08:00", "created_at":"2017-11-05 06:40:11.094971+08:00",
"rating":4, "rating":4,
"prof":3, "prof":1,
"course":1,
"user":1 "user":1
} }
}, },
...@@ -83,7 +90,8 @@ ...@@ -83,7 +90,8 @@
"message":"makes a lot of jokes", "message":"makes a lot of jokes",
"created_at":"2017-11-05 06:50:11.094971+08:00", "created_at":"2017-11-05 06:50:11.094971+08:00",
"rating":4, "rating":4,
"prof":4, "prof":1,
"course":1,
"user":2 "user":2
} }
}, },
...@@ -95,6 +103,7 @@ ...@@ -95,6 +103,7 @@
"created_at":"2017-11-05 7:00:11.094971+08:00", "created_at":"2017-11-05 7:00:11.094971+08:00",
"rating":4, "rating":4,
"prof":1, "prof":1,
"course":1,
"user":3 "user":3
} }
}, },
...@@ -105,7 +114,8 @@ ...@@ -105,7 +114,8 @@
"message":"fair in giving grades", "message":"fair in giving grades",
"created_at":"2017-11-05 07:10:11.094971+08:00", "created_at":"2017-11-05 07:10:11.094971+08:00",
"rating":4, "rating":4,
"prof":2, "prof":1,
"course":1,
"user":1 "user":1
} }
} }
......
...@@ -15,4 +15,4 @@ class ReviewForm(ModelForm): ...@@ -15,4 +15,4 @@ class ReviewForm(ModelForm):
class Meta: class Meta:
model = Review model = Review
fields = ['message', 'rating', 'prof', 'user'] fields = ['message', 'rating', 'prof', 'course', 'user']
\ No newline at end of file \ No newline at end of file
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-07 00:50 # Generated by Django 1.11.5 on 2017-11-16 10:04
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings from django.conf import settings
...@@ -13,19 +13,11 @@ class Migration(migrations.Migration): ...@@ -13,19 +13,11 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
('profs', '__first__'), ('profs', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
] ]
operations = [ operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=15, unique=True)),
('description', models.CharField(max_length=100)),
],
),
migrations.CreateModel( migrations.CreateModel(
name='Review', name='Review',
fields=[ fields=[
...@@ -34,6 +26,7 @@ class Migration(migrations.Migration): ...@@ -34,6 +26,7 @@ class Migration(migrations.Migration):
('created_at', models.DateTimeField(auto_now_add=True)), ('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(null=True)), ('updated_at', models.DateTimeField(null=True)),
('rating', models.IntegerField(default=5, validators=[django.core.validators.MaxValueValidator(5), django.core.validators.MinValueValidator(0)])), ('rating', models.IntegerField(default=5, validators=[django.core.validators.MaxValueValidator(5), django.core.validators.MinValueValidator(0)])),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='profs.Course')),
('prof', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='profs.Prof')), ('prof', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='profs.Prof')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to=settings.AUTH_USER_MODEL)), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to=settings.AUTH_USER_MODEL)),
], ],
......
...@@ -3,7 +3,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator ...@@ -3,7 +3,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator
from django.contrib.auth.models import User from django.contrib.auth.models import User
# Import profs # Import profs
from profs.models import Prof from profs.models import Prof, Course
# Create your models here. # Create your models here.
class Review(models.Model): class Review(models.Model):
...@@ -15,6 +15,8 @@ class Review(models.Model): ...@@ -15,6 +15,8 @@ class Review(models.Model):
validators = [MaxValueValidator(5), MinValueValidator(0)] validators = [MaxValueValidator(5), MinValueValidator(0)]
) )
prof = models.ForeignKey(Prof, related_name = 'reviews') prof = models.ForeignKey(Prof, related_name = 'reviews')
course = models.ForeignKey(Course, related_name = 'reviews')
# prof_course = models.ForeignKey(Course, related_name='reviews')
user = models.ForeignKey(User, related_name = 'reviews') user = models.ForeignKey(User, related_name = 'reviews')
def __str__ (self): def __str__ (self):
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment