update paths after changing name, fixes #1013

This commit is contained in:
j 2012-09-30 18:27:01 +02:00
parent 83b71b6c3c
commit 0fe1786ec0
2 changed files with 10 additions and 0 deletions

View file

@ -9,3 +9,11 @@ import models
def update_itemsort(id): def update_itemsort(id):
p = models.Person.objects.get(pk=id) p = models.Person.objects.get(pk=id)
p.update_itemsort() p.update_itemsort()
@task(ignore_results=True, queue='default')
def update_file_paths(id):
from item.models import Item
from item.tasks import update_file_paths
p = models.Person.objects.get(pk=id)
for i in Item.objects.filter(find__value__icontains=p.name).distinct():
update_file_paths(i.itemId)

View file

@ -14,6 +14,7 @@ from ox.django.api import actions
from item import utils from item import utils
import models import models
import tasks
@admin_required_json @admin_required_json
def editName(request): def editName(request):
@ -31,6 +32,7 @@ def editName(request):
person.sortname = data['sortname'] person.sortname = data['sortname']
person.edited = True person.edited = True
person.save() person.save()
tasks.update_file_paths.delay(person.id)
response['data'] = person.json() response['data'] = person.json()
return render_to_json_response(response) return render_to_json_response(response)
actions.register(editName, cache=False) actions.register(editName, cache=False)