Ejemplo n.º 1
0
def location_edit(request, location_id=None, action='edit'):
    info = LocationInfo()
    if location_id:
        copy_url = reverse_lazy(info.copy_url_name,
                                kwargs={
                                    'action': 'copy',
                                    'location_id': location_id
                                })
    else:
        copy_url = None

    _title = 'Use this location as a template for creating a new location'
    if location_id:
        detail_page_url = reverse_lazy('location-info',
                                       kwargs={'locationid': location_id})
    else:
        detail_page_url = ""
    extra_context = {
        'copy_url': copy_url,
        'copy_title': _title,
        'detail_page_url': detail_page_url,
    }
    extra_context.update(info.template_context)
    return render_edit(
        request,
        Location,
        LocationForm,
        location_id,
        'seeddb-location-edit',
        extra_context=extra_context,
        action=action,
    )
Ejemplo n.º 2
0
Archivo: room.py Proyecto: hmpf/nav
def room_edit(request, action='edit', room_id=None, lat=None, lon=None):
    """Controller for editing a room"""
    info = RoomInfo()
    if room_id:
        copy_url = reverse_lazy(
            info.copy_url_name, kwargs={'action': 'copy', 'room_id': room_id}
        )
    else:
        copy_url = None
    roompositions = [
        [float(r.position[0]), float(r.position[1])]
        for r in Room.objects.all()
        if r.position
    ]
    extra_context = {
        'map': True,
        'roompositions': roompositions,
        'copy_url': copy_url,
        'copy_title': 'Use this room as a template for creating a new room',
    }

    extra_context.update(info.template_context)
    return render_edit(
        request,
        Room,
        RoomForm,
        room_id,
        'seeddb-room-edit',
        lon=lon,
        lat=lat,
        extra_context=extra_context,
        action=action,
    )
Ejemplo n.º 3
0
def cabling_edit(request, cabling_id=None):
    info = CablingInfo()
    return render_edit(request,
                       Cabling,
                       CablingForm,
                       cabling_id,
                       'seeddb-cabling-edit',
                       extra_context=info.template_context)
Ejemplo n.º 4
0
def patch_edit(request, patch_id=None):
    info = PatchInfo()
    return render_edit(request,
                       Patch,
                       PatchForm,
                       patch_id,
                       'seeddb-patch-edit',
                       extra_context=info.template_context)
Ejemplo n.º 5
0
def netboxgroup_edit(request, netboxgroup_id=None):
    info = NetboxGroupInfo()
    return render_edit(request,
                       NetboxGroup,
                       NetboxGroupForm,
                       netboxgroup_id,
                       'seeddb-netboxgroup-edit',
                       extra_context=info.template_context)
Ejemplo n.º 6
0
def netboxtype_edit(request, type_id=None):
    info = NetboxTypeInfo()
    return render_edit(request,
                       NetboxType,
                       NetboxTypeForm,
                       type_id,
                       'seeddb-type-edit',
                       extra_context=info.template_context)
Ejemplo n.º 7
0
def organization_edit(request, organization_id=None):
    info = OrganizationInfo()
    return render_edit(request,
                       Organization,
                       OrganizationForm,
                       organization_id,
                       'seeddb-organization-edit',
                       extra_context=info.template_context)
Ejemplo n.º 8
0
def location_edit(request, location_id=None):
    info = LocationInfo()
    return render_edit(request,
                       Location,
                       LocationForm,
                       location_id,
                       'seeddb-location-edit',
                       extra_context=info.template_context)
Ejemplo n.º 9
0
def room_edit(request, room_id=None, lat=None, lon=None):
    """Controller for editing a room"""
    info = RoomInfo()
    extra_context = {'map': True}
    extra_context.update(info.template_context)
    return render_edit(request, Room, RoomForm, room_id,
                       'seeddb-room-edit', lon=lon, lat=lat,
                       extra_context=extra_context)
Ejemplo n.º 10
0
def vendor_edit(request, vendor_id=None):
    info = VendorInfo()
    return render_edit(request,
                       Vendor,
                       VendorForm,
                       vendor_id,
                       'seeddb-vendor',
                       extra_context=info.template_context)
Ejemplo n.º 11
0
def netboxgroup_edit(request, netboxgroup_id=None):
    info = NetboxGroupInfo()
    return render_edit(request,
                       NetboxGroup,
                       DeviceGroupForm,
                       netboxgroup_id,
                       'seeddb-netboxgroup-edit',
                       template='seeddb/edit_device_group.html',
                       extra_context=info.template_context)
Ejemplo n.º 12
0
def vlan_edit(request, vlan_id=None):
    info = VlanInfo()
    return render_edit(request,
                       Vlan,
                       VlanForm,
                       vlan_id,
                       'seeddb-vlan-edit',
                       template='seeddb/edit_vlan.html',
                       extra_context=info.template_context)
Ejemplo n.º 13
0
def usage_edit(request, usage_id=None):
    """The view used when editing usages"""
    info = UsageInfo()
    return render_edit(request,
                       Usage,
                       UsageForm,
                       usage_id,
                       'seeddb-usage-edit',
                       extra_context=info.template_context)
Ejemplo n.º 14
0
def cabling_edit(request):
    info = CablingInfo()
    cabling_id = request.GET.get('cablingid')
    return render_edit(request,
                       Cabling,
                       CablingForm,
                       cabling_id,
                       'seeddb-cabling-edit',
                       extra_context=info.template_context)
Ejemplo n.º 15
0
def vendor_edit(request, vendor_id=None):
    """The view used when editing vendors"""
    info = VendorInfo()
    return render_edit(request,
                       Vendor,
                       VendorForm,
                       vendor_id,
                       'seeddb-vendor',
                       extra_context=info.template_context)
Ejemplo n.º 16
0
def room_edit(request, room_id=None, lat=None, lon=None):
    """Controller for editing a room"""
    info = RoomInfo()
    roompositions = [[float(r.position[0]), float(r.position[1])]
                     for r in Room.objects.all()
                     if r.position]
    extra_context = {'map': True, 'roompositions': roompositions}

    extra_context.update(info.template_context)
    return render_edit(request, Room, RoomForm, room_id,
                       'seeddb-room-edit', lon=lon, lat=lat,
                       extra_context=extra_context)
Ejemplo n.º 17
0
def room_edit(request, room_id=None, lat=None, lon=None):
    """Controller for editing a room"""
    info = RoomInfo()
    extra_context = {'map': True}
    extra_context.update(info.template_context)
    return render_edit(request,
                       Room,
                       RoomForm,
                       room_id,
                       'seeddb-room-edit',
                       lon=lon,
                       lat=lat,
                       extra_context=extra_context)
Ejemplo n.º 18
0
def prefix_edit(request, prefix_id=None):
    """Controller for editing a prefix"""
    info = PrefixInfo()
    prefix, vlan = get_prefix_and_vlan(prefix_id)
    if request.method == 'POST':
        prefix_form = PrefixForm(request.POST, instance=prefix)
        vlan_form = PrefixVlanForm(request.POST, instance=vlan)
        if prefix_form.is_valid() and vlan_form.is_valid():
            vlan = vlan_form.save()
            prefix = prefix_form.save(commit=False)
            prefix.vlan = vlan
            prefix.save()
            msg = "Saved prefix %s" % prefix.net_address
            new_message(request, msg, Messages.SUCCESS)
            return HttpResponseRedirect(
                reverse('seeddb-prefix-edit', args=(prefix.id, )))
    else:
        prefix_form = PrefixForm(instance=prefix, initial=request.GET.dict())
        vlan_form = PrefixVlanForm(instance=vlan, initial=request.GET.dict())
    if prefix_id:
        detail_page_url = reverse_lazy('prefix-details',
                                       kwargs={'prefix_id': prefix_id})
    else:
        detail_page_url = ""
    context = info.template_context
    context.update({
        'object': prefix,
        'form': prefix_form,
        'vlan_form': vlan_form,
        'sub_active': prefix and {
            'edit': True
        } or {
            'add': True
        },
        'detail_page_url': detail_page_url,
    })
    return render_edit(
        request,
        Prefix,
        PrefixForm,
        prefix_id,
        "seeddb-prefix-edit",
        template="seeddb/edit_prefix.html",
        extra_context=context,
    )
Ejemplo n.º 19
0
def netboxgroup_edit(request, netboxgroup_id=None):
    if netboxgroup_id:
        detail_page_url = reverse_lazy('netbox-group-detail',
                                       kwargs={'groupid': netboxgroup_id})
    else:
        detail_page_url = ""
    info = NetboxGroupInfo()
    extra_context = {
        'detail_page_url': detail_page_url,
    }
    extra_context.update(info.template_context)
    return render_edit(
        request,
        NetboxGroup,
        DeviceGroupForm,
        netboxgroup_id,
        'seeddb-netboxgroup-edit',
        template='seeddb/edit_device_group.html',
        extra_context=extra_context,
    )
Ejemplo n.º 20
0
def vlan_edit(request, vlan_id=None):
    if vlan_id:
        detail_page_url = reverse_lazy('vlan-details',
                                       kwargs={'vlanid': vlan_id})
    else:
        detail_page_url = ""
    info = VlanInfo()
    extra_context = {
        'detail_page_url': detail_page_url,
    }
    extra_context.update(info.template_context)
    return render_edit(
        request,
        Vlan,
        VlanForm,
        vlan_id,
        'seeddb-vlan-edit',
        template='seeddb/edit_vlan.html',
        extra_context=extra_context,
    )
Ejemplo n.º 21
0
def vendor_edit(request, vendor_id=None):
    info = VendorInfo()
    return render_edit(request, Vendor, VendorForm, vendor_id,
                       'seeddb-vendor',
                       extra_context=info.template_context)
Ejemplo n.º 22
0
def patch_edit(request, patch_id=None):
    info = PatchInfo()
    return render_edit(request, Patch, PatchForm, patch_id,
                       'seeddb-patch-edit',
                       extra_context=info.template_context)
Ejemplo n.º 23
0
def organization_edit(request, organization_id=None):
    info = OrganizationInfo()
    return render_edit(request, Organization, OrganizationForm,
                       organization_id, 'seeddb-organization-edit',
                       extra_context=info.template_context)
Ejemplo n.º 24
0
def vlan_edit(request, vlan_id=None):
    info = VlanInfo()
    return render_edit(request, Vlan, VlanForm, vlan_id,
                       'seeddb-vlan-edit',
                       template='seeddb/edit_vlan.html',
                       extra_context=info.template_context)
Ejemplo n.º 25
0
def location_edit(request, location_id=None):
    info = LocationInfo()
    return render_edit(request, Location, LocationForm, location_id,
                       'seeddb-location-edit',
                       extra_context=info.template_context)
Ejemplo n.º 26
0
def usage_edit(request, usage_id=None):
    info = UsageInfo()
    return render_edit(request, Usage, UsageForm, usage_id,
                       'seeddb-usage-edit',
                       extra_context=info.template_context)
Ejemplo n.º 27
0
def netboxtype_edit(request, type_id=None):
    info = NetboxTypeInfo()
    return render_edit(request, NetboxType, NetboxTypeForm, type_id,
                       'seeddb-type-edit',
                       extra_context=info.template_context)