diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3ed4bc5becc9985223978dedac71e4fdca2c1fe5..663ce9c18faedca6329c096f19a3849a4015be87 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,10 +34,10 @@ test_pytest: paths: - .coverage -test_prospector: +test_flake8: <<: *test_definition_backend script: - - prospector --uses django || exit 0 + - flake8 --exclude=migrations --ignore=N802 core # ----------------------------- Frontend subsection -------------------------- # .test_template_frontend: &test_definition_frontend diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e63378ac57329d9a0728dce6758f4d2e7585e6d0..053bd6572ce691ad5c3702e86133c104fe057666 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,10 +12,3 @@ args: - requirements.txt - requirements.dev.txt -- repo: local - hooks: - - id: prospector - name: prospector - entry: ./pre-commit-scripts/prospector.sh - language: script - types: [python] diff --git a/core/grady_speak.py b/core/grady_speak.py deleted file mode 100644 index 08b6242f7406b15b820aa11bf9ded76e07816869..0000000000000000000000000000000000000000 --- a/core/grady_speak.py +++ /dev/null @@ -1,23 +0,0 @@ -grady_says = [ - "Now let's see if we can improve this with a little water, sir.", - "Won't keep you a moment, sir.", - "Grady, sir. Delbert Grady.", - "Yes, sir.", - "That's right, sir.", - "Why no, sir. I don't believe so.", - "Ah ha, it's coming off now, sir.", - "Why no, sir. I don't believe so.", - "Yes, sir. I have a wife and two daughters, sir.", - "Oh, they're somewhere around. I'm not quite sure at the moment, sir.", - "That's strange, sir. I don't have any recollection of that at all.", - "I'm sorry to differ with you, sir, but you are the caretaker.", - "You have always been the caretaker, I should know, sir.", - "I've always been here.", - "Indeed, he is, Mr. Torrance. Avery willful boy. ", - "A rather naughty boy, if I may be so bold, sir.", - "Perhaps they need a good talking to, if you don't mind my saying so. Perhaps a bit more.", - "My girls, sir, they didn't care for the Overlook at first.", - "One of them actually stole a packet of matches and tried to burn it down.", - "But I corrected them, sir.", - "And when my wife tried to prevent me from doing my duty... I corrected her.", -] diff --git a/core/models.py b/core/models.py index 30a240f2b5521a7e049c4663098532ae6abd3f2b..966b647d3b5aad0c0a5d6759fbddc715aa703870 100644 --- a/core/models.py +++ b/core/models.py @@ -13,9 +13,8 @@ from typing import Dict, Union from django.contrib.auth import get_user_model from django.contrib.auth.models import AbstractUser from django.db import models -from django.db.models import Value as V from django.db.models import (BooleanField, Case, Count, F, IntegerField, Q, - QuerySet, Sum, When) + QuerySet, Sum, Value, When) from django.db.models.functions import Coalesce @@ -125,7 +124,7 @@ class SubmissionType(models.Model): When( Q(submissions__feedback__isnull=False) & Q(submissions__feedback__status=Feedback.ACCEPTED), - then=V(1)), output_field=IntegerField(), + then=Value(1)), output_field=IntegerField(), ) ) ).annotate( @@ -230,11 +229,12 @@ class Student(models.Model): the annotated QuerySet as described above. """ return cls.objects.annotate( - overall_score=Coalesce(Sum('submissions__feedback__score'), V(0)), + overall_score=Coalesce(Sum('submissions__feedback__score'), + Value(0)), ).annotate( done=Case( - When(exam__pass_score__lt=F('overall_score'), then=V(1)), - default=V(0), + When(exam__pass_score__lt=F('overall_score'), then=Value(1)), + default=Value(0), output_field=BooleanField() ) ) @@ -362,12 +362,12 @@ class Submission(models.Model): candidates = cls.objects.filter( ( - Q(feedback__isnull=True) - | Q(feedback__origin=Feedback.DID_NOT_COMPILE) - | Q(feedback__origin=Feedback.COULD_NOT_LINK) - | Q(feedback__origin=Feedback.FAILED_UNIT_TESTS) - ) - & ~Q(feedback__of_tutor=tutor) + Q(feedback__isnull=True) | + Q(feedback__origin=Feedback.DID_NOT_COMPILE) | + Q(feedback__origin=Feedback.COULD_NOT_LINK) | + Q(feedback__origin=Feedback.FAILED_UNIT_TESTS) + ) & + ~Q(feedback__of_tutor=tutor) ) # we want a submission of a specific type @@ -542,6 +542,7 @@ class Feedback(models.Model): ) return tutor_feedback[0] if tutor_feedback else None + @classmethod def tutor_assigned_feedback(cls, user: Union[Tutor, Reviewer]): """Gets all feedback that is assigned to the tutor including all status cases. diff --git a/pre-commit-scripts/prospector.sh b/pre-commit-scripts/prospector.sh deleted file mode 100755 index f6d218ff3bdf21de8df9dc93d0cbf80bcfd80452..0000000000000000000000000000000000000000 --- a/pre-commit-scripts/prospector.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -diff_files="$(git diff --cached --name-only --relative --diff-filter=AM)" -if [ -n "$diff_files" ]; then - prospector --uses django $diff_files -else - exit 0 -fi diff --git a/requirements.dev.txt b/requirements.dev.txt index 63b69b7d1ecfc80af3daa2c7027332dadfc8178a..eaa909a4ee73cc11378a4b7d2041c5d66d204e48 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,4 +1,4 @@ +flake8~=3.5.0 pre-commit~=1.4.1 -prospector~=0.12.7 pytest-cov~=2.5.1 pytest-django~=3.1.2