def add_buildings_to_project(request): """ Adds buildings to a project. Payload:: { 'project': { 'project_slug': Identifier of project to add buildings to, 'selected_buildings': A list of building IDs to add to project } } Returns:: { 'status': 'success' or 'error', 'message': 'error message, if any', 'project_loading_cache_key': Identifier for the background job, to determine the job's progress } """ body = json.loads(request.body) project_json = body.get('project') project = Project.objects.get(slug=project_json['project_slug']) add_buildings.delay(project_slug=project.slug, project_dict=project_json, user_pk=request.user.pk) key = project.adding_buildings_status_percentage_cache_key return {'status': 'success', 'project_loading_cache_key': key}
def add_buildings_to_project(request): """ Adds buildings to a project. Payload:: { 'project': { 'project_slug': Identifier of project to add buildings to, 'selected_buildings': A list of building IDs to add to project } } Returns:: { 'status': 'success' or 'error', 'message': 'error message, if any', 'project_loading_cache_key': Identifier for the background job, to determine the job's progress } """ body = json.loads(request.body) project_json = body.get('project') project = Project.objects.get(slug=project_json['project_slug']) add_buildings.delay( project_slug=project.slug, project_dict=project_json, user_pk=request.user.pk) key = project.adding_buildings_status_percentage_cache_key return { 'status': 'success', 'project_loading_cache_key': key }