Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
16bec2f
Resolving issues filtering with no organizations
SamuelVch98 Jul 27, 2024
585ace3
use toast to display errors
SamuelVch98 Jul 29, 2024
0da87f0
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Jul 29, 2024
eada3ca
Fix small issues
SamuelVch98 Jul 30, 2024
7cae218
create unique file for toast and use it
SamuelVch98 Jul 30, 2024
4a633f6
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Jul 30, 2024
99f16d6
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Aug 20, 2024
cf3938d
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Sep 12, 2024
ad8658c
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Oct 1, 2024
1177b11
indicate the type of user to be displayed
SamuelVch98 Oct 9, 2024
9f8b4cc
Fix the bug that prevents you from changing organisation if none was …
SamuelVch98 Oct 9, 2024
ec2bdc1
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Oct 13, 2024
97023c8
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Oct 15, 2024
af8da85
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Oct 15, 2024
4db087a
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Oct 16, 2024
d40c27b
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Oct 17, 2024
7d55991
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Nov 28, 2024
cce7b20
Merge branch 'UCL-INGI:main' into main
SamuelVch98 Dec 3, 2024
8c94489
Add handsontable to the app
SamuelVch98 Jul 16, 2024
9698880
Finish integrating the handsontable panel
SamuelVch98 Jul 16, 2024
2af10b9
update README
SamuelVch98 Jul 16, 2024
a7f1f7d
Fix PR request
SamuelVch98 Jul 26, 2024
11ab5cb
rabse + modifying the code to display several promoters
SamuelVch98 Oct 21, 2024
e1cae5a
create a new table to store more easily whether a publication is for …
SamuelVch98 Oct 15, 2024
84b4903
continue to develop the publication just for teachers
SamuelVch98 Oct 15, 2024
5a446f2
display of courses assigned in the researcher and teacher view
SamuelVch98 Oct 16, 2024
a7a0e7e
send a mail to the users concerned after publication of the assignments
SamuelVch98 Oct 27, 2024
3345eae
add mail template
SamuelVch98 Oct 28, 2024
d0f4c6c
small fix
SamuelVch98 Dec 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
from course import course_bp
from config import config_bp
from course_preference import course_preference_bp
from assignment import assignment_bp
from assignment import assignment_bp, mail
from db import db, Year, Organization, User, Course, Teacher, Researcher, Evaluation
from decorators import *
from flask import Flask, render_template, session, request
from flask_mail import Mail
from enums import *
from util import get_current_year
import json
Expand All @@ -21,6 +22,7 @@
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db.init_app(app)
mail.init_app(app)

# Core blueprints
app.register_blueprint(auth_bp, url_prefix="/auth")
Expand Down
22 changes: 21 additions & 1 deletion assignment.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from flask_mail import Message, Mail
import os
from decorators import login_required, check_access_level
from db import db, User, Course, PreferenceAssignment, Teacher, Researcher, Organization, \
ResearcherSupervisor, Role, AssignmentDraft, AssignmentPublished
from flask import Blueprint, render_template, flash, current_app, url_for, request, make_response, redirect, session, \
Flask, jsonify
from util import get_current_year
from enums import DEFAULT_MAX_LOAD
from enums import DEFAULT_MAX_LOAD, MAIL_ADMIN

assignment_bp = Blueprint('assignment', __name__)
mail = Mail()


@assignment_bp.route('/assignments', methods=['GET'])
Expand Down Expand Up @@ -72,6 +75,7 @@ def load_data():

@assignment_bp.route('/publish_assignments', methods=['POST'])
@login_required
@check_access_level(Role.ADMIN)
def publish_assignments():
data = request.get_json()
if not data:
Expand Down Expand Up @@ -125,8 +129,24 @@ def publish_assignments():

db.session.add_all(assignments_to_add)
db.session.commit()
send_mail(True)
return jsonify({"message": "Assignments published successfully"}), 200

except Exception as e:
db.session.rollback()
return jsonify({"error": f"Failed to publish assignments: {str(e)}"}), 500


@assignment_bp.route('/send_email')
@login_required
@check_access_level(Role.ADMIN)
def send_mail(teacher_publication):
users = db.session.query(User).filter_by(is_teacher=True).all() if teacher_publication else db.session.query(
User).filter_by(active=True).all()

for user in users:
mail_html = render_template('mail_template.html', user=user)
mail_message = Message("Publication of assignments", sender="[email protected]", html=mail_html,
recipients=[user.email], cc=MAIL_ADMIN)

mail.send(mail_message)
6 changes: 6 additions & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"APP_NAME": "ICTM Teaching",
"SECRET_KEY": "ASECRETKEY",
"SQLALCHEMY_DATABASE_URI": "DB URI",
"MAIL_SERVER": "MAIL SERVER",
"MAIL_PORT": "MAIL PORT",
"MAIL_USERNAME": "MAIL SENDER USERNAME",
"MAIL_PASSWORD": "MAIL SENDER PASSWORD",
"MAIL_USE_TLS": false,
"MAIL_USE_SSL": true,
"SAML": {
"attributes": {
"sn": "urn:oid:2.5.4.4",
Expand Down
2 changes: 1 addition & 1 deletion course.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def add_course():
@check_access_level(Role.ADMIN)
def courses(year):
courses = db.session.query(Course).filter_by(year=year).all()
return render_template('courses.html', courses=courses, current_year=year)
return render_template('courses.html', courses=courses, year=year)


@course_bp.route('/search_teachers')
Expand Down
1 change: 0 additions & 1 deletion create_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

def create_database(name, first_name, email):
with app.app_context():
db.create_all()
add_first_admin(name, first_name, email)
initialize_configuration()
create_organizations()
Expand Down
1 change: 1 addition & 0 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Teacher(db.Model):

class PreferenceAssignment(db.Model):
__tablename__ = 'preference_assignment'
rank = db.Column(db.Integer, nullable=False)
id = db.Column(db.Integer, primary_key=True)
rank = db.Column(db.Integer, nullable=False)
course_id = db.Column(db.Integer, nullable=False)
Expand Down
1 change: 1 addition & 0 deletions enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
"Corrections/jury/oral", "Creation of new content (new exercises, new project statement, ...)"]
EVALUATION_HOUR = ["< 2h", "2h - 4h", "4h - 6h", "6h - 8h", "> 8h"]
WORKLOAD = ["Very light", "Light", "Reasonable", "High", "Very high"]
MAIL_ADMIN = ["[email protected]"]
2 changes: 1 addition & 1 deletion templates/courses.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h4>Courses</h4>
<tr class="course-item"
data-organizations="{{ course.organizations | map(attribute='id') | join(',') }}">
<td>
<a href="{{ url_for("course.course_info", course_id=course.id, year=current_year) }}">
<a href="{{ url_for("course.course_info", course_id=course.id, year=year) }}">
{{ course.code }} - {{ course.title }}
</a>
</td>
Expand Down
32 changes: 21 additions & 11 deletions templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ <h2 class="sub-header">Course(s) assigned this year ({{ dynamic_year }} - {{ dyn
<table class="table table-hover">
<thead>
<tr>
<th>Code</th>
<th>Title</th>
<th>Course</th>
<th>Position</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">No courses assigned this year.</td>
</tr>
{% for researcher_course in researcher_assignments %}
<tr>
<td>{{ researcher_course.course.code }} - {{ researcher_course.course.title }}</td>
<td>{{ researcher_course.position }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="container-fluid">
Expand Down Expand Up @@ -108,7 +111,11 @@ <h2 class="sub-header">My courses for ({{ dynamic_year }} - {{ dynamic_year + 1
<tr>
<td>{{ course.code }}</td>
<td>{{ course.title }}</td>
<td>None</td>
<td>
{% for assistant in assistants %}
{{ assistant.name }} {{ assistant.first_name }}<br>
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -117,14 +124,17 @@ <h2 class="sub-header">Course assignments for my researchers</h2>
<table class="table table-hover">
<thead>
<tr>
<th>Code</th>
<th>Title</th>
<th>Course</th>
<th>Researcher</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">No course(s) this year.</td>
</tr>
{% for researcher_course in teacher_assignments %}
<tr>
<td>{{ researcher_course.course.code }} - {{ researcher_course.course.title }}</td>
<td>{{ researcher_course.user.name }} {{ researcher_course.user.first_name }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!DOCTYPE html>
<html lang="en">
<head>
Expand Down
23 changes: 23 additions & 0 deletions templates/mail_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap.min.css') }}">
</head>
<body class="bg-light">
<div class="container my-5">
<div class="card mx-auto" style="max-width: 600px;">
<div class="card-header bg-primary text-white text-center">
<h3 class="mt-2">Publication of Your Assignments</h3>
</div>

<div class="card-body">
<p class="lead">Hello {{ user.name }} {{ user.first_name }},</p>
<p>The assignments for the {{ dynamic_year }} - {{ dynamic_year + 1 }} academic year have been published and can be accessed from the ICTM application homepage.</p>
<p>Please check your assignments. If you have any problems, you can reply directly to this email.</p>
</div>
</div>
</div>
</body>
</html>