Exemple #1
0
def edit_dc(request, dcid):
    "Edit a Destination component"
    dcomp = get_object_or_404(DestinationComponent, pk=dcid)
    if request.method == "POST":
        form = DCForm(request.POST, instance=dcomp)
        if form.is_valid():
            try:
                model = form.save(commit=False)
                model.save()
                form.save_m2m()
                msg = _("The destination component has been updated")
            except DatabaseError:
                msg = _("The destination component could not be updated")
            messages.info(request, msg)
            return HttpResponseRedirect(reverse("dc-rules"))
    else:
        form = DCForm(instance=dcomp)
    for name in ["url", "domain", "regex"]:
        form.fields[name].widget.attrs["size"] = "45"
    return render_to_response("web/config/edit_dc.html", locals(), context_instance=RequestContext(request))
Exemple #2
0
def add_dc(request):
    "add a destination component"
    if request.method == "POST":
        form = DCForm(request.POST)
        if form.is_valid():
            try:
                model = form.save(commit=False)
                model.save()
                form.save_m2m()
                msg = _("The destination component was created successfully")
                messages.info(request, msg)
                return HttpResponseRedirect(reverse("dc-rules"))
            except DatabaseError:
                msg = _("The destination component could not be created")
                messages.info(request, msg)
                return HttpResponseRedirect(reverse("dc-rules"))
    else:
        form = DCForm()
    for name in ["url", "domain", "regex"]:
        form.fields[name].widget.attrs["size"] = "45"
    return render_to_response("web/config/add_dc.html", locals(), context_instance=RequestContext(request))
Exemple #3
0
def edit_dc(request, dcid):
    "Edit a Destination component"
    dcomp = get_object_or_404(DestinationComponent, pk=dcid)
    if request.method == 'POST':
        form = DCForm(request.POST, instance=dcomp)
        if form.is_valid():
            try:
                model = form.save(commit=False)
                model.save()
                form.save_m2m()
                msg = _('The destination component has been updated')
            except DatabaseError:
                msg = _('The destination component could not be updated')
            messages.info(request, msg)
            return HttpResponseRedirect(reverse('dc-rules'))
    else:
        form = DCForm(instance=dcomp)
    for name in ['url', 'domain', 'regex']:
        form.fields[name].widget.attrs['size'] = '45'
    return render_to_response('web/config/edit_dc.html',
                              locals(),
                              context_instance=RequestContext(request))
Exemple #4
0
def add_dc(request):
    "add a destination component"
    if request.method == 'POST':
        form = DCForm(request.POST)
        if form.is_valid():
            try:
                model = form.save(commit=False)
                model.save()
                form.save_m2m()
                msg = _('The destination component was created successfully')
                messages.info(request, msg)
                return HttpResponseRedirect(reverse('dc-rules'))
            except DatabaseError:
                msg = _('The destination component could not be created')
                messages.info(request, msg)
                return HttpResponseRedirect(reverse('dc-rules'))
    else:
        form = DCForm()
    for name in ['url', 'domain', 'regex']:
        form.fields[name].widget.attrs['size'] = '45'
    return render_to_response('web/config/add_dc.html',
                              locals(),
                              context_instance=RequestContext(request))