Commit 0ce12dc5 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

fix project find

parent eb64254e
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -224,12 +224,24 @@ def update_data_from_xlsx_rows(
    from resources.models import UserTask

    project = None

    # Try to find the project
    if len(xlsx_rows) > 0:
        for r in xlsx_rows:
            if r.get("resource_pk"):
                first_resource = models.Resource.objects.filter(
            pk=xlsx_rows[0].get("pk")
                    pk=r.get("resource_pk")
                ).first()
                if first_resource:
                    project = first_resource.ptr_project
                    break
            if r.get("collection_pk"):
                first_collection = models.Collection.objects.filter(
                    pk=r.get("collection_pk")
                ).first()
                if first_collection:
                    project = first_collection.project
                    break
    user_task = None
    user = User.objects.filter(pk=user_id).first()
    if user: