Example #1
0
def getDefault(cortex):
    default = cortex.default
    if not default:
        default = Ganglion()
        default.name = "Cortex Dump"
        default.user = cortex.user
        default.put()
        cortex.default = default
        cortex.put()
    return default
Example #2
0
 def get(self,name):
     user = users.get_current_user()
     ganglion = Ganglion().all().filter('user ='******'name =', name)
     ganglion = ganglion.fetch(1)
     if not ganglion:
         self.redirect('/')
     else:
         ganglion = ganglion[0]
         if not ganglion.checkUser():
             self.error(404)
             return
         self.redirect('/ganglion/%s' % ganglion.key())
Example #3
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, })
Example #4
0
 def post(self):
     logging.debug('ToggleChecked ' + repr(self.request.arguments()))
     toggle = self.request.get('toggle')
     user = users.get_current_user()
     cortex = getCortex(user)
     if toggle == "hide":
         cortex.showChecked = False
     elif toggle == "show":
         cortex.showChecked = True
     else:
         self.error(404)
         return
     cortex.put()
     key = self.request.get('key')
     if not key: 
         self.error(404)
         return
     ganglion = Ganglion.get(key)
     if not ganglion: 
         self.error(404)
         return
     if not ganglion.checkUser():
         self.error(404)
         return
     dumps = getDumps(ganglion)
     write_template(self, getDumpsTemplate(cortex), \
         { 'dumps': dumps,
           'ganglion': ganglion,
           'showChecked': cortex.showChecked,
           'user': user, })
Example #5
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
Example #6
0
 def get(self,key):
     user = users.get_current_user()
     cortex = getCortex(user)
     ganglion = Ganglion().get(key)
     if not ganglion:
         self.error(404)
         return
     if not ganglion.checkUser():
         self.error(404)
         return
     dumps = getDumps(ganglion)
     ganglia = Ganglion.all().filter('user ='******'name')
     someGanglia = ganglia.count() > 0
     logout = users.create_logout_url('/')
     write_template(self,'index.html', \
         { 'dumps': dumps,
           'ganglion': ganglion,
           'showChecked': cortex.showChecked,
           'dumpsTemplate': getDumpsTemplate(cortex),
           'ganglia': ganglia,
             'someGanglia':
             someGanglia,
             'user': user,
             'logout': logout})
Example #7
0
 def post(self):
     key = self.request.get('key')
     if not key: 
         self.error(404)
         return
     ganglion = Ganglion.get(key)
     if not ganglion: 
         self.error(404)
         return
     if not ganglion.checkUser():
         self.error(404)
         return
     user = users.get_current_user()
     cortex = getCortex(user)
     cortex.default = ganglion
     cortex.put()
Example #8
0
 def post(self):
     key = self.request.get('key')
     if not key: 
         self.error(404)
         return
     update_value = self.request.get('update_value')
     if not update_value: 
         self.error(404)
         return
     ganglion = Ganglion.get(key)
     if not ganglion: 
         self.error(404)
         return
     if not ganglion.checkUser():
         self.error(404)
         return
     ganglion.name = update_value
     ganglion.put()
     self.response.out.write(ganglion.name)
Example #9
0
 def post(self,view):
     user = users.get_current_user()
     cortex = getCortex(user)
     cortex.viewMode = view
     cortex.put()
     ganglionKey = self.request.get('ganglion')
     ganglion = None
     if not ganglionKey: 
         self.error(404)
         return
     ganglion = Ganglion.get(ganglionKey)
     if not ganglion: 
         self.error(404)
         return
     if not ganglion.checkUser():
         self.error(404)
         return
     dumps = getDumps(ganglion)
     write_template(self, getDumpsTemplate(cortex), \
         { 'dumps': dumps,
           'ganglion': ganglion,
           'user': user, })
Example #10
0
 def post(self):
     ganglion = Ganglion()
     ganglion.name = 'New (Click to change)'
     ganglion.user = users.get_current_user()
     ganglion.put()
     self.redirect('/ganglion/%s' % ganglion.key())