def get_context_data(self, **kwargs): context = super(UpdateServerGroupView, self).get_context_data(**kwargs) context['server_form'] = ServerForm() context['server_group_form'] = ServerGroupForm() context['server_group_formset'] = context['formset'] context['groups'] = ServerGroup.objects.all().order_by('name') context['nogroup_servers'] = Server.objects.filter( servergroup__isnull=True).order_by('hostname') return context
def get_context_data(self, **kwargs): context = super(AddServerGroupView, self).get_context_data(**kwargs) ServerGroupFormSet = modelformset_factory(ServerGroup, form=ServerGroupForm) context['server_form'] = ServerForm() context['server_group_form'] = context['form'] context['server_group_formset'] = ServerGroupFormSet( queryset=ServerGroup.objects.all().select_related()) context['groups'] = ServerGroup.objects.all().order_by('name') context['nogroup_servers'] = Server.objects.filter( servergroup__isnull=True).order_by('hostname') return context
def get_server_list_context_data(): ServerGroupFormSet = modelformset_factory(ServerGroup, form=ServerGroupForm) return { 'server_form': ServerForm(), 'server_group_form': ServerGroupForm(), 'server_group_formset': ServerGroupFormSet( queryset=ServerGroup.objects.all().select_related()), 'groups': ServerGroup.objects.all().order_by('name'), 'nogroup_servers': Server.objects.filter(servergroup__isnull=True).order_by('hostname'), }
def server_list(request): ServerGroupFormSet = modelformset_factory(ServerGroup, form=ServerGroupForm) data = { 'server_form': ServerForm(), 'server_group_form': ServerGroupForm(), 'server_group_formset': ServerGroupFormSet( queryset=ServerGroup.objects.all().select_related()), 'groups': ServerGroup.objects.all().order_by('name'), 'nogroup_servers': Server.objects.filter(servergroup__isnull=True).order_by('hostname'), } return render(request, 'server-list.html', data)
def server_detail(request, server_id): try: server = Server.objects.get(pk=server_id) except: raise Http404 form = ServerForm(instance=server) data = { 'server_form': form, 'server': server, 'groups': ServerGroup.objects.all().order_by('name'), 'nogroup_servers': Server.objects.filter(servergroup__isnull=True).order_by('hostname') } return render(request, 'server-detail.html', data)
def server_detail(request, server_id): try: server = Server.objects.get(pk=server_id) except: raise Http404 form = ServerForm(instance=server) data = { 'graphtypes': GraphType.objects.all(), 'server_form': form, 'server': server, 'groups': ServerGroup.objects.all().order_by('name'), 'nogroup_servers': Server.objects.filter(servergroup__isnull=True).order_by('hostname'), 'default_view': getattr(settings, "SKWISSH_DEFAULT_VIEW", 'hour') in ('last', 'hour', 'day', 'week', 'month') and getattr(settings, "SKWISSH_DEFAULT_VIEW", 'hour') or 'hour' } return render(request, 'server-detail.html', data)