gazu 1.0.1__py2.py3-none-any.whl → 1.0.2__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gazu/task.py CHANGED
@@ -429,15 +429,6 @@ def get_task_by_entity(entity, task_type, name="main", client=default):
429
429
  )
430
430
 
431
431
 
432
- @deprecated(
433
- version="0.9.17",
434
- reason="You should use another function: gazu.task.get_task_by_entity, it will be removed in a future version of Gazu (0.10.0).",
435
- )
436
- @cache
437
- def get_task_by_name(entity, task_type, name="main", client=default):
438
- return get_task_by_entity(entity, task_type, name=name, client=client)
439
-
440
-
441
432
  @cache
442
433
  def get_task_type(task_type_id, client=default):
443
434
  """
@@ -679,7 +670,7 @@ def new_task(
679
670
  if assigner is not None:
680
671
  data["assigner_id"] = normalize_model_parameter(assigner)["id"]
681
672
 
682
- task = get_task_by_name(entity, task_type, name, client=client)
673
+ task = get_task_by_entity(entity, task_type, name, client=client)
683
674
  if task is None:
684
675
  task = raw.post("data/tasks", data, client=client)
685
676
  return task
@@ -1345,3 +1336,406 @@ def update_comment(comment, client=default):
1345
1336
  dict: Updated comment.
1346
1337
  """
1347
1338
  return raw.put("data/comments/%s" % comment["id"], comment, client=client)
1339
+
1340
+
1341
+ @cache
1342
+ def all_open_tasks(client=default):
1343
+ """
1344
+ Get all open tasks.
1345
+
1346
+ Returns:
1347
+ list: Open tasks.
1348
+ """
1349
+ return raw.fetch_all("tasks/open", client=client)
1350
+
1351
+
1352
+ @cache
1353
+ def get_open_tasks_stats(client=default):
1354
+ """
1355
+ Get statistics for open tasks.
1356
+
1357
+ Returns:
1358
+ dict: Open tasks statistics.
1359
+ """
1360
+ return raw.get("data/tasks/open/stats", client=client)
1361
+
1362
+
1363
+ @cache
1364
+ def all_previews_for_task(task, client=default):
1365
+ """
1366
+ Get all previews for a task.
1367
+
1368
+ Args:
1369
+ task (dict / ID): The task dict or id.
1370
+
1371
+ Returns:
1372
+ list: Previews for the task.
1373
+ """
1374
+ task = normalize_model_parameter(task)
1375
+ return raw.fetch_all("tasks/%s/previews" % task["id"], client=client)
1376
+
1377
+
1378
+ @cache
1379
+ def all_open_tasks_for_person(person, client=default):
1380
+ """
1381
+ Get all open tasks for a person.
1382
+
1383
+ Args:
1384
+ person (dict / ID): The person dict or id.
1385
+
1386
+ Returns:
1387
+ list: Open tasks for the person.
1388
+ """
1389
+ person = normalize_model_parameter(person)
1390
+ return raw.fetch_all("persons/%s/tasks/open" % person["id"], client=client)
1391
+
1392
+
1393
+ @cache
1394
+ def all_tasks_for_person_and_type(person, task_type, client=default):
1395
+ """
1396
+ Get all tasks for a person and task type.
1397
+
1398
+ Args:
1399
+ person (dict / ID): The person dict or id.
1400
+ task_type (dict / ID): The task type dict or id.
1401
+
1402
+ Returns:
1403
+ list: Tasks for the person and task type.
1404
+ """
1405
+ person = normalize_model_parameter(person)
1406
+ task_type = normalize_model_parameter(task_type)
1407
+ return raw.fetch_all(
1408
+ "persons/%s/task-types/%s/tasks" % (person["id"], task_type["id"]),
1409
+ client=client,
1410
+ )
1411
+
1412
+
1413
+ @cache
1414
+ def all_comments_for_project(project, client=default):
1415
+ """
1416
+ Get all comments for a project.
1417
+
1418
+ Args:
1419
+ project (dict / ID): The project dict or id.
1420
+
1421
+ Returns:
1422
+ list: Comments for the project.
1423
+ """
1424
+ project = normalize_model_parameter(project)
1425
+ return raw.fetch_all(
1426
+ "projects/%s/comments" % project["id"], client=client
1427
+ )
1428
+
1429
+
1430
+ @cache
1431
+ def all_notifications_for_project(project, client=default):
1432
+ """
1433
+ Get all notifications for a project.
1434
+
1435
+ Args:
1436
+ project (dict / ID): The project dict or id.
1437
+
1438
+ Returns:
1439
+ list: Notifications for the project.
1440
+ """
1441
+ project = normalize_model_parameter(project)
1442
+ return raw.fetch_all(
1443
+ "projects/%s/notifications" % project["id"], client=client
1444
+ )
1445
+
1446
+
1447
+ @cache
1448
+ def all_preview_files_for_project(project, client=default):
1449
+ """
1450
+ Get all preview files for a project.
1451
+
1452
+ Args:
1453
+ project (dict / ID): The project dict or id.
1454
+
1455
+ Returns:
1456
+ list: Preview files for the project.
1457
+ """
1458
+ project = normalize_model_parameter(project)
1459
+ return raw.fetch_all(
1460
+ "projects/%s/preview-files" % project["id"], client=client
1461
+ )
1462
+
1463
+
1464
+ @cache
1465
+ def all_subscriptions_for_project(project, client=default):
1466
+ """
1467
+ Get all subscriptions for a project.
1468
+
1469
+ Args:
1470
+ project (dict / ID): The project dict or id.
1471
+
1472
+ Returns:
1473
+ list: Subscriptions for the project.
1474
+ """
1475
+ project = normalize_model_parameter(project)
1476
+ return raw.fetch_all(
1477
+ "projects/%s/subscriptions" % project["id"], client=client
1478
+ )
1479
+
1480
+
1481
+ @cache
1482
+ def get_persons_tasks_dates(project, client=default):
1483
+ """
1484
+ Get tasks dates for persons in a project.
1485
+
1486
+ Args:
1487
+ project (dict / ID): The project dict or id.
1488
+
1489
+ Returns:
1490
+ dict: Tasks dates for persons.
1491
+ """
1492
+ project = normalize_model_parameter(project)
1493
+ return raw.get(
1494
+ "data/projects/%s/persons/tasks/dates" % project["id"], client=client
1495
+ )
1496
+
1497
+
1498
+ def remove_tasks_for_type(project, task_type, client=default):
1499
+ """
1500
+ Delete all tasks for a task type in a project.
1501
+
1502
+ Args:
1503
+ project (dict / ID): The project dict or id.
1504
+ task_type (dict / ID): The task type dict or id.
1505
+
1506
+ Returns:
1507
+ Response: Request response object.
1508
+ """
1509
+ project = normalize_model_parameter(project)
1510
+ task_type = normalize_model_parameter(task_type)
1511
+ return raw.delete(
1512
+ "data/projects/%s/task-types/%s/tasks"
1513
+ % (project["id"], task_type["id"]),
1514
+ client=client,
1515
+ )
1516
+
1517
+
1518
+ def remove_tasks_batch(tasks, client=default):
1519
+ """
1520
+ Delete multiple tasks in batch.
1521
+
1522
+ Args:
1523
+ tasks (list): List of task dicts or IDs to delete.
1524
+
1525
+ Returns:
1526
+ Response: Request response object.
1527
+ """
1528
+ task_ids = [
1529
+ normalize_model_parameter(task)["id"] for task in tasks
1530
+ ]
1531
+ return raw.post(
1532
+ "data/tasks/delete-batch", {"task_ids": task_ids}, client=client
1533
+ )
1534
+
1535
+
1536
+ def assign_tasks_to_person(tasks, person, client=default):
1537
+ """
1538
+ Assign multiple tasks to a person.
1539
+
1540
+ Args:
1541
+ tasks (list): List of task dicts or IDs.
1542
+ person (dict / ID): The person dict or id.
1543
+
1544
+ Returns:
1545
+ dict: Response information.
1546
+ """
1547
+ person = normalize_model_parameter(person)
1548
+ task_ids = [
1549
+ normalize_model_parameter(task)["id"] for task in tasks
1550
+ ]
1551
+ return raw.put(
1552
+ "data/tasks/assign",
1553
+ {"person_id": person["id"], "task_ids": task_ids},
1554
+ client=client,
1555
+ )
1556
+
1557
+
1558
+ @cache
1559
+ def get_task_time_spent_for_date(task, date, client=default):
1560
+ """
1561
+ Get time spent for a task on a specific date.
1562
+
1563
+ Args:
1564
+ task (dict / ID): The task dict or id.
1565
+ date (str): Date in YYYY-MM-DD format.
1566
+
1567
+ Returns:
1568
+ dict: Time spent information.
1569
+ """
1570
+ task = normalize_model_parameter(task)
1571
+ return raw.get(
1572
+ "data/tasks/%s/time-spent/for-date" % task["id"],
1573
+ params={"date": date},
1574
+ client=client,
1575
+ )
1576
+
1577
+
1578
+ def remove_time_spent(time_spent, client=default):
1579
+ """
1580
+ Delete a time spent entry.
1581
+
1582
+ Args:
1583
+ time_spent (dict / ID): The time spent dict or id.
1584
+
1585
+ Returns:
1586
+ Response: Request response object.
1587
+ """
1588
+ time_spent = normalize_model_parameter(time_spent)
1589
+ return raw.delete(
1590
+ "data/time-spents/%s" % time_spent["id"], client=client
1591
+ )
1592
+
1593
+
1594
+ def add_preview_to_comment(comment, preview_file, client=default):
1595
+ """
1596
+ Add a preview to a comment.
1597
+
1598
+ Args:
1599
+ comment (dict / ID): The comment dict or id.
1600
+ preview_file (dict / ID): The preview file dict or id.
1601
+
1602
+ Returns:
1603
+ dict: Updated comment.
1604
+ """
1605
+ comment = normalize_model_parameter(comment)
1606
+ preview_file = normalize_model_parameter(preview_file)
1607
+ return raw.post(
1608
+ "data/comments/%s/preview-files" % comment["id"],
1609
+ {"preview_file_id": preview_file["id"]},
1610
+ client=client,
1611
+ )
1612
+
1613
+
1614
+ def remove_preview_from_comment(comment, preview_file, client=default):
1615
+ """
1616
+ Remove a preview from a comment.
1617
+
1618
+ Args:
1619
+ comment (dict / ID): The comment dict or id.
1620
+ preview_file (dict / ID): The preview file dict or id.
1621
+
1622
+ Returns:
1623
+ Response: Request response object.
1624
+ """
1625
+ comment = normalize_model_parameter(comment)
1626
+ preview_file = normalize_model_parameter(preview_file)
1627
+ return raw.delete(
1628
+ "data/comments/%s/preview-files/%s"
1629
+ % (comment["id"], preview_file["id"]),
1630
+ client=client,
1631
+ )
1632
+
1633
+
1634
+ def create_shot_tasks(shot, task_types, client=default):
1635
+ """
1636
+ Create tasks for a shot.
1637
+
1638
+ Args:
1639
+ shot (dict / ID): The shot dict or id.
1640
+ task_types (list): List of task type dicts or IDs.
1641
+
1642
+ Returns:
1643
+ list: Created tasks.
1644
+ """
1645
+ shot = normalize_model_parameter(shot)
1646
+ task_type_ids = [
1647
+ normalize_model_parameter(task_type)["id"] for task_type in task_types
1648
+ ]
1649
+ return raw.post(
1650
+ "data/shots/%s/tasks" % shot["id"],
1651
+ {"task_type_ids": task_type_ids},
1652
+ client=client,
1653
+ )
1654
+
1655
+
1656
+ def create_asset_tasks(asset, task_types, client=default):
1657
+ """
1658
+ Create tasks for an asset.
1659
+
1660
+ Args:
1661
+ asset (dict / ID): The asset dict or id.
1662
+ task_types (list): List of task type dicts or IDs.
1663
+
1664
+ Returns:
1665
+ list: Created tasks.
1666
+ """
1667
+ asset = normalize_model_parameter(asset)
1668
+ task_type_ids = [
1669
+ normalize_model_parameter(task_type)["id"] for task_type in task_types
1670
+ ]
1671
+ return raw.post(
1672
+ "data/assets/%s/tasks" % asset["id"],
1673
+ {"task_type_ids": task_type_ids},
1674
+ client=client,
1675
+ )
1676
+
1677
+
1678
+ def create_edit_tasks(edit, task_types, client=default):
1679
+ """
1680
+ Create tasks for an edit.
1681
+
1682
+ Args:
1683
+ edit (dict / ID): The edit dict or id.
1684
+ task_types (list): List of task type dicts or IDs.
1685
+
1686
+ Returns:
1687
+ list: Created tasks.
1688
+ """
1689
+ edit = normalize_model_parameter(edit)
1690
+ task_type_ids = [
1691
+ normalize_model_parameter(task_type)["id"] for task_type in task_types
1692
+ ]
1693
+ return raw.post(
1694
+ "data/edits/%s/tasks" % edit["id"],
1695
+ {"task_type_ids": task_type_ids},
1696
+ client=client,
1697
+ )
1698
+
1699
+
1700
+ def create_concept_tasks(concept, task_types, client=default):
1701
+ """
1702
+ Create tasks for a concept.
1703
+
1704
+ Args:
1705
+ concept (dict / ID): The concept dict or id.
1706
+ task_types (list): List of task type dicts or IDs.
1707
+
1708
+ Returns:
1709
+ list: Created tasks.
1710
+ """
1711
+ concept = normalize_model_parameter(concept)
1712
+ task_type_ids = [
1713
+ normalize_model_parameter(task_type)["id"] for task_type in task_types
1714
+ ]
1715
+ return raw.post(
1716
+ "data/concepts/%s/tasks" % concept["id"],
1717
+ {"task_type_ids": task_type_ids},
1718
+ client=client,
1719
+ )
1720
+
1721
+
1722
+ def create_entity_tasks(entity, task_types, client=default):
1723
+ """
1724
+ Create tasks for an entity.
1725
+
1726
+ Args:
1727
+ entity (dict / ID): The entity dict or id.
1728
+ task_types (list): List of task type dicts or IDs.
1729
+
1730
+ Returns:
1731
+ list: Created tasks.
1732
+ """
1733
+ entity = normalize_model_parameter(entity)
1734
+ task_type_ids = [
1735
+ normalize_model_parameter(task_type)["id"] for task_type in task_types
1736
+ ]
1737
+ return raw.post(
1738
+ "data/entities/%s/tasks" % entity["id"],
1739
+ {"task_type_ids": task_type_ids},
1740
+ client=client,
1741
+ )