Skip to content

Commit

Permalink
Update packages & profile image debug
Browse files Browse the repository at this point in the history
  • Loading branch information
javierpelayo committed Apr 1, 2022
1 parent 7f0c420 commit 2b299b2
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ build/
*.egg-info/
*.ini
.flaskenv
pyvenv.cfg
bin/
lib/
5 changes: 4 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
app = Flask(__name__)
# toolbar = DebugToolbarExtension()
limiter = Limiter(key_func=get_remote_address,
default_limits=['200 per day', '50 per hour'])
default_limits=['1000 per day', '200 per hour'])
db = SQLAlchemy()
bcrypt = Bcrypt()
moment = Moment()
Expand All @@ -28,8 +28,11 @@
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(Config)
app.config["TEMPLATES_AUTO_RELOAD"] = True
app.config['MAX_CONTENT_LENGTH'] = 400000000

limiter.init_app(app)
app.app_context().push()
db.init_app(app)
bcrypt.init_app(app)
moment.init_app(app)
Expand Down
7 changes: 6 additions & 1 deletion app/assignments/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@login_required
@course_auth
def assignments(course_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
assignments = Assignment.query.filter_by(course_id=course_id).all()
assignments = sorted(assignments, key=lambda a: a.duedate_time)
Expand All @@ -35,6 +36,7 @@ def assignments(course_id):

if request.method == "GET":
return render_template('assignments.html',
profile_image=profile_image,
course=course,
assignments=assignments,
user_assignments=user_assignments,
Expand All @@ -46,6 +48,7 @@ def assignments(course_id):
@course_auth
@teacher_auth
def new_assignment(course_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
assignmentform = AssignmentForm()
errors = {}
Expand Down Expand Up @@ -139,6 +142,7 @@ def new_assignment(course_id):

elif request.method == "GET":
return render_template('new_assignment.html',
profile_image=profile_image,
course=course,
assignmentform=assignmentform,
title=str(course.title) + " - New Assignment")
Expand All @@ -148,7 +152,7 @@ def new_assignment(course_id):
@login_required
@course_auth
def assignment(course_id, assignment_id):

profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
file = request.files.get("file")
upload = request.form.get("upload")

Expand Down Expand Up @@ -293,6 +297,7 @@ def assignment(course_id, assignment_id):
return redirect(url_for("assignments.assignment", course_id=course.id, assignment_id=assignment.id))
elif request.method == "GET":
return render_template('assignment.html',
profile_image=profile_image,
course=course,
assignment=assignment,
current_time=time(),
Expand Down
8 changes: 8 additions & 0 deletions app/courses/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def dashboard():
@courses_.route('/dashboard/courses', methods=['GET', 'POST'])
@login_required
def courses():
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
teacher_courses = Course.query.filter_by(teacher_id=current_user.id).all()

# Get the student courses
Expand Down Expand Up @@ -90,11 +91,13 @@ def courses():

if request.method == "GET" and current_user.profession == "Teacher":
return render_template('courses.html',
profile_image=profile_image,
courses=teacher_courses,
new_course=new_course,
title="Courses")
elif request.method == "GET" and current_user.profession == "Student":
return render_template('courses.html',
profile_image=profile_image,
courses=student_courses,
add_course=add_course,
title="Courses")
Expand All @@ -103,13 +106,15 @@ def courses():
@login_required
@course_auth
def course(course_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
teacher = (course.teacher_id == current_user.id)

drop = request.form.get('drop')

if not teacher and request.method == "GET":
return render_template('course.html',
profile_image=profile_image,
course=course,
title="Course - " + str(course.title))

Expand All @@ -134,6 +139,7 @@ def course(course_id):
edit_course_form.join.data = str(course.join)

return render_template('course.html',
profile_image=profile_image,
course=course,
edit_course_form=edit_course_form,
title="Course - " + str(course.title))
Expand Down Expand Up @@ -167,6 +173,7 @@ def course(course_id):
@course_auth
@teacher_auth
def course_syllabus(course_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
syllabusform = UpdateSyllabusForm()

Expand All @@ -179,6 +186,7 @@ def course_syllabus(course_id):
elif request.method == "GET":
syllabusform.syllabus.data = course.syllabus
return render_template('course_syllabus.html',
profile_image=profile_image,
course=course,
syllabusform=syllabusform,
title=str(course.title) + " - Syllabus")
4 changes: 3 additions & 1 deletion app/deadlines/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Blueprint, render_template
from flask import Blueprint, render_template, url_for
from flask_login import login_required, current_user
from app.models import (Course_User, User_Assignment,
Assignment)
Expand All @@ -9,6 +9,7 @@
@deadlines_.route('/dashboard/deadlines', methods=['GET'])
@login_required
def deadlines():
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
courses = Course_User.query.filter_by(user_id=current_user.id).all()
user_assignments = User_Assignment.query.filter_by(user_id=current_user.id).all()
user_assignments = [ua.id for ua in user_assignments]
Expand All @@ -20,5 +21,6 @@ def deadlines():
assignments_due.append(assignment)

return render_template("deadlines.html",
profile_image=profile_image,
assignments=assignments_due,
title="Deadlines")
8 changes: 7 additions & 1 deletion app/inbox/routes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import profile
from flask import (Blueprint, request, redirect, render_template,
url_for)
from flask_login import login_required, current_user
Expand All @@ -15,6 +16,7 @@
@inbox_.route('/dashboard/inbox', methods=['GET', 'POST'])
@login_required
def inbox():
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
conversation_snippets = inbox_info()

delete = request.form.get("delete")
Expand All @@ -38,6 +40,7 @@ def inbox():
return redirect(url_for("inbox.inbox"))

return render_template("conversation.html",
profile_image=profile_image,
conversation_snippets=conversation_snippets,
title="Inbox")

Expand All @@ -52,6 +55,7 @@ def get_recipients():
@inbox_.route('/dashboard/inbox/conversation/new', methods=['GET', 'POST'])
@login_required
def new_conversation():
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
conversation_snippets = inbox_info()
recipient = request.args.get("recipient_id")
if recipient:
Expand Down Expand Up @@ -88,6 +92,7 @@ def new_conversation():
elif request.method == "GET":
form = NewConversationForm()
return render_template("new_conversation.html",
profile_image=profile_image,
conversation_snippets=conversation_snippets,
recipient=recipient,
form=form,
Expand Down Expand Up @@ -122,7 +127,7 @@ def update_messages(convo_id):
@login_required
@limiter.exempt
def conversation(convo_id):

profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
user_convo = Conversation_User.query.filter_by(user_id=current_user.id, conversation_id=convo_id).first()
user_convo.read = True
db.session.commit()
Expand Down Expand Up @@ -151,6 +156,7 @@ def conversation(convo_id):

return redirect(url_for("inbox.conversation", convo_id=convo_id))
return render_template("conversation.html",
profile_image=profile_image,
conversation=conversation,
messages=messages,
conversation_snippets=conversation_snippets,
Expand Down
8 changes: 7 additions & 1 deletion app/lectures/routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask import (Blueprint, request, render_template,
redirect, url_for, flash)
from flask_login import login_required
from flask_login import login_required, current_user
from app.lectures.forms import NewLectureForm
from app.filters import autoversion
from app.middleware import course_auth, teacher_auth
Expand All @@ -11,12 +11,14 @@
@login_required
@course_auth
def lectures(course_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
lectures = Lecture.query.filter_by(course_id=course_id).all()
lectures.sort(key=lambda l:l.created_time)

if request.method == "GET":
return render_template("lectures.html",
profile_image=profile_image,
course=course,
lectures=lectures,
title=f"{course.title} - Lectures",
Expand All @@ -28,6 +30,7 @@ def lectures(course_id):
@course_auth
@teacher_auth
def new_lecture(course_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
form = NewLectureForm()

Expand All @@ -50,6 +53,7 @@ def new_lecture(course_id):
return redirect(url_for("lectures.lectures", course_id=course.id))
else:
return render_template("new_lecture.html",
profile_image=profile_image,
course=course,
form=form,
title=f"{course.title} - New Lecture",
Expand All @@ -59,11 +63,13 @@ def new_lecture(course_id):
@login_required
@course_auth
def lecture(course_id, lecture_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
lecture = Lecture.query.filter_by(id=lecture_id).first()

if request.method == "GET":
return render_template("lecture.html",
profile_image=profile_image,
course=course,
lecture=lecture,
title=f"{course.title} - Lecture",
Expand Down
2 changes: 1 addition & 1 deletion app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_token(self, expires_in=None):
payload['exp'] = time() + expires_in
return jwt.encode(payload,
current_app.config["SECRET_KEY"],
algorithm='HS256').decode('utf-8')
algorithm='HS256')

@staticmethod
def verify_token(token):
Expand Down
Binary file added app/static/profile_images/5dfe821e4cf244a9.jpg
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 app/static/profile_images/968f94f27e1fa306.jpg
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 app/static/profile_images/a67ac77caf121522.jpg
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 app/static/profile_images/a98f624937b3c69a.jpg
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 app/static/profile_images/d3b09c388f9b913f.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions app/students/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@login_required
@course_auth
def grades(course_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
if current_user.id == course.teacher_id:
return redirect(url_for("students.students", course_id=course.id))
Expand All @@ -28,6 +29,7 @@ def grades(course_id):

if request.method == "GET":
return render_template('grades.html',
profile_image=profile_image,
course=course,
course_user=course_user,
assignments=assignments,
Expand All @@ -41,6 +43,7 @@ def grades(course_id):
@login_required
@course_auth
def students(course_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
course_students = Course_User.query.filter_by(course_id=course.id).all()
teacher = User_Account.query.filter_by(id=course.teacher_id).first()
Expand Down Expand Up @@ -70,6 +73,7 @@ def students(course_id):
return redirect(url_for("students.students", course_id=course.id))
elif request.method == "GET":
return render_template("students.html",
profile_image=profile_image,
course=course,
course_students=course_students,
students_list=students_list,
Expand Down Expand Up @@ -106,6 +110,7 @@ def student(course_id, student_id):
@course_auth
@teacher_auth
def student_grades(course_id, student_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
student = User_Account.query.filter_by(id=student_id).first()

Expand All @@ -116,6 +121,7 @@ def student_grades(course_id, student_id):

if request.method == "GET":
return render_template("grades.html",
profile_image=profile_image,
course=course,
course_user=course_user,
assignments=assignments,
Expand All @@ -131,6 +137,7 @@ def student_grades(course_id, student_id):
@course_auth
@teacher_auth
def student_grades_edit(course_id, student_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
student = User_Account.query.filter_by(id=student_id).first()

Expand Down Expand Up @@ -221,6 +228,7 @@ def student_grades_edit(course_id, student_id):
return redirect(url_for("students.student_grades", course_id=course.id, student_id=student.id))
elif request.method == "GET":
return render_template("grades_edit.html",
profile_image=profile_image,
course=course,
course_user=course_user,
assignments=assignments,
Expand All @@ -237,6 +245,7 @@ def student_grades_edit(course_id, student_id):
@course_auth
@teacher_auth
def student_assignments(course_id, student_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
student = User_Account.query.filter_by(id=student_id).first()
assignments = course.assignments
Expand All @@ -254,6 +263,7 @@ def student_assignments(course_id, student_id):

if request.method == "GET":
return render_template("student_assignments.html",
profile_image=profile_image,
course=course,
student=student,
assignments=assignments,
Expand All @@ -267,6 +277,7 @@ def student_assignments(course_id, student_id):
@course_auth
@teacher_auth
def student_assignment(course_id, student_id, user_assignment_id):
profile_image = url_for('static', filename="profile_images/" + current_user.profile_image)
course = Course.query.filter_by(id=course_id).first()
student = User_Account.query.filter_by(id=student_id).first()
user_assignment = User_Assignment.query.filter_by(id=user_assignment_id).first()
Expand All @@ -282,6 +293,7 @@ def student_assignment(course_id, student_id, user_assignment_id):

if request.method == "GET":
return render_template("student_assignment.html",
profile_image=profile_image,
course=course,
student=student,
user_assignment=user_assignment,
Expand Down
1 change: 0 additions & 1 deletion app/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<link href="https://fonts.googleapis.com/css2?family=Arimo&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css')|autoversion }}">

{{ moment.include_jquery() }}
{{ moment.include_moment(sri=False) }}
<script src="https://cdn.tiny.cloud/1/5t7si4kzxnjyk0lgsz2gu9mgqhzgjunlvlxfbc1z8u5ircmn/tinymce/5/tinymce.min.js" referrerpolicy="origin"/></script>
<title>{{ title }}</title>
Expand Down
1 change: 0 additions & 1 deletion app/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS Framework/CDN -->
{{ moment.include_jquery() }}
{{ moment.include_moment(sri=False) }}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Arimo&display=swap" rel="stylesheet">
Expand Down
Loading

0 comments on commit 2b299b2

Please sign in to comment.