Skip to content
Open
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
15 changes: 12 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,23 @@ 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
change_metadata = get_change_metadata(
request, information_source=image_form.cleaned_data["why_allowed"]
)
change_metadata.update({"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
4 changes: 4 additions & 0 deletions ynr/apps/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ def record_version(self, change_metadata, new_person=False):
# Always create a version if this is a merge
should_insert = True

if new_version["information_source"] == "profile-photo":
# Always create a version if this is a photo upload
should_insert = True

if should_insert:
versions.insert(0, new_version)

Expand Down