diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/DocumentList.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/DocumentList.html
new file mode 100644
index 0000000000..510cf60e9b
--- /dev/null
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/DocumentList.html
@@ -0,0 +1,19 @@
+{% extends "ndf/base.html" %}
+{% block title %} List of Documents {% endblock %}
+{% block body_content %}
+
+
+
+ | File Name |
+ View |
+
+ {% for doc in filecollection %}
+
+ | {{doc.name}} |
+ view |
+
+
+ {% endfor %}
+
+
+{% endblock %}
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/urls.py b/gnowsys-ndf/gnowsys_ndf/ndf/urls.py
index 44c8ca8f67..6acaf8fcfd 100644
--- a/gnowsys-ndf/gnowsys_ndf/ndf/urls.py
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/urls.py
@@ -10,7 +10,10 @@
url(r'^create_wiki/', views.create_wiki, name='create_wiki'),
url(r'^wikipage/', views.wikipage, name='wikipage'),
url(r'^delete/(?P<_id>[\w-]+)$', views.delete_node, name='delete_node'),
- url(r'^uploadDoc/$', TemplateView.as_view(template_name='ndf/UploadDoc.html')),#Direct ot html template
- url(r'^submitDoc/', views.submitDoc, name='submitDoc'),
- url(r'^submit/', views.submitDoc, name='submitDoc')
+
+ url(r'^uploadDoc/$', TemplateView.as_view(template_name='ndf/UploadDoc.html')),#Direct ot html template
+ url(r'^submitDoc/', views.submitDoc, name='submitDoc'),
+ url(r'^submit/', views.submitDoc, name='submitDoc'),
+ url(r'^documentList/', views.GetDoc, name='documentList'),
+ url(r'^readDoc/(?P<_id>[\w-]+)$', views.readDoc, name='read_file'),
)
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/views.py b/gnowsys-ndf/gnowsys_ndf/ndf/views.py
index 8f9a0aa359..a00b450d82 100644
--- a/gnowsys-ndf/gnowsys_ndf/ndf/views.py
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/views.py
@@ -100,6 +100,23 @@ def submitDoc(request):
filetype=magic.from_buffer(files.read()) #Gusing filetype by python-magic
print "test",title,user,memberOf
#this code is for storing Document in gridfs
+ files.seek(0) #moving files cursor to start
objectid=fileobj.fs.files.put(files.read(),filename=title,content_type=filetype)
+ #files.seek(0)
+ #print "fileread:",files.read()
#print "objectid:",objectid
- return HttpResponse("File uploaded succesfully and your object id:"+str(objectid))
+ return HttpResponseRedirect("/ndf/documentList/")
+ #return HttpResponse("File uploaded succesfully and your object id:"+str(objectid))
+
+def GetDoc(request):
+ filecollection=get_database()[File.collection_name]
+ files=filecollection.File.find()
+ template="ndf/DocumentList.html"
+ variable=RequestContext(request,{'filecollection':files})
+ return render_to_response(template,variable)
+
+def readDoc(request,_id):
+ filecollection=get_database()[File.collection_name]
+ fileobj=filecollection.File.one({"_id": ObjectId(_id)})
+ fl=fileobj.fs.files.get_last_version(fileobj.name)
+ return HttpResponse(fl.read(),content_type=fl.content_type)