Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: stable
rev: 23.1.0
hooks:
- id: black
language_version: python3
Expand All @@ -9,6 +9,6 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/sqlalchemyorg/zimports/
rev: 0.1.3
rev: v0.6.0
hooks:
- id: zimports
2 changes: 2 additions & 0 deletions src/match/controllers/create_match_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def process(self):
match.save()
user_1.person.pending_feedback = True
user_2.person.pending_feedback = True
user_1.person.save()
user_2.person.save()
return (
(True, "")
if self._return_status
Expand Down
26 changes: 21 additions & 5 deletions src/survey/controllers/create_survey_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from api.utils import modify_attribute
from api.utils import success_response
from match import match_status
from match.models import Match
from rest_framework import status
from survey import constants
from survey.models import Survey
Expand Down Expand Up @@ -62,11 +61,28 @@ def process(self):
status.HTTP_400_BAD_REQUEST,
)

# Commenting this out because iOS is sending the new match_id as the match_id,
# but we need the previous week's match id, which we can actually get the
# user's previous match using their match history. Not the most efficient, but
# a temporary fix.
#
# Verify that required ids are valid
completed_match = Match.objects.filter(id=self._match_id)
if not completed_match:
return failure_response("match_id is invalid", status.HTTP_404_NOT_FOUND)
completed_match = completed_match[0]
# completed_match = Match.objects.filter(id=self._match_id)
# if not completed_match:
# return failure_response("match_id is invalid", status.HTTP_404_NOT_FOUND)
# completed_match = completed_match[0]

prev_matches = (
self._request.user.matches_1.all() | self._request.user.matches_1.all()
).order_by("-created_date")

if len(prev_matches) < 2:
return failure_response(
"User does not have enough matches", status.HTTP_400_BAD_REQUEST
)

# index 0 -> current match, 1 -> previous week, etc
completed_match = prev_matches[1]

# Check if the submitting user has already submitted a survey
survey = Survey.objects.filter(
Expand Down
Loading