Exemplo n.º 1
0
def hardware_add(request, type_id=None, object_id=None):
    if object_id is None:
        web = webs.hardware_web()
        breadcrumbs = web.get_add_breadcrumbs()
    else:
        object = get_object_or_404(models.hardware, pk=object_id)
        object = object.get_object()
        web = webs.get_web_from_object(object)
        breadcrumbs = web.get_view_breadcrumbs(object)
        breadcrumbs.append(webs.breadcrumb(web.get_add_to_instance_url(object,type_id),"add hardware"))

    if request.method == 'POST':
        form = forms.hardware_type_form(request.POST, request.FILES)

        if form.is_valid():
            new_type = form.cleaned_data['type']
            url = web.get_add_url(new_type)
            url = request.GET.get("next",url)
            return HttpResponseRedirect(url)
    else:
        form = forms.hardware_type_form()

    return render_to_response("lintory/hardware_type.html", {
            'breadcrumbs': breadcrumbs,
            'form' : form,
            'media' : form.media,
            },context_instance=RequestContext(request))
Exemplo n.º 2
0
def hardware_edit(request, object_id):
    object = get_object_or_404(models.hardware, pk=object_id)
    type_id = object.type_id

    if type_id not in type_dict:
        raise Http404(u"Hardware type '%s' not found"%(type_id))

    object = object.get_object()
    web = webs.get_web_from_object(object)
    return web.object_edit(request, object)
Exemplo n.º 3
0
def render_link(record, title=None):
    if title is None:
        title=u"%s"%(record)

    if record is not None:
        web = webs.get_web_from_object(record)
        return mark_safe(u"<a href='%s'>%s</a>"%(
                web.get_view_url(record),
                conditional_escape(title)))
    else:
        return mark_safe(u"-")
Exemplo n.º 4
0
def get_svg_url(instance):
    web = webs.get_web_from_object(instance)
    return mark_safe(web.get_svg_url(instance))
Exemplo n.º 5
0
def hardware_delete(request, object_id):
    object = get_object_or_404(models.hardware, pk=object_id)
    object = object.get_object()
    web = webs.get_web_from_object(object)
    return web.object_delete(request, object)
Exemplo n.º 6
0
 def render_delete(self, record):
     web = webs.get_web_from_object(record)
     return mark_safe("<a class='deletelink' href='%s?%s'>%s</a>"%(
             web.get_delete_url(record),
             get_next_url(self.request),
             "delete"))
Exemplo n.º 7
0
 def render_edit(self, record):
     web = webs.get_web_from_object(record)
     return mark_safe("<a class='changelink' href='%s?%s'>%s</a>"%(
             web.get_edit_url(record),
             get_next_url(self.request),
             "edit"))