Skip to content

Commit

Permalink
WIP record new version with photo upload
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Jun 13, 2024
1 parent e2eaaea commit baa830c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions ynr/apps/moderation_queue/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit baa830c

Please sign in to comment.