Add publish message to all views + fix some bugs

master
Corentin LEMAIRE 6 months ago
parent 0e37e4903b
commit 452707cf6c

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -10,6 +10,9 @@
<a href="{% url 'profile' %}">Profile</a>
<a href="{% url 'search' %}">Search</a>
<a href="{% url 'notifications_view' %}">Notifications</a>
{% if person.role == 'Teacher' %}
<a href="{% url 'publish_message' %}">Publish a message</a>
{% endif %}
<a href="{% url 'logout' %}">Logout</a>
{% endif %}
</nav>

@ -21,7 +21,7 @@
{% if error_message %}
{{ error_message }}
{% endif %}
<br/>
<label for="title">Course Title</label><br>
<input type="text" name="title" id="title" value="{{ course.title }}" required><br/>

@ -6,7 +6,7 @@ from redis_app.utils.index import create_index
# This model only helps us the development part to set rules on objects (we do not use the django model to save objects in it)
from .models import Person
DEFAULT_EXPIRE_TIME = 120
DEFAULT_EXPIRE_TIME = 1200
EXPIRE_REFRESH_TIME = 60
messages = [] # All messages obtained with pub/sub. Will refresh the view every time a message is received
@ -228,6 +228,7 @@ def delete_course_view(request, course_id):
res = delete_course(course_id)
if not res:
return courses(request)
publish(course_id, f"DELETE: Course:{course_id} has been deleted!")
return courses(request)
def create_course(course_title, course_summary, course_level, course_places, course_teacher):
@ -325,10 +326,18 @@ def update_course_form(request, course_id):
course_level = request.POST['level']
course_places = request.POST['places']
course_teacher = getPersonId(person['name'], person['role']).split(":")[1]
course = redis_connection.hgetall(f"course:{course_id}")
course["id"] = course_id
course_students = course.get("students", "")
try:
if course_students and len(course_students.split(',')) >= int(course_places):
return render(request, 'update.html', {'person': person, "error_message": "There's too many students registered to decrease the number of places that much!", "course": course})
except:
return render(request, 'update.html', {'person': person, "error_message": "The number of places has not the right format!", "course": course})
update_course(course_id, course_title, course_summary, course_level, course_places, course_teacher)
return courses(request)
return render(request, 'update.html', {'person': person, "error_message": "The form has been wrongly filled!"})
return render(request, 'update.html', {'person': person, "error_message": "The form has been wrongly filled!", "course": course})
# Test if places are not limited
def course_register(course_id, person_id):

Loading…
Cancel
Save