Esempio n. 1
0
    def get_context_data(self, **kwargs):

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

        # Hosts Table (Stage->Host Through table)
        stage_hosts = self.object.hosts.all()

        host_table = tables.StageHostTable(
            stage_hosts, stage_id=self.object.pk)  # Through table
        RequestConfig(self.request).configure(host_table)
        context['hosts'] = host_table

        context['available_hosts'] = Host.objects.exclude(
            id__in=[host.pk for host in stage_hosts]).all()

        # Configuration Table
        configuration_table = tables.ConfigurationTable(
            self.object.stage_configurations())
        RequestConfig(self.request).configure(configuration_table)
        context['configurations'] = configuration_table

        # deployment table
        deployment_table = tables.DeploymentTable(
            models.Deployment.objects.filter(stage=self.object).select_related(
                'stage', 'task'),
            prefix='deploy_')
        RequestConfig(self.request).configure(deployment_table)
        context['deployment_table'] = deployment_table

        return context
Esempio n. 2
0
    def get_context_data(self, **kwargs):
        context = super(ProjectDetail, self).get_context_data(**kwargs)

        configuration_table = tables.ConfigurationTable(
            self.object.project_configurations(), prefix='config_')
        RequestConfig(self.request).configure(configuration_table)
        context['configurations'] = configuration_table

        stages = self.object.get_stages().annotate(
            deployment_count=Count('deployment'))
        context['stages'] = stages

        stage_table = tables.StageTable(stages, prefix='stage_')
        RequestConfig(self.request).configure(stage_table)
        context['stage_table'] = stage_table

        deployment_table = tables.DeploymentTable(
            models.Deployment.objects.filter(stage__in=stages).select_related(
                'stage', 'task'),
            prefix='deploy_')
        RequestConfig(self.request).configure(deployment_table)
        context['deployment_table'] = deployment_table

        hook_table = HookTable(self.object.web_hooks(False))
        RequestConfig(self.request).configure(hook_table)
        context['hook_table'] = hook_table

        return context