Skip to content
Snippets Groups Projects
Commit 118fe72c authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

Added messages, simplified urls

parent 36f3dba8
No related branches found
No related tags found
No related merge requests found
...@@ -56,8 +56,7 @@ ...@@ -56,8 +56,7 @@
<button type="submit" form="form1" class="btn btn-success" name="update" value="Next">Next</button> <button type="submit" form="form1" class="btn btn-success" name="update" value="Next">Next</button>
<a href="{% url 'FeedbackDelete' feedback.slug %}" class="btn btn-danger" name="delete" value="Delete">Delete</a> <a href="{% url 'FeedbackDelete' feedback.slug %}" class="btn btn-danger" name="delete" value="Delete">Delete</a>
{% else %} {% else %}
<button class="btn btn-success mx-1" value="Submit" disabled>Submit</button> <button class="btn btn-secondary mx-1" value="Submit" disabled>View is read only</button>
<button class="btn btn-danger" value="Delete" disabled>Delete</button>
{% endif %} {% endif %}
</div> </div>
...@@ -103,6 +102,11 @@ ...@@ -103,6 +102,11 @@
editor_student.setOptions({ editor_student.setOptions({
readOnly: true, readOnly: true,
}) })
{% if feedback.final %}
editor_tutor.setOptions({
readOnly: true,
})
{% endif %}
</script> </script>
{% endblock script_block %} {% endblock script_block %}
...@@ -6,73 +6,84 @@ ...@@ -6,73 +6,84 @@
{% block body_block %} {% block body_block %}
<div class="row"> <div class="row my-3">
<div class="col-3"> <div class="col-3">
<div class="card my-4 text-center">
<div class="card-block"> {# Only a list of tutors. Currently no controls available #}
<div class="card-header" id="SubmissionCard"> <div class="card">
<h4>List of Tutors</h4> <div class="card-header">
Tutor overview
</div>
<div class="card-block">
<table class="table">
<thead>
<th>Tutor</th>
<th># of feedbacks</th>
</thead>
{% for tutor in tutor_list %}
<tbody>
<tr>
<td>{{tutor.username}}</td>
<td><code>{{tutor.corrected_submissions__count}}</code></td>
</tr>
</tbody>
{% endfor %}
</table>
</div> </div>
<ul class="list-group list-group-flush">
{% for tutor in tutor_list %}
<li class="list-group-item"> {{ tutor }} </li>
{% endfor %}
</ul>
</div> </div>
</div> </div>
</div>
<div class="col-9"> <div class="col-9">
<div class="row-md-auto my-4 page-header"> <div class="row page-header">
{% if feedback_list|length == 0 %} {% if feedback_list|length == 0 %}
<h2>Nobody has provided any feedback, yet. Maybe you have to kick some ass?</h2> <h2>Nobody has provided any feedback, yet. Maybe you have to kick some ass?</h2>
{% else %} {% else %}
{% if feedback_list|length == 1 %} {% if feedback_list|length == 1 %}
<h2>Well, one is better than nothing</h2> <h2>Well, one is better than nothing</h2>
{% else %} {% else %}
<h2>So far {{feedback_list|length}} constributions were provided</h2> <h2>So far {{feedback_list|length}} constributions were provided</h2>
{% endif %} {% endif %}
</div> </div>
<div class="row-md-auto my-2"> <div class="row my-2">
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<th>Submission Type</th> <th>Submission Type</th>
<th>Student</th> <th>Student</th>
<th>Score</th> <th>Score</th>
<th>Tutor</th> <th>Tutor</th>
<th></th> <th></th>
</tr>
</thead>
<tbody>
{% for feedback in feedback_list %}
<tr>
<td class="align-middle"> {% if feedback.final %}
<span class="badge badge-success">Final</span>
{% endif %}</td>
<td class="align-middle"> {{ feedback.of_submission.type }} </td>
<td class="align-middle"> {{ feedback.of_submission.student }} </td>
<td class="align-middle"> <code> {{ feedback.score }} / {{ feedback.of_submission.type.full_score }} </code> </td>
<td class="align-middle"> {{ feedback.of_tutor}} </td>
<td class="align-middle">
<a href="{% url 'FeedbackDelete' feedback.slug %}" class="btn btn-primary" name="delete" value="Delete">Delete</a>
<a href="{% url 'FeedbackEdit' feedback.slug %}" class="btn btn-primary" name="edit" value="View">View</a>
{% if not feedback.final %}
<a class="btn btn-primary" href="{% url 'FeedbackMarkFinal' feedback.slug %}"> Mark final </a>
{% else %}
<a class="btn btn-secondary" href="{% url 'FeedbackMarkNotFinal' feedback.slug %}"> Undo </a>
{% endif %}
</td>
</tr> </tr>
{% endfor %} </thead>
</tbody> <tbody>
</table> {% for feedback in feedback_list %}
<tr>
<td class="align-middle"> {% if feedback.final %}
<span class="badge badge-success">Final</span>
{% endif %}</td>
<td class="align-middle"> {{ feedback.of_submission.type }} </td>
<td class="align-middle"> {{ feedback.of_submission.student }} </td>
<td class="align-middle"> <code> {{ feedback.score }} / {{ feedback.of_submission.type.full_score }} </code> </td>
<td class="align-middle"> {{ feedback.of_tutor}} </td>
<td class="align-middle">
<a href="{% url 'FeedbackEdit' feedback.slug %}" class="btn btn-outline-primary" name="edit" value="View">View</a>
<a href="{% url 'FeedbackDelete' feedback.slug %}" class="btn btn-outline-danger" name="delete" value="Delete">Delete</a>
{% if not feedback.final %}
<a class="btn btn-outline-success" href="{% url 'FeedbackMarkFinal' feedback.slug %}"> Mark final </a>
{% else %}
<a class="btn btn-outline-secondary" href="{% url 'FeedbackMarkNotFinal' feedback.slug %}"> Undo </a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div> </div>
</div> </div>
</div>
{% endif %} {% endif %}
{% endblock body_block %} {% endblock body_block %}
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
{% block body_block %} {% block body_block %}
<div class="row justify-content-center my-2"> <div class="row justify-content-center my-2">
<div class="col-3"> <div class="col-3">
{# This is a contol panel where new work can be requested #}
<div class="card"> <div class="card">
<h4 class="card-header">Command Center</h4> <h4 class="card-header">Command Center</h4>
<table class="table"> <table class="table">
...@@ -28,8 +30,21 @@ ...@@ -28,8 +30,21 @@
<a role="button" class="btn btn-outline-danger" href="{% url 'CreateFeedback' %}">Just give me anything</a> <a role="button" class="btn btn-outline-danger" href="{% url 'CreateFeedback' %}">Just give me anything</a>
</div> </div>
</div> </div>
{# This is where all the messages pop up #}
{% for message in messages %}
<div class="alert {{ message.tags }} alert-dismissible fade show my-2" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
{{message}}
</div>
{% endfor %}
</div> </div>
<div class="col-5"> <div class="col-5">
{# The custom header message #}
<div class="row my-2 page-header"> <div class="row my-2 page-header">
{% if feedback_list|length == 0 %} {% if feedback_list|length == 0 %}
<h2>You havn't provided any feedback yet. Sad. Get to work!</h2> <h2>You havn't provided any feedback yet. Sad. Get to work!</h2>
...@@ -40,6 +55,8 @@ ...@@ -40,6 +55,8 @@
<h2>So far you have provided {{feedback_list|length}} constributions</h2> <h2>So far you have provided {{feedback_list|length}} constributions</h2>
{% endif %} {% endif %}
</div> </div>
{# The big table where the tutor can see what s/he actually did #}
<div class="row justify-content-center my-2"> <div class="row justify-content-center my-2">
<table class="table"> <table class="table">
<thead> <thead>
...@@ -70,6 +87,4 @@ ...@@ -70,6 +87,4 @@
</div> </div>
</div> </div>
</div> </div>
{% endblock body_block %} {% endblock body_block %}
...@@ -8,7 +8,6 @@ urlpatterns = [ ...@@ -8,7 +8,6 @@ urlpatterns = [
url(r'^login/$', views.user_login, name='login'), url(r'^login/$', views.user_login, name='login'),
url(r'^logout/$', views.user_logout, name='logout'), url(r'^logout/$', views.user_logout, name='logout'),
url(r'^start/$', views.user_home, name='start'), url(r'^start/$', views.user_home, name='start'),
url(r'^finished/$', views.finished, name='end'),
url(r'^feedback/create/$', views.create_feedback, name='CreateFeedback'), url(r'^feedback/create/$', views.create_feedback, name='CreateFeedback'),
url(r'^feedback/create/(?P<type_slug>\w+)/$', views.create_feedback, name='CreateFeedbackForType'), url(r'^feedback/create/(?P<type_slug>\w+)/$', views.create_feedback, name='CreateFeedbackForType'),
......
...@@ -5,6 +5,7 @@ from django.contrib import messages ...@@ -5,6 +5,7 @@ from django.contrib import messages
from django.http import Http404, HttpResponse, HttpResponseRedirect from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import render from django.shortcuts import render
from django.urls import reverse from django.urls import reverse
from django.db.models import Count
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.views.generic import DetailView from django.views.generic import DetailView
from django.views.generic.edit import UpdateView from django.views.generic.edit import UpdateView
...@@ -17,6 +18,7 @@ from random import choice ...@@ -17,6 +18,7 @@ from random import choice
# Create your views here. # Create your views here.
def in_groups(user, group_list): def in_groups(user, group_list):
return bool(user.groups.filter(name__in=group_list)) or user.is_superuser return bool(user.groups.filter(name__in=group_list)) or user.is_superuser
...@@ -99,7 +101,7 @@ def student_view(request): ...@@ -99,7 +101,7 @@ def student_view(request):
@group_required('Reviewers') @group_required('Reviewers')
def reviewer_view(request): def reviewer_view(request):
context = { context = {
'tutor_list': User.objects.filter(groups__name='Tutors'), 'tutor_list': User.objects.annotate(Count('corrected_submissions')).filter(groups__name='Tutors'),
'submission_list': Submission.objects.all(), 'submission_list': Submission.objects.all(),
'feedback_list': Feedback.objects.all(), 'feedback_list': Feedback.objects.all(),
} }
...@@ -112,6 +114,10 @@ def create_feedback(request, type_slug=None): ...@@ -112,6 +114,10 @@ def create_feedback(request, type_slug=None):
Submission.assign_tutor(request.user, type_slug) Submission.assign_tutor(request.user, type_slug)
feedback = Feedback.tutor_unfinished_feedback(request.user) feedback = Feedback.tutor_unfinished_feedback(request.user)
if not feedback: if not feedback:
if type_slug:
messages.info(request, "No more submissions of this type available.")
else:
messages.success(request, "Well done! There is no more work to do.")
return HttpResponseRedirect(reverse('start')) return HttpResponseRedirect(reverse('start'))
return HttpResponseRedirect(reverse('FeedbackEdit', args=(feedback.slug,))) return HttpResponseRedirect(reverse('FeedbackEdit', args=(feedback.slug,)))
...@@ -140,11 +146,6 @@ def markunfinal_feedback(request, feedback_slug): ...@@ -140,11 +146,6 @@ def markunfinal_feedback(request, feedback_slug):
return HttpResponseRedirect(reverse('start')) return HttpResponseRedirect(reverse('start'))
@group_required('Tutors', 'Reviewers')
def finished(request):
return HttpResponse("Ich habe fertig.")
class FeedbackEdit(UpdateView): class FeedbackEdit(UpdateView):
"""docstring for FeedbackCreate""" """docstring for FeedbackCreate"""
......
...@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/1.10/ref/settings/ ...@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/1.10/ref/settings/
import os import os
from django.contrib.messages import constants as messages
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...@@ -126,3 +128,12 @@ GRAPH_MODELS = { ...@@ -126,3 +128,12 @@ GRAPH_MODELS = {
'all_applications': True, 'all_applications': True,
'group_models': True, 'group_models': True,
} }
MESSAGE_TAGS = {
messages.DEBUG: 'alert-info',
messages.INFO: 'alert-info',
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning',
messages.ERROR: 'alert-danger',
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment