コード例 #1
0
ファイル: view.py プロジェクト: Seraf/numeter
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[]'))
        })
コード例 #2
0
ファイル: host.py プロジェクト: Seraf/numeter
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', {})
コード例 #3
0
ファイル: storage.py プロジェクト: Seraf/numeter
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', {})
コード例 #4
0
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[]'))
            })
コード例 #5
0
ファイル: user.py プロジェクト: Seraf/numeter
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', {})
コード例 #6
0
ファイル: user.py プロジェクト: Seraf/numeter
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', {})
コード例 #7
0
ファイル: plugin.py プロジェクト: Seraf/numeter
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', {})
コード例 #8
0
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', {})
コード例 #9
0
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', {})
コード例 #10
0
ファイル: view.py プロジェクト: Seraf/numeter
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', {})
コード例 #11
0
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(),
        })
コード例 #12
0
ファイル: storage.py プロジェクト: Seraf/numeter
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(),
        })
コード例 #13
0
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', {})
コード例 #14
0
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),
        })
コード例 #15
0
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(),
        })
コード例 #16
0
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(),
        })
コード例 #17
0
ファイル: view.py プロジェクト: Seraf/numeter
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),
        })
コード例 #18
0
ファイル: user.py プロジェクト: Seraf/numeter
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(),
        })
コード例 #19
0
ファイル: user.py プロジェクト: Seraf/numeter
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(),
        })
コード例 #20
0
ファイル: view.py プロジェクト: Seraf/numeter
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', {})
コード例 #21
0
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', {})
コード例 #22
0
ファイル: host.py プロジェクト: Seraf/numeter
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', {})
コード例 #23
0
ファイル: source.py プロジェクト: Seraf/numeter
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', {})
コード例 #24
0
ファイル: plugin.py プロジェクト: Seraf/numeter
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', {})
コード例 #25
0
ファイル: plugin.py プロジェクト: gaelL/numeter
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', {})
コード例 #26
0
ファイル: group.py プロジェクト: Seraf/numeter
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', {})
コード例 #27
0
ファイル: user.py プロジェクト: Seraf/numeter
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', {})
コード例 #28
0
ファイル: source.py プロジェクト: gaelL/numeter
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', {})