@celery_app.task
def create_project_request(project_id, publicbody_id, sequence=0, **kwargs):
    from .services import CreateRequestFromProjectService
    try:
        project = FoiProject.objects.get(id=project_id)
    except FoiProject.DoesNotExist:
        return
    try:
        pb = PublicBody.objects.get(id=publicbody_id)
    except PublicBody.DoesNotExist:
        return
    kwargs.update({'project': project, 'publicbody': pb, 'subject': project.title, 'user': project.user, 'body': project.description, 'public': project.public, 'reference': project.reference, 'tags': [t.name for t in project.tags.all()], 'project_order': sequence})
    service = CreateRequestFromProjectService(kwargs)
    foirequest = service.execute()
    if (project.request_count == project.foirequest_set.all().count()):
        project.status = FoiProject.STATUS_READY
        project.save()
    return foirequest.pk
@celery_app.task
def create_project_request(project_id, publicbody_id, sequence=0, **kwargs):
    from .services import CreateRequestFromProjectService
    try:
        project = FoiProject.objects.get(id=project_id)
    except FoiProject.DoesNotExist:
        return
    try:
        pb = PublicBody.objects.get(id=publicbody_id)
    except PublicBody.DoesNotExist:
        return
    kwargs.update({'project': project, 'publicbody': pb, 'subject': project.title, 'user': project.user, 'body': project.description, 'public': project.public, 'reference': project.reference, 'tags': [t.name for t in project.tags.all()], 'project_order': sequence})
    service = CreateRequestFromProjectService(kwargs)
    foirequest = service.execute()
    if (project.request_count == project.foirequest_set.all().count()):
        project.status = FoiProject.STATUS_READY
        project.save()
    return foirequest.pk