예제 #1
0
 def post(self):
     title = self.request.form.get('title')
     desc = self.request.form.get('desc')
     desc_ru = self.request.form.get('desc_ru')
     file = self.request.files.get('file')
     
     if not title:
         return self.render_response('admin_new_doc.html', **{'no_title':True})
     
     if not file:
         return self.render_response('admin_new_doc.html', **{'no_file':True})
     
     doc = Document(title=title, desc=desc, desc_ru=desc_ru, file_name=file.filename, file=db.Blob(file.read()))
     doc.put()
     return self.redirect('/admin/documents?new=1')
예제 #2
0
 def get(self):
     documents = Document.all().order('-date').fetch(300)
     context = {
         'documents' : documents,
         'new' : self.request.args.get('new')
     }
     return self.render_response('admin_documents.html', **context)
예제 #3
0
 def get(self):
     id = int(self.request.args.get('id'))
     if not id:
         return Response('no id given')
     doc = Document.get_by_id(id)
     if not doc:
         return Response('no doc found')
     doc.delete()
     return self.redirect('/admin/documents?del=1')
예제 #4
0
 def get(self):
     ServeBasics.get(self)
     id = int(self.request.args.get('id'))
     if not id:
         return Response('no id')
     
     deliverable = Document.get_by_id(id)
     self.context['deliverable'] = deliverable
     
     if not deliverable:
         return Response('no deliverable found')
         
     return self.render_response('deliverable.html', **self.context)
예제 #5
0
 def get(self):
     id = int(self.request.args.get('id'))
     if not id:
         return Response('no id')
     
     doc = Document.get_by_id(id)
     if not doc:
         return Response('no doc found')
     
     r = Response(doc.file)
     r.headers['Content-Type'] = 'binary/octet-stream'
     r.headers['Content-Disposition'] = 'attachment; filename=%s;' % doc.file_name
     return r
예제 #6
0
 def get(self):
     ServeBasics.get(self)
     documents = Document.all().order('-date').fetch(300)
     self.context['documents'] = documents
     return self.render_response('deliverables.html', **self.context)