Exemplo n.º 1
0
 def post(self):
     text = self.request.get('dumptext')
     ganglionKey = self.request.get('ganglion')
     if ganglionKey:
         ganglion = Ganglion.get(ganglionKey)
     else:
         self.error(404)
         return
     if not ganglion.checkUser():
         self.error(404)
         return
     user = users.get_current_user()
     cortex = getCortex(user)
     if text:
         dump = Dump()
         dump.user = users.get_current_user()
         if ganglion and ganglion.user == user:
             dump.ganglion = ganglion
         dump.processNewText(text)
     dumps = getDumps(ganglion)
     write_template(self, getDumpsTemplate(cortex), \
         { 'dumps': dumps,
           'showChecked': cortex.showChecked,
           'ganglion': ganglion,
           'user': user, })
Exemplo n.º 2
0
 def post(self):
     key = self.request.get('key')
     if key:
         dump = Dump().get(key)
         if not dump.ganglion.checkUser():
             self.error(404)
             return
         if dump and dump.user == users.get_current_user():
             dump.delete()
Exemplo n.º 3
0
 def get(self):
     dumps = Dump.all()
     for dump in dumps.fetch(1000):
         self.response.out.write(dump.text)
         self.response.out.write('<br>')
         dump.order = 1001
         dump.put()
Exemplo n.º 4
0
def upload(request):
    file = upload_receive(request)

    instance = Dump(file=file, name=file.name, timestamp=datetime.datetime.now())
    instance.save()

    basename = os.path.basename(instance.file.path)

    file_dict = {
        'name': basename,
        'size': file.size,

        'url': settings.MEDIA_URL + basename,
        'thumbnailUrl': settings.MEDIA_URL + basename,

        'deleteUrl': reverse('jfu_delete', kwargs={'pk': instance.pk}),
        'deleteType': 'POST',
    }

    return UploadResponse(request, file_dict)
Exemplo n.º 5
0
def upload(request):
    file = upload_receive(request)

    instance = Dump(file=file,
                    name=file.name,
                    timestamp=datetime.datetime.now())
    instance.save()

    basename = os.path.basename(instance.file.path)

    file_dict = {
        'name': basename,
        'size': file.size,
        'url': settings.MEDIA_URL + basename,
        'thumbnailUrl': settings.MEDIA_URL + basename,
        'deleteUrl': reverse('jfu_delete', kwargs={'pk': instance.pk}),
        'deleteType': 'POST',
    }

    return UploadResponse(request, file_dict)
Exemplo n.º 6
0
 def post(self):
     key = self.request.get('element_id')
     logging.debug('key ' + key)
     if not key: 
         self.error(404)
         return
     update_value = self.request.get('update_value')
     if not update_value: 
         self.error(404)
         return
     dump = Dump.get(key)
     if not dump: 
         self.error(404)
         return
     if not dump.ganglion.checkUser():
         self.error(404)
         return
     dump.processNewText(update_value)
     self.response.out.write(dump.text)
Exemplo n.º 7
0
 def post(self,key):
     user = users.get_current_user()
     ganglion = Ganglion().get(key)
     if not ganglion:
         logging.error("Cannot find ganglion %s" % key)
         return
     if not ganglion.checkUser():
         self.error(404)
         return
     #logging.debug("Sorting %s" % key)
     #logging.debug(repr(self.request.arguments()))
     order = 1
     for dumpKey in self.request.get_all('dump[]'):
         #logging.debug(dumpKey)
         dump = Dump.get(dumpKey)
         if dump:
             #logging.debug("order %s" % order)
             dump.order = order
             dump.put()
         order += 1
     #logging.debug("%s items sorted" % order)
     return
Exemplo n.º 8
0
 def post(self):
     key = self.request.get('id')
     logging.debug('key ' + key)
     if not key: 
         self.error(404)
         return
     checked = self.request.get('checked')
     logging.debug('checked ' + checked)
     if not checked: 
         self.error(404)
         return
     dump = Dump.get(key)
     if not dump: 
         self.error(404)
         return
     if not dump.ganglion.checkUser():
         self.error(404)
         return
     if checked == "true":
         dump.checked = True 
     else:
         dump.checked = False
     dump.put()
     return