diff --git a/ynr/apps/moderation_queue/helpers.py b/ynr/apps/moderation_queue/helpers.py index 1aa25efb5..9ccd6a909 100644 --- a/ynr/apps/moderation_queue/helpers.py +++ b/ynr/apps/moderation_queue/helpers.py @@ -3,7 +3,7 @@ import requests from candidates.models.db import ActionType, LoggedAction -from candidates.views.version_data import get_client_ip +from candidates.views.version_data import get_change_metadata, get_client_ip from django.http import HttpResponseRedirect from django.shortcuts import render from django.urls import reverse @@ -32,14 +32,33 @@ def image_form_valid_response(request, person, image_form): queued_image = image_form.save(commit=False) queued_image.user = request.user queued_image.save() - # Record that action: + # TODO: Record this action and update the person versions. + # this needs a separate path than the usual record_version + # for person identifiers. We don't need to check previous versions + # of the person, we just need to record the action in the version log. + # we need to create a version and insert it into the version log. it should + # include the user, the action type, the person, and the source. + # the challenge is that the change_metadata step below will not + # work because it does not have the same structure as the version log. + # we need to create a new version which includes all the person attributes + # with blank values and the user and the action type + change_metadata = get_change_metadata( + request, image_form.cleaned_data["justification_for_use"] + ) + # change_metadata.update({ + # "data": {}, + # "photo-upload": True + # }) + person.record_version(change_metadata) + person.save() + LoggedAction.objects.create( user=request.user, action_type=ActionType.PHOTO_UPLOAD, ip_address=get_client_ip(request), popit_person_new_version="", person=person, - source=image_form.cleaned_data["justification_for_use"], + source=image_form.cleaned_data["why_allowed"], ) return HttpResponseRedirect( reverse("photo-upload-success", kwargs={"person_id": person.id})