示例#1
0
 def post(self, script, version, user=None):
     if script.user.key() != user.key():
         return self.not_authorized()
     version = Version(script=script, body=self.request.get('script'))
     version.put()
     script.latest_version = version
     script.put()
     self.redirect('/%s' % script.id)
示例#2
0
 def post(self):
     user = users.get_current_user()
     body = self.request.get('script')
     if body:
         script = Script()
         script.put()
         version = Version(script=script, body=body)
         version.put()
         script.latest_version = version
         script.put()
         self.redirect('/%s' % script.id)
     else:
         self.redirect('/new')
示例#3
0
def version(req, mode):
    """
    Gets or set the version for the current ``mode``

    :param req:
    :param mode: the mode
    :return: an object with current version (``currentVersion``)
    """
    v = Version.query(Version.type == mode).get()
    if req.method == 'GET':
        if not v:
            raise NotFoundException
        return dict(currentVersion=v.current)
    elif req.method == "PUT":
        if not v:
            v = Version()
            v.type = mode
        vset = str(json.loads(req.body)['currentVersion'])
        v.current = vset
        v.put()
        return 200, dict(currentVersion=v.current)