Beispiel #1
0
def parse_interfaces(request):
    form = UploadInterfaceFileForm(request.POST, request.FILES)

    if form.is_valid():
        try:
            form.save()
        except Exception, e:
            return HttpResponseBadRequest(e)

        event_handler = EventHandler()
        event_handler.add_event(u'Interface file %s was uploaded and parsed successfully' % request.FILES['file'].name)
        logger.debug(u'Interface file %s was uploaded and parsed successfully' % request.FILES['file'].name)

        return HttpResponse(status=201)
Beispiel #2
0
def interface_file(request):
    if request.method == 'POST':
        form = UploadInterfaceFileForm(request.POST, request.FILES)
        
        if form.is_valid():
            try:
                form.save()
            except Exception, e:
                return HttpResponseServerError(e)
            
            event_handler = EventHandler()
            event_handler.add_event(u'Interface file %s was uploaded and parsed successfully' % form.cleaned_data['file'].name)
            logger.debug(u'Interface file %s was uploaded and parsed successfully' % form.cleaned_data['file'].name)
            
            return HttpResponseRedirect(reverse('admin:core_interface_changelist'))