file_bulk_serializer#
PartialFileSerializer#
Bases: FileSerializer
, StrictSerializer
File serializer that does not validate required fields.
All fields have required=False and id is writable. Null id is treated as missing id.
Source code in src/apps/files/serializers/file_bulk_serializer.py
BulkFileFail#
BulkAction#
FileBulkSuccessSerializer#
FileBulkFailSerializer#
FileBulkReturnValueSerializer#
FileBulkSerializer#
Bases: ListSerializer
Serializer for bulk file creation.
Action parameter should be one of BulkAction values: * insert: Create new files. * update: Update existing files. * upsert: Create new files or replace already existing files. * delete: Delete existing files. Update supports partial updating. Values omitted from the request are not changed.
If input file has an id, it's treated as an existing file. If input file has a storage_identifier, its existence is checked from the database. If input file has no id and no storage_identifier, it's treated as a new file.
Call serializer.save() to apply changes. After this, serializer.data will return an object in the format { "success": [ { "object": { ... }, action: "insert" } , ], "failed": [ { "object": { ... }, errors: { ... } } , ] }
When ignore_errors is enabled (False by default), changes will be committed even if there are errors for some objects. Otherwise, only failed objects will be returned.
Where success objects will contain the deserialized file object and failed objects will contain the corresponding input data. Order of input files is maintained so successes and failed objects are in the same order as in the request.
Source code in src/apps/files/serializers/file_bulk_serializer.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
|
data
property
#
Skip ListSerializer.data that tries to return list.
assign_characteristics(file, characteristics_data)
#
Assign characteristics data (not saved yet) to file.
Source code in src/apps/files/serializers/file_bulk_serializer.py
assign_existing_storage_data(files)
#
Assign storage and related fields to existing file data.
Source code in src/apps/files/serializers/file_bulk_serializer.py
assign_storage_to_files(files)
#
Assign FileStorage instances to files.
Source code in src/apps/files/serializers/file_bulk_serializer.py
check_changing_existing_allowed(files)
#
Check if inserting new files is allowed.
Source code in src/apps/files/serializers/file_bulk_serializer.py
check_creating_new_allowed(files)
#
Check if inserting new files is allowed.
Source code in src/apps/files/serializers/file_bulk_serializer.py
check_duplicate_ids(files)
#
Check that same files are not being modified multiple times.
Source code in src/apps/files/serializers/file_bulk_serializer.py
check_files_allowed_actions(files)
#
Check that only allowed actions are performed on files.
Files containing an id field are assumed to exist.
Source code in src/apps/files/serializers/file_bulk_serializer.py
check_id_field_allowed(files)
#
Check that id field is allowed.
Source code in src/apps/files/serializers/file_bulk_serializer.py
check_ids_exist(files)
#
Check that all file ids point to existing files.
Source code in src/apps/files/serializers/file_bulk_serializer.py
create(validated_data)
#
Perform bulk file action.
Returns success objects which will be stored in self.instance by .save().
Source code in src/apps/files/serializers/file_bulk_serializer.py
do_create_or_update(files)
#
Perform bulk create and update actions for files.
Source code in src/apps/files/serializers/file_bulk_serializer.py
do_delete(files)
#
Perform bulk delete on files.
Source code in src/apps/files/serializers/file_bulk_serializer.py
fail(object, errors)
#
Add object to list of failed items.
Source code in src/apps/files/serializers/file_bulk_serializer.py
flush_file_errors(files)
#
Remove errors field and return only files that have no errors.
Source code in src/apps/files/serializers/file_bulk_serializer.py
get_file_instances(validated_data)
#
Return not yet saved instances from validated data.
Source code in src/apps/files/serializers/file_bulk_serializer.py
group_files_by_storage_service(files)
#
Return files grouped by storage service.
Source code in src/apps/files/serializers/file_bulk_serializer.py
populate_id_from_external_identifier(files)
#
Add id value to files that already exist based on external id.
Source code in src/apps/files/serializers/file_bulk_serializer.py
update_file_instance(instance, file_data)
#
Update instance attributes of a File instance.
Returns the updated file, or None if there were errors.