Best Python code snippet using Kiwi_python
views.py
Source:views.py  
...72        return form73    def form_valid(self, form):74        response = super().form_valid(form)75        if not self.object.assignee:76            self.object.assignee = New.find_assignee(self.request.POST)77            self.object.save()78        add_comment([self.object], form.cleaned_data["text"], self.request.user)79        return response80    @staticmethod81    def assignee_from_components(components):82        """83        Return the first owner which is assigned to any of the84        components. This is as best as we can to automatically figure85        out who should be assigned to this bug.86        """87        for component in components:88            if component.initial_owner:89                return component.initial_owner90        return None91    @staticmethod92    def find_assignee(data):93        """94        Try to automatically find an assignee for Bug by first scanning95        TestCase components (if present) and then components for the96        product.97        """98        assignee = None99        if "_execution" in data:100            assignee = New.assignee_from_components(101                data["_execution"].case.component.all()102            )103            del data["_execution"]104        if not assignee:105            assignee = New.assignee_from_components(106                Component.objects.filter(product=data["product"])107            )108        return assignee109    @staticmethod110    def create_bug(data):111        """112        Helper method used within Issue Tracker integration.113        :param data: Untrusted input, usually via HTTP request114        :type data: dict115        :return: bug116        :rtype: Model117        """118        bug = None119        if "assignee" not in data or not data["assignee"]:120            data["assignee"] = New.find_assignee(data)121        text = data["text"]122        del data["text"]123        bug = Bug.objects.create(**data)124        add_comment([bug], text, bug.reporter)125        return bug126@method_decorator(127    object_permission_required(128        "bugs.change_bug", (Bug, "pk", "pk"), accept_global_perms=True129    ),130    name="dispatch",131)132class Edit(UpdateView):133    model = Bug134    form_class = NewBugForm...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
