def add_sources(request): if request.method == 'POST': V = get_object_or_404(View.objects.filter(pk=request.POST['view_id'])) V.sources.add(*request.POST.getlist('source_ids[]')) messages.success(request, _("Source(s) added with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {}) else: return render(request, 'modals/add_sources.html', { 'views': View.objects.all(), 'sources': Data_Source.objects.filter(pk__in=request.GET.getlist('ids[]')) })
def update(request, host_id): H = get_object_or_404(Host.objects.filter(pk=host_id)) F = Host_Form(data=request.POST, instance=H) data = {} if F.is_valid(): F.save() messages.success(request, _("Host updated with success.")) data['response'] = 'ok' data['callback-url'] = H.get_absolute_url() else: for field, error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field, error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def update(request, storage_id): S = get_object_or_404(Storage.objects.filter(pk=storage_id)) F = Storage_Form(data=request.POST, instance=S) data = {} if F.is_valid(): F.save() messages.success(request, _("Storage updated with success.")) data['response'] = 'ok' data['callback-url'] = S.get_absolute_url() else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def add_sources(request): if request.method == 'POST': V = get_object_or_404(View.objects.filter(pk=request.POST['view_id'])) V.sources.add(*request.POST.getlist('source_ids[]')) messages.success(request, _("Source(s) added with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {}) else: return render( request, 'modals/add_sources.html', { 'views': View.objects.all(), 'sources': Data_Source.objects.filter(pk__in=request.GET.getlist('ids[]')) })
def update(request, user_id): """Update a user.""" U = get_object_or_404(User.objects.filter(pk=user_id)) F = User_Admin_EditForm(data=request.POST, instance=U) data = {} if F.is_valid(): F.save() messages.success(request, _("User updated with success.")) data['response'] = 'ok' data['callback-url'] = U.get_absolute_url() else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def update(request, user_id): """Update a user.""" U = get_object_or_404(User.objects.filter(pk=user_id)) F = User_Admin_EditForm(data=request.POST, instance=U) data = {} if F.is_valid(): F.save() messages.success(request, _("User updated with success.")) data['response'] = 'ok' data['callback-url'] = U.get_absolute_url() else: for field, error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field, error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def update(request, plugin_id): """Update a plugin.""" P = get_object_or_404(Plugin.objects.filter(pk=plugin_id)) F = Plugin_Form(data=request.POST, instance=P) data = {} if F.is_valid(): F.save() messages.success(request, _("Plugin updated with success.")) data['response'] = 'ok' data['callback-url'] = P.get_absolute_url() else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def update(request, skeleton_id): S = get_object_or_404(Skeleton.objects.filter(pk=skeleton_id)) F = Skeleton_Form(data=request.POST, instance=S) data = {} if F.is_valid(): F.save() messages.success(request, _("Skeleton updated with success.")) data.update({ 'response': 'ok', 'callback-url': S.get_absolute_url(), 'id': S.id, }) else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def update(request, multiview_id): M = get_object_or_404(Multiview.objects.filter(pk=multiview_id)) F = Multiview_Form(data=request.POST, instance=M, user=request.user) data = {} if F.is_valid(): F.save() messages.success(request, _("Multiview updated with success.")) data.update({ 'response': 'ok', 'callback-url': M.get_absolute_url(), 'id': M.id, }) else: for field, error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field, error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def update(request, view_id): V = get_object_or_404(View.objects.filter(pk=view_id)) F = View_Form(data=request.POST, instance=V, user=request.user) data = {} if F.is_valid(): F.save() messages.success(request, _("View updated with success.")) data.update({ 'response':'ok', 'callback-url': V.get_absolute_url(), 'id': V.pk, }) else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def add(request): if request.method == 'POST': F = Storage_Form(request.POST) data = {} if F.is_valid(): S = F.save() messages.success(request, _("Storage added with success.")) data['response'] = 'ok' data['callback-url'] = S.get_absolute_url() else: for field, error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field, error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {}) else: return render(request, 'storages/storage.html', { 'Storage_Form': Storage_Form(), })
def add(request): if request.method == 'POST': F = Storage_Form(request.POST) data = {} if F.is_valid(): S = F.save() messages.success(request, _("Storage added with success.")) data['response'] = 'ok' data['callback-url'] = S.get_absolute_url() else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {}) else: return render(request, 'storages/storage.html', { 'Storage_Form': Storage_Form(), })
def use(request, skeleton_id): S = get_object_or_404(Skeleton.objects.filter(pk=skeleton_id)) if request.method == 'GET': F = Skeleton_To_View_Form(user=request.user, skeleton=S) return render(request, 'modals/use-skeleton.html', { 'Skeleton_To_View_Form': F, }) else: F = Skeleton_To_View_Form(user=request.user, skeleton=S, data=request.POST) data = {} if F.is_valid(): messages.success(request, _("View creatted with success.")) data['response'] = 'ok' data['callback-url'] = S.get_absolute_url() else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {})
def add(request): if request.method == 'POST': F = Multiview_Form(data=request.POST, user=request.user) data = {} if F.is_valid(): M = F.save() messages.success(request, _("Multiview added with success.")) data.update({ 'response': 'ok', 'callback-url': M.get_absolute_url(), 'id': M.pk, }) else: for field, error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field, error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {}) else: return render(request, 'forms/multiview.html', { 'Multiview_Form': Multiview_Form(user=request.user), })
def add(request): if request.method == 'POST': F = Skeleton_Form(data=request.POST) data = {} if F.is_valid(): S = F.save() messages.success(request, _("Skeleton added with success.")) data.update({ 'response': 'ok', 'callback-url': S.get_absolute_url(), 'id': S.pk, }) else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {}) else: return render(request, 'forms/skeleton.html', { 'Skeleton_Form': Skeleton_Form(), })
def add(request): if request.method == 'POST': data = {} F = Event_Form(request.POST) if F.is_valid(): E = F.save() messages.success(request, _("Event added with success.")) data.update({ 'response': 'ok', 'callback-url': E.get_absolute_url(), 'id':E.pk, }) else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {}) else: return render(request, 'views/event.html', { 'Event_Form': Event_Form(), })
def add(request): if request.method == 'POST': data = {} F = View_Form(data=request.POST, user=request.user) if F.is_valid(): V = F.save() messages.success(request, _("View added with success.")) data.update({ 'response': 'ok', 'callback-url': V.get_absolute_url(), 'id':V.pk, }) else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {}) else: return render(request, 'forms/view.html', { 'View_Form': View_Form(user=request.user), })
def add(request): """ GET: User Form. POST: Create user. """ if request.method == 'POST': F = User_CreationForm(request.POST) data = {} if F.is_valid(): U = F.save() messages.success(request, _("User added with success.")) data['response'] = 'ok' data['callback-url'] = U.get_absolute_url() else: for field,error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field,error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {}) else: return render(request, 'users/user.html', { 'User_Form': User_CreationForm(), })
def add(request): """ GET: User Form. POST: Create user. """ if request.method == 'POST': F = User_CreationForm(request.POST) data = {} if F.is_valid(): U = F.save() messages.success(request, _("User added with success.")) data['response'] = 'ok' data['callback-url'] = U.get_absolute_url() else: for field, error in F.errors.items(): messages.error(request, '<b>%s</b>: %s' % (field, error)) data['response'] = 'error' return render_HTML_JSON(request, data, 'base/messages.html', {}) else: return render(request, 'users/user.html', { 'User_Form': User_CreationForm(), })
def bulk_delete(request): """Delete several views in one request.""" views = View.objects.filter(pk__in=request.POST.getlist('ids[]')) views.delete() messages.success(request, _("View(s) deleted with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {})
def bulk_delete(request): """Delete several multiviews in one request.""" multiviews = Multiview.objects.filter(pk__in=request.POST.getlist('ids[]')) multiviews.delete() messages.success(request, _("Multiview(s) deleted with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {})
def bulk_delete(request): """Delete several hosts in one request.""" hosts = Host.objects.filter(pk__in=request.POST.getlist('ids[]')) hosts.delete() messages.success(request, _("Hosts deleted with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {})
def bulk_delete(request): """Delete several sources in one request.""" sources = Data_Source.objects.filter(pk__in=request.POST.getlist('ids[]')) sources.delete() messages.success(request, _("Source(s) deleted with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {})
def bulk_delete(request): """Delete several plugins in one request.""" plugins = Plugin.objects.filter(pk__in=request.POST.getlist('ids[]')) plugins.delete() messages.success(request, _("Plugin(s) deleted with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {})
def bulk_delete(request): """Delete several groups in one request.""" groups = Group.objects.filter(pk__in=request.POST.getlist('ids[]')) groups.delete() messages.success(request, _("Group(s) deleted with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {})
def bulk_delete(request): """Delete several users in one request.""" users = User.objects.filter(pk__in=request.POST.getlist('ids[]')) users.delete() messages.success(request, _("User(s) deleted with success.")) return render_HTML_JSON(request, {}, 'base/messages.html', {})