MCPcopy
hub / github.com/WebODM/WebODM / patch

Method patch

app/api/media.py:212–235  ·  view source on GitHub ↗
(self, request, pk=None, project_pk=None, filename=None)

Source from the content-addressed store, hash-verified

210 raise exceptions.NotFound()
211
212 def patch(self, request, pk=None, project_pk=None, filename=None):
213 task = self.get_and_check_task(request, pk)
214 check_project_perms(request, task.project, perms=("change_project", ))
215
216 if not task.media:
217 raise exceptions.NotFound()
218
219 with transaction.atomic():
220 task = self._lock_task(task)
221
222 found = False
223 for entry in task.media:
224 if entry['filename'] == filename:
225 if 'description' in request.data:
226 entry['description'] = str(request.data['description'])[:4096]
227 found = True
228 break
229
230 if not found:
231 raise exceptions.NotFound()
232
233 task.save()
234
235 return Response({'success': True}, status=status.HTTP_200_OK)
236
237 def delete(self, request, pk=None, project_pk=None, filename=None):
238 task = self.get_and_check_task(request, pk)

Callers 7

test_exportsMethod · 0.80
test_tagsMethod · 0.80
test_mediaMethod · 0.80
test_taskMethod · 0.80
test_presetMethod · 0.80
test_cropMethod · 0.80

Calls 4

check_project_permsFunction · 0.85
get_and_check_taskMethod · 0.80
_lock_taskMethod · 0.80
saveMethod · 0.45

Tested by 7

test_exportsMethod · 0.64
test_tagsMethod · 0.64
test_mediaMethod · 0.64
test_taskMethod · 0.64
test_presetMethod · 0.64
test_cropMethod · 0.64