nautobot.apps.views
¶
Utilities for apps to implement UI views.
nautobot.apps.views.NautobotUIViewSet
¶
Bases: mixins.ObjectDetailViewMixin
, mixins.ObjectListViewMixin
, mixins.ObjectEditViewMixin
, mixins.ObjectDestroyViewMixin
, mixins.ObjectBulkDestroyViewMixin
, mixins.ObjectBulkCreateViewMixin
, mixins.ObjectBulkUpdateViewMixin
, mixins.ObjectChangeLogViewMixin
, mixins.ObjectNotesViewMixin
Nautobot BaseViewSet that is intended for UI use only. It provides default Nautobot functionalities such as
create()
, bulk_create()
, update()
, partial_update()
, bulk_update()
, destroy()
, bulk_destroy()
, retrieve()
notes()
, changelog()
and list()
actions.
Source code in nautobot/core/views/viewsets.py
nautobot.apps.views.ObjectBulkCreateViewMixin
¶
Bases: NautobotViewSetMixin
, BulkCreateModelMixin
UI mixin to bulk create model instances.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectBulkDestroyViewMixin
¶
Bases: NautobotViewSetMixin
, BulkDestroyModelMixin
UI mixin to bulk destroy model instances.
Source code in nautobot/core/views/mixins.py
bulk_destroy(request, args, kwargs)
¶
Call perform_bulk_destroy(). The function exist to keep the DRF's get/post pattern of {action}/perform_{action}, we will need it when we transition from using forms to serializers in the UI. User should override this function to handle any actions as needed before bulk destroy.
Source code in nautobot/core/views/mixins.py
perform_bulk_destroy(request, kwargs)
¶
request.POST "_delete": Function to render the user selection of objects in a table form/BulkDestroyConfirmationForm via Response that is passed to NautobotHTMLRenderer. request.POST "_confirm": Function to validate the table form/BulkDestroyConfirmationForm and to perform the action of bulk destroy. Render the form with errors if exceptions are raised.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectBulkUpdateViewMixin
¶
Bases: NautobotViewSetMixin
, BulkUpdateModelMixin
UI mixin to bulk update model instances.
Source code in nautobot/core/views/mixins.py
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
|
bulk_update(request, args, kwargs)
¶
Call perform_bulk_update(). The function exist to keep the DRF's get/post pattern of {action}/perform_{action}, we will need it when we transition from using forms to serializers in the UI. User should override this function to handle any actions as needed before bulk update.
Source code in nautobot/core/views/mixins.py
perform_bulk_update(request, kwargs)
¶
request.POST "_edit": Function to render the user selection of objects in a table form/BulkUpdateForm via Response that is passed to NautobotHTMLRenderer. request.POST "_apply": Function to validate the table form/BulkUpdateForm and to perform the action of bulk update. Render the form with errors if exceptions are raised.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectChangeLogViewMixin
¶
Bases: NautobotViewSetMixin
UI mixin to list a model's changelog queryset
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectDestroyViewMixin
¶
Bases: NautobotViewSetMixin
, mixins.DestroyModelMixin
UI mixin to destroy a model instance.
Source code in nautobot/core/views/mixins.py
destroy(request, args, kwargs)
¶
request.GET: render the ObjectDeleteConfirmationForm which is passed to NautobotHTMLRenderer as Response. request.POST: call perform_destroy() which validates the form and perform the action of delete. Override to add more variables to Response
Source code in nautobot/core/views/mixins.py
perform_destroy(request, kwargs)
¶
Function to validate the ObjectDeleteConfirmationForm and to delete the object.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectDetailViewMixin
¶
nautobot.apps.views.ObjectEditViewMixin
¶
Bases: NautobotViewSetMixin
, mixins.CreateModelMixin
, mixins.UpdateModelMixin
UI mixin to create or update a model instance.
Source code in nautobot/core/views/mixins.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
|
create(request, args, kwargs)
¶
request.GET: render the ObjectForm which is passed to NautobotHTMLRenderer as Response. request.POST: call perform_create() which validates the form and perform the action of create. Override to add more variables to Response.
Source code in nautobot/core/views/mixins.py
perform_create(request, args, kwargs)
¶
Function to validate the ObjectForm and to create a new object.
Source code in nautobot/core/views/mixins.py
perform_update(request, args, kwargs)
¶
Function to validate the ObjectEditForm and to update/partial_update an existing object.
Source code in nautobot/core/views/mixins.py
update(request, args, kwargs)
¶
request.GET: render the ObjectEditForm which is passed to NautobotHTMLRenderer as Response. request.POST: call perform_update() which validates the form and perform the action of update/partial_update of an existing object. Override to add more variables to Response.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectListViewMixin
¶
Bases: NautobotViewSetMixin
, mixins.ListModelMixin
UI mixin to list a model queryset
Source code in nautobot/core/views/mixins.py
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 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
|
list(request, args, kwargs)
¶
List the model instances.
Source code in nautobot/core/views/mixins.py
queryset_to_csv()
¶
Export the queryset of objects as comma-separated value (CSV), using the model's to_csv() method.
Source code in nautobot/core/views/mixins.py
queryset_to_yaml()
¶
Export the queryset of objects as concatenated YAML documents.
nautobot.apps.views.ObjectNotesViewMixin
¶
Bases: NautobotViewSetMixin
UI Mixin for an Object's Notes.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectView
¶
Bases: ObjectPermissionRequiredMixin
, View
Retrieve a single object for display.
queryset: The base queryset for retrieving the object template_name: Name of the template to use
Source code in nautobot/core/views/generic.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 |
|
get(request, args, kwargs)
¶
Generic GET handler for accessing an object by PK or slug
Source code in nautobot/core/views/generic.py
get_changelog_url(instance)
¶
Return the changelog URL for a given instance.
Source code in nautobot/core/views/generic.py
get_extra_context(request, instance)
¶
Return any additional context data for the template.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
Request
|
The current request |
required |
instance |
Model
|
The object being viewed |
required |
Returns:
Type | Description |
---|---|
dict
|
Additional context data |
Source code in nautobot/core/views/generic.py
get_template_name()
¶
Return self.template_name if set. Otherwise, resolve the template path by model app_label and name.