示例#1
0
文件: views.py 项目: rajibmitra/cabot
 def render_to_response(self, context, *args, **kwargs):
     context = super(StatusCheckListView, self).get_context_data(**kwargs)
     if context is None:
         context = {}
     context['custom_check_types'] = get_custom_check_plugins()
     context['checks'] = StatusCheck.objects.all().order_by('name').prefetch_related('service_set', 'instance_set')
     return super(StatusCheckListView, self).render_to_response(context, *args, **kwargs)
示例#2
0
文件: views.py 项目: tsocial/cabot
    def get(self, request, pk, alerttype):
        try:
            profile = UserProfile.objects.get(user=pk)
        except UserProfile.DoesNotExist:
            user = User.objects.get(id=pk)
            profile = UserProfile(user=user)
            profile.save()

        profile.user_data()

        if alerttype == u'General':
            form = GeneralSettingsForm(
                initial={
                    'first_name': profile.user.first_name,
                    'last_name': profile.user.last_name,
                    'email_address': profile.user.email,
                    'enabled': profile.user.is_active,
                })
        else:
            plugin_userdata = self.model.objects.get(title=alerttype,
                                                     user=profile)
            form_model = get_object_form(type(plugin_userdata))
            form = form_model(instance=plugin_userdata)

        return render(
            request, self.template.template.name, {
                'form': form,
                'alert_preferences': profile.user_data(),
                'custom_check_types': get_custom_check_plugins(),
            })
示例#3
0
文件: views.py 项目: rajibmitra/cabot
 def render_to_response(self, context, *args, **kwargs):
     if context is None:
         context = {}
     context['custom_check_types'] = get_custom_check_plugins()
     context['checkresults'] = self.object.statuscheckresult_set.order_by(
         '-time_complete')[:100]
     return super(StatusCheckDetailView, self).render_to_response(context, *args, **kwargs)
示例#4
0
文件: views.py 项目: UbimoLTD/cabot
 def render_to_response(self, context, *args, **kwargs):
     if context is None:
         context = {}
     context['custom_check_types'] = get_custom_check_plugins()
     context['checkresults'] = self.object.statuscheckresult_set.order_by(
         '-time_complete')[:100]
     return super(StatusCheckDetailView, self).render_to_response(context, *args, **kwargs)
示例#5
0
文件: views.py 项目: UbimoLTD/cabot
 def render_to_response(self, context, *args, **kwargs):
     context = super(StatusCheckListView, self).get_context_data(**kwargs)
     if context is None:
         context = {}
     context['custom_check_types'] = get_custom_check_plugins()
     context['checks'] = StatusCheck.objects.all().order_by('name').prefetch_related('service_set', 'instance_set')
     return super(StatusCheckListView, self).render_to_response(context, *args, **kwargs)
示例#6
0
文件: views.py 项目: arachnys/cabot
    def get(self, request, pk, alerttype):
        try:
            profile = UserProfile.objects.get(user=pk)
        except UserProfile.DoesNotExist:
            user = User.objects.get(id=pk)
            profile = UserProfile(user=user)
            profile.save()

        profile.user_data()

        if alerttype == u'General':
            form = GeneralSettingsForm(initial={
                'first_name': profile.user.first_name,
                'last_name': profile.user.last_name,
                'email_address': profile.user.email,
                'enabled': profile.user.is_active,
            })
        else:
            plugin_userdata = self.model.objects.get(title=alerttype, user=profile)
            form_model = get_object_form(type(plugin_userdata))
            form = form_model(instance=plugin_userdata)

        return render(request, self.template.template.name, {
            'form': form,
            'alert_preferences': profile.user_data(),
            'custom_check_types': get_custom_check_plugins(),
        })
示例#7
0
def subscriptions(request):
    """ Simple list of all checks """
    services = Service.objects.all()
    users = User.objects.filter(is_active=True)

    return render(request, 'cabotapp/subscriptions.html', {
        'services': services,
        'users': users,
        'duty_officers': get_duty_officers(),
        'custom_check_types': get_custom_check_plugins(),
    })
示例#8
0
文件: views.py 项目: rajibmitra/cabot
 def get_context_data(self, **kwargs):
     context = super(InstanceDetailView, self).get_context_data(**kwargs)
     date_from = date.today() - relativedelta(day=1)
     context['custom_check_types'] = get_custom_check_plugins()
     context['report_form'] = StatusCheckReportForm(initial={
         'checks': self.object.status_checks.all(),
         'service': self.object,
         'date_from': date_from,
         'date_to': date_from + relativedelta(months=1) - relativedelta(days=1)
     })
     return context
示例#9
0
文件: views.py 项目: UbimoLTD/cabot
 def get_context_data(self, **kwargs):
     context = super(InstanceDetailView, self).get_context_data(**kwargs)
     date_from = date.today() - relativedelta(day=1)
     context['custom_check_types'] = get_custom_check_plugins()
     context['report_form'] = StatusCheckReportForm(initial={
         'checks': self.object.status_checks.all(),
         'service': self.object,
         'date_from': date_from,
         'date_to': date_from + relativedelta(months=1) - relativedelta(days=1)
     })
     return context
示例#10
0
文件: views.py 项目: arachnys/cabot
def subscriptions(request):
    """ Simple list of all checks """
    services = Service.objects.all()
    users = User.objects.filter(is_active=True)

    return render(request, 'cabotapp/subscriptions.html', {
        'services': services,
        'users': users,
        'duty_officers': get_duty_officers(),
        'custom_check_types': get_custom_check_plugins(),
    })
示例#11
0
文件: views.py 项目: tsocial/cabot
    def get(self, request, plugin_name):
        if plugin_name == u'global':
            form = CoreSettingsForm()
            alert_test_form = AlertTestForm()
        else:
            plugin = self.model.objects.get(title=plugin_name)
            form_model = get_object_form(type(plugin))
            form = form_model(instance=plugin)
            alert_test_form = AlertTestPluginForm(
                initial={'alert_plugin': plugin})

        return render(
            request, self.template.template.name, {
                'form': form,
                'plugins': AlertPlugin.objects.all(),
                'plugin_name': plugin_name,
                'alert_test_form': alert_test_form,
                'custom_check_types': get_custom_check_plugins()
            })
示例#12
0
文件: views.py 项目: arachnys/cabot
    def get(self, request, plugin_name):
        if plugin_name == u'global':
            form = CoreSettingsForm()
            alert_test_form = AlertTestForm()
        else:
            plugin = self.model.objects.get(title=plugin_name)
            form_model = get_object_form(type(plugin))
            form = form_model(instance=plugin)
            alert_test_form = AlertTestPluginForm(initial = {
                'alert_plugin': plugin
            })

        return render(request, self.template.template.name, {
            'form': form,
            'plugins': AlertPlugin.objects.all(),
            'plugin_name': plugin_name,
            'alert_test_form': alert_test_form,
            'custom_check_types': get_custom_check_plugins()
        })
示例#13
0
文件: views.py 项目: tsocial/cabot
 def render_to_response(self, context, *args, **kwargs):
     if context is None:
         context = {}
     context['custom_check_types'] = get_custom_check_plugins()
     return super(BaseCommonView,
                  self).render_to_response(context, *args, **kwargs)
示例#14
0
文件: views.py 项目: arachnys/cabot
 def render_to_response(self, context, *args, **kwargs):
     if context is None:
         context = {}
     context['custom_check_types'] = get_custom_check_plugins()
     return super(BaseCommonView, self).render_to_response(context, *args, **kwargs)