Skip to content

Commit a0d0c3d

Browse files
authored
Fix assign teachers (#45)
1 parent 63d0b34 commit a0d0c3d

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

course.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from sqlalchemy import func
2+
13
from decorators import login_required, check_access_level
24
from db import db, User, Course, Teacher, Organization, Evaluation, Year, Role
35
from flask import Blueprint, render_template, flash, url_for, request, make_response, redirect, \
@@ -123,11 +125,12 @@ def search_teachers():
123125
search_term = request.args.get('q', '')
124126

125127
if not validate_string_pattern(search_term):
126-
return make_response("Invalid search term", 400)
128+
flash("Invalid search term", "danger")
127129

128130
teachers = db.session.query(User).filter(
131+
User.active == True,
129132
User.is_teacher == True,
130-
User.name.ilike(f'%{search_term}%')
133+
func.concat(User.name, ' ', User.first_name).ilike(f'%{search_term}%')
131134
).all()
132135
results = [{'id': teacher.id, 'text': f'{teacher.name} {teacher.first_name}'} for teacher in teachers]
133136
return jsonify(results)

templates/course_template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ <h2 class="sub-header">Course informations</h2>
4646
$(document).ready(function () {
4747
$(document).on('change', '#organization_code', function () {
4848
var containerSelector = $('#selected-organizations', $(this).parent());
49-
addBadge($(this), containerSelector);
49+
addBadge(this, containerSelector, 'organization_code');
5050
});
5151

5252

templates/layout.html

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,6 @@
135135
<div id="content">
136136
{% block pagecontent %}{% endblock %}
137137
</div>
138-
{% block additionalfooter %}
139-
<script>
140-
$(document).ready(function () {
141-
$('#confirmationModal').on('show.bs.modal', function (event) {
142-
var button = $(event.relatedTarget);
143-
144-
var message = button.data('message');
145-
var url = button.data('url');
146-
147-
var modal = $(this);
148-
modal.find('.modal-body').text(message);
149-
modal.find('#confirmationForm').attr('action', url);
150-
});
151-
});
152-
</script>
153-
{% endblock %}
138+
{% block additionalfooter %}{% endblock %}
154139
</body>
155140
</html>

user.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def user_profile(user_id, current_year):
138138
if researcher:
139139
preferences = db.session.query(PreferenceAssignment).filter_by(researcher_id=researcher.id,
140140
course_year=current_year).all()
141-
142141
courses = []
143142
if current_user and requested_user.organization:
144143
courses = db.session.query(Course).filter(Course.year == current_year,
@@ -201,7 +200,6 @@ def update_user_profile(user_id):
201200
user.organization_id = organization_code
202201
user.is_admin = is_admin
203202
user.is_teacher = is_teacher
204-
user.is_researcher = is_researcher
205203
if is_researcher:
206204
if researcher is None:
207205
create_researcher(user.id, researcher_type, max_loads)

0 commit comments

Comments
 (0)