Esempio n. 1
0
 def get_form(self):
     if not self.form:
         # Make new form object
         self.form = TestSuiteDetailForm(self.request.GET, )
         # Process the form
         self.form.is_valid()
     return self.form
Esempio n. 2
0
class TestSuiteDetailView(DetailView):
    model = TestSuite
    template_name = 'testsuite.html'
    context_object_name = 'testsuite'
    form = None

    def tz_and_dateify(self, date):
        if not date:
            return None

        return timezone.datetime(year=date.year,
                                 month=date.month,
                                 day=date.day,
                                 hour=0,
                                 minute=0,
                                 tzinfo=timezone.get_current_timezone())

    def get_context_data(self, **kwargs):
        today = timezone.now().date()
        one_week_ago = today - datetime.timedelta(days=7)

        context = super(TestSuiteDetailView, self).get_context_data(**kwargs)

        context['form'] = self.get_form()
        cdata = context['form'].cleaned_data

        context['result_overview_from'] = cdata.get("result_overview_from")
        context['result_overview_to'] = cdata.get("result_overview_to")
        context['executed_tests_from'] = cdata.get("executed_tests_from")
        context['executed_tests_to'] = cdata.get("executed_tests_to")

        result_overview_from = self.tz_and_dateify(
            context['result_overview_from'])
        result_overview_to = self.tz_and_dateify(context['result_overview_to'])
        executed_tests_from = self.tz_and_dateify(
            context['executed_tests_from'])
        executed_tests_to = self.tz_and_dateify(context['executed_tests_to'])

        if self.object:
            context['test_data'] = self.object.test_data(
                result_overview_from, result_overview_to)

            qs = self.object.testrun_set
            if executed_tests_from:
                qs = qs.filter(started__gte=executed_tests_from)
            if executed_tests_to:
                qs = qs.filter(started__lt=executed_tests_to +
                               datetime.timedelta(days=1))

            context['runs'] = qs.order_by('-started')

        return context

    def get_form(self):
        if not self.form:
            # Make new form object
            self.form = TestSuiteDetailForm(self.request.GET, )
            # Process the form
            self.form.is_valid()
        return self.form
Esempio n. 3
0
 def get_form(self):
     if not self.form:
         # Make new form object
         self.form = TestSuiteDetailForm(
             self.request.GET,
         )
         # Process the form
         self.form.is_valid()
     return self.form
Esempio n. 4
0
class TestSuiteDetailView(DetailView):
    model = TestSuite
    template_name = 'testsuite.html'
    context_object_name = 'testsuite'
    form = None

    def tz_and_dateify(self, date):
        if not date:
            return None

        return timezone.datetime(
            year=date.year,
            month=date.month,
            day=date.day,
            hour=0,
            minute=0,
            tzinfo=timezone.get_current_timezone()
        )

    def get_context_data(self, **kwargs):
        today = timezone.now().date()
        one_week_ago = today - datetime.timedelta(days=7)

        context = super(TestSuiteDetailView, self).get_context_data(**kwargs)

        context['form'] = self.get_form()
        cdata = context['form'].cleaned_data

        context['result_overview_from'] = cdata.get("result_overview_from")
        context['result_overview_to'] = cdata.get("result_overview_to")
        context['executed_tests_from'] = cdata.get("executed_tests_from")
        context['executed_tests_to'] = cdata.get("executed_tests_to")

        result_overview_from = self.tz_and_dateify(
            context['result_overview_from']
        )
        result_overview_to = self.tz_and_dateify(
            context['result_overview_to']
        )
        executed_tests_from = self.tz_and_dateify(
            context['executed_tests_from']
        )
        executed_tests_to = self.tz_and_dateify(
            context['executed_tests_to']
        )


        if self.object:
            context['test_data'] = self.object.test_data(
                result_overview_from,
                result_overview_to
            )


            qs = self.object.testrun_set
            if executed_tests_from:
                qs = qs.filter(started__gte=executed_tests_from)
            if executed_tests_to:
                qs = qs.filter(
                    started__lt=executed_tests_to + datetime.timedelta(days=1)
                )

            context['runs'] = qs.order_by('-started')

        return context

    def get_form(self):
        if not self.form:
            # Make new form object
            self.form = TestSuiteDetailForm(
                self.request.GET,
            )
            # Process the form
            self.form.is_valid()
        return self.form