Commit 7147e9cb authored by Gab De Jesus's avatar Gab De Jesus

Fixed files from wrong push

parent 1e22e988
......@@ -3,9 +3,6 @@ __pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
......@@ -25,62 +22,12 @@ wheels/
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
.static_storage/
.media/
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
......@@ -90,15 +37,6 @@ ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
\ No newline at end of file
# Project specifics
*/__pycache__/
migrations/
\ No newline at end of file
......@@ -23,15 +23,17 @@ from reviews import views as reviews_views
from profs import views as profs_views
from academe import views as academe_views
urlpatterns = [
url(r'^signup/$', accounts_views.signup, name='signup'),
url(r'^account_activation_sent/$', accounts_views.account_activation_sent, name='account_activation_sent'),
url(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
url(r'^signup/$', accounts_views.signup, name='signup'),
url(r'^account_activation_sent/$', accounts_views.account_activation_sent, name='account_activation_sent'),
url(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
accounts_views.activate, name='activate'),
url(r'^login/$', auth_views.LoginView.as_view(template_name='templates/login.html'), name='login'),
url(r'^logout/$', auth_views.LogoutView.as_view(), name='logout'),
url(r'^login/$', auth_views.LoginView.as_view(template_name='templates/login.html'), name='login'),
url(r'^logout/$', auth_views.LogoutView.as_view(), name='logout'),
url(r'^admin/', admin.site.urls),
url(r'^$', reviews_views.index, name="homepage"),
url(r'^$', academe_views.index, name="homepage"),
url(r'reviews/$', reviews_views.index, name="reviews_index"),
url(r'^prof/$', profs_views.index, name="profs_index"),
url(r'^prof/(?P<prof_id>[0-9]+)/$', profs_views.getProf, name="profs_getProf"),
......
......@@ -3,14 +3,15 @@ from django.urls import reverse
from profs.models import Prof
from profs.forms import ProfForm
# Create your views here.
# Homepage
def index(request):
if(request.method=='POST'):
form = ProfForm(request.POST)
if(form.is_valid()):
form.save()
# Return to profs_index using reverse so only need to change url in settings.py
return redirect(reverse('profs_index'))
# if(request.method=='POST'):
# form = ProfForm(request.POST)
# if(form.is_valid()):
# form.save()
# # Return to profs_index using reverse so only need to change url in settings.py
# return redirect(reverse('profs_index'))
profs = Prof.objects.all()
return render(request, 'profs/index.html', {'prof_form':ProfForm, 'profs': profs})
# profs = Prof.objects.all()
# return render(request, 'profs/index.html', {'prof_form':ProfForm, 'profs': profs})
return render(request, 'templates/index.html')
\ No newline at end of file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-04 09:28
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Profile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email_confirmed', models.BooleanField(default=False)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-07 00:50
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Profile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email_confirmed', models.BooleanField(default=False)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
......@@ -41,7 +41,7 @@ def signup(request):
#set up smtp
s = smtplib.SMTP(host='smtp.gmail.com', port=587)
s.starttls()
MY_ADDRESS = "academe.obf@gmail.com"
MY_ADDRESS = "academe.site@gmail.com"
s.login(MY_ADDRESS, "Thisisthetester")
with open("templates/account_activation_email.txt", encoding="utf-8") as template_file:
......
No preview for this file type
from django.contrib import admin
# Register your models here.
from django.contrib import admin
from .models import Prof
# Register your models here.
admin.site.register(Prof)
\ No newline at end of file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-24 01:47
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Prof',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=20)),
('last_name', models.CharField(max_length=20)),
],
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-07 00:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Prof',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=20)),
('last_name', models.CharField(max_length=20)),
],
),
]
......@@ -12,7 +12,9 @@
<h1>New Review</h1>
<form method="POST">
{% csrf_token %}
{{ review_form.as_p }}
<p>{{ review_form.message }}</p>
<p>{{ review_form.rating }}</p>
<p>{{ review_form.prof }}</p>
<button type="submit">Save</button>
</form>
......
......@@ -2,14 +2,15 @@
{% block content %}
<div>
<h1><center>{{prof.first_name}} {{prof.last_name}}</center></h1>
<h3><center>Reviews</center></h3>
<h4><center>Reviews</center></h4>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Review #</th>
<th>Review By</th>
<th>Rating</th>
<th>Review</th>
<th>Created At</th>
......@@ -19,6 +20,7 @@
{% for review in reviews %}
<tr>
<th scope="row">{{ review.id }}</th>
<td>{{ review.user }}</td>
<td>{{ review.rating }}</td>
<td>{{ review.message }}</td>
<td>{{ review.created_at }}</td>
......@@ -26,11 +28,21 @@
{% endfor %}
</tbody>
</table>
{% if messages %}
{% for message in messages %}
{{ message }}
{% endfor %}
{% endif %}
<div class="form-group">
<label for="comment">Review {{ prof.first_name }} {{ prof.last_name }}</label>
<textarea class="form-control" rows="5" id="comment"></textarea>
<button type="submit" class="btn btn-default">Submit Review</button>
<form method="POST">
{% csrf_token %}
<p>{{ review_form.message }}</p>
<p>{{ review_form.rating }}</p>
<button type="submit" class="btn btn-default">Submit Review</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
......@@ -2,12 +2,13 @@ from django.shortcuts import render, redirect
from django.urls import reverse
from profs.models import Prof
from profs.forms import ProfForm
from django.contrib import messages
from django.contrib.auth.models import User
from reviews.models import Review
from reviews.forms import ReviewForm
from django.contrib.auth.decorators import login_required
# Create your views here.
def index(request):
# Make a prof
# if(request.method=='POST'):
......@@ -19,10 +20,15 @@ def index(request):
# Make a new review
if(request.method=='POST'):
form = ReviewForm(request.POST)
post_values = request.POST.copy()
post_values['user'] = request.user.id
form = ReviewForm(post_values)
if(form.is_valid()):
form.save()
return redirect(reverse('profs_index'))
# Go to that profs page
prof_id = post_values['prof']
return redirect(reverse('profs_getProf', args=(prof_id)))
profs = Prof.objects.all()
return render(request, 'profs/index.html', {'review_form': ReviewForm, 'profs': profs})
......@@ -30,6 +36,19 @@ def index(request):
# Display the page of a prof using id passed through url
@login_required
def getProf(request, prof_id):
# Make a new review for the specific prof
if(request.method=='POST'):
# Insert the current user, and the prof with the id
post_values = request.POST.copy()
post_values['prof'] = prof_id
post_values['user'] = request.user.id
form = ReviewForm(post_values)
if(form.is_valid()):
form.save()
return redirect(reverse('profs_getProf', args=(prof_id)))
else:
messages.error(request, "Error")
return render(request, 'profs/prof.html')
prof = Prof.objects.get(pk=prof_id)
reviews = Review.objects.filter(prof=prof)
return render(request, 'profs/prof.html', {'review_form': ReviewForm, 'prof': prof, 'reviews': reviews})
......
from django.contrib import admin
# Register your models here.
from django.contrib import admin
# Register your models here.
from .models import Course, Review
admin.site.register(Course)
admin.site.register(Review)
\ No newline at end of file
[
{
"model": "reviews.prof",
"model": "profs.Prof",
"pk": 1,
"fields": {
"first_name": "Gab",
......@@ -8,7 +8,7 @@
}
},
{
"model": "reviews.prof",
"model": "profs.Prof",
"pk": 2,
"fields": {
"first_name": "Jayce",
......@@ -16,7 +16,7 @@
}
},
{
"model": "reviews.prof",
"model": "profs.Prof",
"pk": 3,
"fields": {
"first_name": "Josh",
......@@ -24,7 +24,7 @@
}
},
{
"model": "reviews.prof",
"model": "profs.Prof",
"pk": 4,
"fields": {
"first_name": "Nate",
......
[
{
"model":"reviews.Review",
"pk":1,
"fields":{
"message":"legendary",
"created_at":"2017-11-05 05:40:11.094971+08:00",
"rating":5,
"prof":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":2,
"user":2
}
},
{
"model":"reviews.Review",
"pk":3,
"fields":{
"message":"chill",
"created_at":"2017-11-05 06:00:11.094971+08:00",
"rating":5,
"prof":3,
"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":4,
"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,
"user":2
}
},
{
"model":"reviews.Review",
"pk":6,
"fields":{
"message":"mabait",
"created_at":"2017-11-05 06:30:11.094971+08:00",
"rating":5,
"prof":2,
"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":3,
"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":4,
"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,
"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":2,
"user":1
}
}
]
\ No newline at end of file
[
{
"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": []
}
}
]
\ No newline at end of file
from django.forms import ModelForm
from reviews.models import Review
class ReviewForm(ModelForm):
class Meta:
model = Review
fields = ['message', 'rating', 'prof']
\ No newline at end of file
from django.forms import ModelForm, CharField, TextInput
from reviews.models import Review
# Make a custom widget for rating so it can only be 0 - 5
from django.forms import widgets
from django.utils.safestring import mark_safe
# class RatingWidget(widgets.TextInput):
# def render(self, name, value, attrs=None):
# return mark_safe(u'''<span>USD</span>%s''' % (super(RatingWidget, self).render(name, value, attrs)))
class ReviewForm(ModelForm):
# rating = CharField(label='Cost Price Per Unit', widget=RatingWidget, max_length=5)
rating = CharField(widget=TextInput(attrs={'type': 'number','value': 5, 'min': 0, 'max': 5}))
class Meta:
model = Review
fields = ['message', 'rating', 'prof', 'user']
\ No newline at end of file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-10-10 04:34
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Prof',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=20)),
('last_name', models.CharField(max_length=20)),
],
),
migrations.CreateModel(
name='Review',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('message', models.TextField(max_length=4000)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(null=True)),
('rating', models.IntegerField(default=5, validators=[django.core.validators.MaxValueValidator(5), django.core.validators.MinValueValidator(0)])),
('prof', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='reviews.Prof')),
],
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-07 00:50
from __future__ import unicode_literals
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('profs', '__first__'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
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(
name='Review',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('message', models.TextField(max_length=4000)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(null=True)),
('rating', models.IntegerField(default=5, validators=[django.core.validators.MaxValueValidator(5), django.core.validators.MinValueValidator(0)])),
('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)),
],
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-12 04:12
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('reviews', '0001_initial'),
]
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)),
],
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-24 01:47
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('reviews', '0002_course'),
]
operations = [
migrations.AlterField(
model_name='review',
name='prof',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='profs.Prof'),
),
migrations.DeleteModel(
name='Prof',
),
]
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
from django.contrib.auth.models import User
# Import profs
from profs.models import Prof
# Create your models here.
class Course(models.Model):
name = models.CharField(max_length = 15, unique = True)
description = models.CharField(max_length = 100)
class Review(models.Model):
message = models.TextField(max_length = 4000)
created_at = models.DateTimeField(auto_now_add = True)
updated_at = models.DateTimeField(null = True)
rating = models.IntegerField(
default = 5,
validators = [MaxValueValidator(5), MinValueValidator(0)]
)
prof = models.ForeignKey(Prof, related_name = 'reviews')
def __str__ (self):
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
from django.contrib.auth.models import User
# Import profs
from profs.models import Prof
# Create your models here.
class Course(models.Model):
name = models.CharField(max_length = 15, unique = True)
description = models.CharField(max_length = 100)
class Review(models.Model):
message = models.TextField(max_length = 4000)
created_at = models.DateTimeField(auto_now_add = True)
updated_at = models.DateTimeField(null = True)
rating = models.IntegerField(
default = 5,
validators = [MaxValueValidator(5), MinValueValidator(0)]
)
prof = models.ForeignKey(Prof, related_name = 'reviews')
user = models.ForeignKey(User, related_name = 'reviews')
def __str__ (self):
return self.message
\ No newline at end of file
{% extends 'templates/base.html' %}
{% block content %}
<center><h1>Reviews</h1></center>
<table style="border: 1px solid black">
<tr>
<th>Prof Name</th>
<th>Review #</th>
<th>Review By</th>
<th>Professor</th>
<th>Review</th>
<th>Rating</th>
<th>Created At</th>
......@@ -12,6 +15,8 @@
<!-- Create the table rows -->
{% for review in reviews %}
<tr>
<td>{{ review.id }}</td>
<td>{{ review.user }}</td>
<td>{{ review.prof.first_name }} {{ review.prof.last_name }}</td>
<td>{{ review.message }}</td>
<td>{{ review.rating }}</td>
......@@ -22,10 +27,10 @@
</table>
<!-- Make the form for uploading a new review -->
<h1>New review</h1>
<!-- <h1>New review</h1>
<form method="POST">
{% csrf_token %}
{{ upload_form.as_p }}
<button type="submit">Save</button>
</form>
{% endblock %}
\ No newline at end of file
{% endblock %} -->
\ No newline at end of file
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from django.urls import reverse
from django.contrib.auth.models import User
from .models import Review
from profs.models import Prof
from .forms import ReviewForm
......@@ -9,6 +10,7 @@ from .forms import ReviewForm
def index(request):
if(request.method=='POST'):
form = ReviewForm(request.POST)
form['user'] = User.objects.get(pk=request.user.id)
if(form.is_valid()):
form.save()
# Return to reviews index so that no more post on refresh
......
{% extends 'templates/base.html' %}
{% block content %}
<h1><center>Welcome to Academe</center></h1>
{% endblock %}
\ No newline at end of file
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