Commit 1e22e988 authored by Gab De Jesus's avatar Gab De Jesus

Reverted to old commit

parent 0034e011
......@@ -3,6 +3,9 @@ __pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
......@@ -22,12 +25,62 @@ 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
......@@ -37,6 +90,15 @@ ENV/
env.bak/
venv.bak/
# Project specifics
*/__pycache__/
migrations/
\ No newline at end of file
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
\ No newline at end of file
......@@ -23,8 +23,6 @@ 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'),
......@@ -33,7 +31,7 @@ urlpatterns = [
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'^$', academe_views.index, name="homepage"),
url(r'^$', reviews_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,15 +3,14 @@ from django.urls import reverse
from profs.models import Prof
from profs.forms import ProfForm
# Homepage
# Create your views here.
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})
return render(request, 'templates/index.html')
\ No newline at end of file
profs = Prof.objects.all()
return render(request, 'profs/index.html', {'prof_form':ProfForm, 'profs': profs})
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-05 05:15
# Generated by Django 1.11.6 on 2017-11-04 09:28
from __future__ import unicode_literals
from django.conf import settings
......
......@@ -41,7 +41,7 @@ def signup(request):
#set up smtp
s = smtplib.SMTP(host='smtp.gmail.com', port=587)
s.starttls()
MY_ADDRESS = "academe.site@gmail.com"
MY_ADDRESS = "academe.obf@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
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-11-05 05:15
# Generated by Django 1.11.5 on 2017-10-24 01:47
from __future__ import unicode_literals
from django.db import migrations, models
......
......@@ -12,9 +12,7 @@
<h1>New Review</h1>
<form method="POST">
{% csrf_token %}
<p>{{ review_form.message }}</p>
<p>{{ review_form.rating }}</p>
<p>{{ review_form.prof }}</p>
{{ review_form.as_p }}
<button type="submit">Save</button>
</form>
......
......@@ -26,21 +26,11 @@
{% 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>
<form method="POST">
{% csrf_token %}
<p>{{ review_form.message }}</p>
<p>{{ review_form.rating }}</p>
<textarea class="form-control" rows="5" id="comment"></textarea>
<button type="submit" class="btn btn-default">Submit Review</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
......@@ -2,13 +2,12 @@ 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'):
......@@ -20,15 +19,10 @@ def index(request):
# Make a new review
if(request.method=='POST'):
post_values = request.POST.copy()
post_values['user'] = request.user.id
form = ReviewForm(post_values)
form = ReviewForm(request.POST)
if(form.is_valid()):
form.save()
# Go to that profs page
prof_id = post_values['prof']
return redirect(reverse('profs_getProf', args=(prof_id)))
return redirect(reverse('profs_index'))
profs = Prof.objects.all()
return render(request, 'profs/index.html', {'review_form': ReviewForm, 'profs': profs})
......@@ -36,19 +30,6 @@ 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 .models import Course, Review
admin.site.register(Course)
admin.site.register(Review)
\ No newline at end of file
[
{
"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
from django.forms import ModelForm, CharField, TextInput
from django.forms import ModelForm
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
fields = ['message', 'rating', 'prof']
\ No newline at end of file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-05 05:16
# Generated by Django 1.11.6 on 2017-10-10 04:34
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
......@@ -13,17 +12,15 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
('profs', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Course',
name='Prof',
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)),
('first_name', models.CharField(max_length=20)),
('last_name', models.CharField(max_length=20)),
],
),
migrations.CreateModel(
......@@ -34,8 +31,7 @@ class Migration(migrations.Migration):
('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)),
('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-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',
),
]
......@@ -20,7 +20,6 @@ class Review(models.Model):
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
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
......@@ -10,7 +9,6 @@ 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