Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #1

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 21 additions & 51 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,14 @@
from django.http import HttpResponse
from .models import Machine

import nmap
import neomodel

def index(request):
return redirect("/core/default/action")


# def project(request,project_id):
# # Removing everything as of now
# for allnodes in Machine.nodes:
# allnodes.delete()
#
#
# print "All nodes deleted successfully"
#
# # output = getlocalinfo()
# #
# # localip = output.split("#")[0]
# # localhostname = output.split("#")[1]
# # subnet = output.split("#")[2]
# #
# # gateway = output.split("#")[3]
# # gatewayhostname = output.split("#")[4]
# # # { id : 0, group : 'source', label : '192.168.1.21'},{ id : 1, group : 'device', label : '192.168.1.1'},
# # # #{ from: 1, to: 0 },
# # localnode = Machine(ip=localip, subnet=subnet, hostname=localhostname)
# # localnode.save()
# #
# #
# # gatewaynode = Machine(ip=gateway, subnet=subnet, hostname=gatewayhostname)
# # gatewaynode.save()
# #
# # localnode.connected.connect(gatewaynode)
#
# context = {"myinfo": "project", "project_id": project_id}
# return render(request, 'project.html', context)
import nmap

def index(request):
return redirect("/core/default/action")

def action(request, project_id):

Expand All @@ -68,17 +40,17 @@ def action(request, project_id):
print "Current Project: " + project_id
print "Project Count: " + str(len(projectform.PROJECT_CHOICES))

projectAvailble = False
for i in range(0, len(projectform.PROJECT_CHOICES)):
key, value = projectform.PROJECT_CHOICES[i]
if project_id == key:
print "Got Project: " + project_id
projectAvailble = True
break

if not projectAvailble:
print "Info: Project Not Found. Returning to default..."
return redirect("/core/default/action")
# projectAvailble = False
# for i in range(0, len(projectform.PROJECT_CHOICES)):
# key, value = projectform.PROJECT_CHOICES[i]
# if project_id == key:
# print "Got Project: " + project_id
# projectAvailble = True
# break
#
# if not projectAvailble:
# print "Info: Project Not Found. Returning to default..."
# return redirect("/core/default/action")

if request.method == "POST":
print "Info: Request is POST"
Expand All @@ -103,7 +75,8 @@ def action(request, project_id):
newprojectform = NewProjectForm(request.POST)
# scanform = ScanForm()
# gotoform = GoToForm()
# projectform = ProjectForm()
# projectform = ProjectForm(request.POST)
print "In new project create block"
if newprojectform.is_valid():
project_id = str(newprojectform.cleaned_data["newproject"])
action = "create"
Expand All @@ -113,23 +86,17 @@ def action(request, project_id):
# scanform = ScanForm()
# gotoform = GoToForm()
# newprojectform = NewProjectForm()

if projectform.is_valid():
action="select"
project_id = str(projectform.cleaned_data["project"])
print "Project: " + project_id

else:
action=request.GET.get("action","show")
# scanform = ScanForm()
# gotoform = GoToForm()
# projectform = ProjectForm()
# newprojectform = NewProjectForm()

#
# for allnodes in Machine.nodes:
# allnodes.delete()
#
# print "Delete successfully"
print "Action is : " + action

if "findme" in action:
Expand Down Expand Up @@ -190,6 +157,9 @@ def action(request, project_id):

# project, test = projectform.PROJECT_CHOICES[project_id-1]
output = getlocalinfo(project_id)
# neomodel.db.set_connection('bolt://neo4j:Neo4j@localhost:7687')
# neomodel.Database.__init__()
print "Reinitialized DB"
# print "Project Count in Create: " + str(len(projectform.PROJECT_CHOICES))
context = {"project_id": project_id, "newprojectform": newprojectform,
"gotoform": gotoform,
Expand Down