def answer(self, questionKey): def ancestored_create_factory(controller): return controller.meta.Model(parent=ndb.Key("Question", questionKey)) self.scaffold.create_factory = ancestored_create_factory def set_redirect(controller, container, item): controller.scaffold.redirect = controller.uri(controller='questions', action='view', key=questionKey) self.events.scaffold_after_save += set_redirect returnKey = scaffold.add(self) time.sleep(0.1) # in order to let item can be queried immediately after adding return returnKey
def add(self): # http = self.oauth.http() # service = build('oauth2', 'v2', http=http) # user_info = service.userinfo().get().execute() # more fields see here {@link https://developers.google.com/apis-explorer/#p/oauth2/v2/oauth2.userinfo.v2.me.get } # return "Hello, you are %s" % user_info['name'] user = users.get_current_user() returnKey = scaffold.add(self) time.sleep(0.1) # in order to let item can be queried immediately after adding print user return returnKey
def add(self): AnswerForm = model_form(self.meta.Model, exclude=("votes",)) self.scaffold.ModelForm = AnswerForm returnKey = scaffold.add(self) time.sleep(0.1) # in order to let item can be queried immediately after adding return returnKey
def admin_add(self): return scaffold.add(self)
def add(self): # a custom form exclude "views" property PostForm = model_form(self.meta.Model, exclude=('views',)) # override model form of BasicModel self.scaffold.ModelForm = PostForm return scaffold.add(self)
def add(self): # a custom form exclude "views" property PostForm = model_form(self.meta.Model, exclude=('views', )) # override model form of BasicModel self.scaffold.ModelForm = PostForm return scaffold.add(self)