def test_story_read(): story_to_test = test_story_setter() assert story_to_test story = Story.get_by_id(int(story_to_test.key().id())) assert story assert story.created assert story.modified assert story.index assert story.visible assert story.version for lang in conftest.langs(): s = Story.api_read(int(story_to_test.key().id()),lang) assert story.name assert story.description return
def test_story_read(): story_to_test = test_story_setter() assert story_to_test story = Story.get_by_id(int(story_to_test.key().id())) assert story assert story.created assert story.modified assert story.index assert story.visible assert story.version for lang in conftest.langs(): s = Story.api_read(int(story_to_test.key().id()), lang) assert story.name assert story.description return
def get(self): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return if None is accountid: context = { 'static_path': STATIC_PATH, 'APP_TITLE': APP_TITLE, 'err_msg': "You should login" } self.render_to_response('err_page.html', context) return keytodel = self.request.get('del') stories = Story.all() stories.order('-created') storylist = [] for story in stories: story.keyname = str(story.key().id()) storylist.append(story) storysortedlist = sorted(storylist, key=lambda p: p.index) context = { 'static_path': STATIC_PATH, 'APP_TITLE': APP_TITLE, 'stories': storysortedlist, 'keytodel': keytodel, 'size': len(storylist) } self.render_to_response('story_index.html', context)
def get(self): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return if None is accountid: context = {'static_path': STATIC_PATH, 'APP_TITLE' : APP_TITLE, 'err_msg':"You should login"} self.render_to_response('err_page.html',context) return keytodel = self.request.get('del') stories = Story.all() stories.order('-created') storylist = [] for story in stories: story.keyname = str(story.key().id()) storylist.append(story) storysortedlist = sorted(storylist, key=lambda p: p.index) context = {'static_path': STATIC_PATH, 'APP_TITLE' : APP_TITLE, 'stories':storysortedlist, 'keytodel':keytodel, 'size':len(storylist)} self.render_to_response('story_index.html',context)
def test_story_new(): facebookid = "*****@*****.**" account = Account.get_by_facebookid(facebookid) assert account story = Story.new(account) story.put() assert story return story
def post(self): testcode = self.request.get('testcode') accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return d = json.loads(testcode) assert (d) det = Story.api_purchase(d['id'], accountid) self.redirect(self.request.url + 'input?result=' + str(det))
def post(self, keyid): #logout accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) story_ = Story.get_by_id(int(keyid)) page = Page.new(account, story_) pageid = int(self.request.get('pageid')) pageToImport = Page.get_by_id(int(pageid)) for link in pageToImport.contents: PageContentLink.new(page, link.content) self.redirect('/story/' + keyid)
def post(self,keyid): #logout accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) story_ = Story.get_by_id(int(keyid)) page = Page.new(account,story_) pageid = int(self.request.get('pageid')) pageToImport = Page.get_by_id(int(pageid)) for link in pageToImport.contents: PageContentLink.new(page,link.content) self.redirect('/story/'+keyid)
def post(self): testcode = self.request.get('testcode') accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return d = json.loads(testcode) assert(d) det = Story.api_purchase(d['id'],accountid) self.redirect(self.request.url + 'input?result='+str(det))
def get(self,storyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return lang = self.request.get('lang') story = Story.get_by_id(int(storyid)) index = story.language.index(lang) del story.language[index] story.put() self.redirect("/story/"+storyid)
def get(self,storyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story_ = Story.get_by_id(int(storyid)) pagelist = [] for page in story_.pages: pagelist.append(page) Page.new(account,story_,len(pagelist)+1) self.redirect("/story/"+storyid)
def post(self,keyid): #logout accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(keyid)) params = {} for key in self.request.arguments(): params[key] = self.request.get(key) story.setter(params) self.redirect('/story/'+keyid)
def post(self,category_name): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return storyid = self.request.get('storyid') category = Category.getter(category_name) story = Story.get_by_id(int(storyid)) CategoryStoryLink.new(category,story) self.redirect('/category/'+category_name)
def get(self, storyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return lang = self.request.get('lang') story = Story.get_by_id(int(storyid)) index = story.language.index(lang) del story.language[index] story.put() self.redirect("/story/" + storyid)
def get(self, storyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story_ = Story.get_by_id(int(storyid)) pagelist = [] for page in story_.pages: pagelist.append(page) Page.new(account, story_, len(pagelist) + 1) self.redirect("/story/" + storyid)
def post(self, keyid): #logout accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(keyid)) params = {} for key in self.request.arguments(): params[key] = self.request.get(key) story.setter(params) self.redirect('/story/' + keyid)
def post(self, category_name): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return storyid = self.request.get('storyid') category = Category.getter(category_name) story = Story.get_by_id(int(storyid)) CategoryStoryLink.new(category, story) self.redirect('/category/' + category_name)
def get(self,storykeyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(storykeyid)) for page in story.pages: for link in page.contents: link.delete() page.delete() story.delete() self.redirect("/story")
def get(self, storykeyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(storykeyid)) for page in story.pages: for link in page.contents: link.delete() page.delete() story.delete() self.redirect("/story")
def get(self,keyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(keyid)) f_data = story.to_formdict() s_form = StoryInfoForm(f_data) context = {'static_path': STATIC_PATH, 'APP_TITLE' : APP_TITLE, 'form':s_form} self.render_to_response('story_update.html',context)
def get(self, key_name, storyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return category = Category.getter(key_name) story = Story.get_by_id(int(storyid)) for link in category.stories: if int(storyid) == link.story.key().id(): link.delete() break self.redirect('/category/' + key_name)
def post(self, keyid): #logout accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(keyid)) score = int(self.request.get('score')) diff = int(self.request.get('diff')) for i in story.pages: i.score = score score = score + diff i.put() self.redirect('/story/' + keyid)
def post(self,keyid): #logout accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(keyid)) score = int(self.request.get('score')) diff = int(self.request.get('diff')) for i in story.pages: i.score = score score = score + diff i.put() self.redirect('/story/'+keyid)
def get(self, key_name, storyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return category = Category.getter(key_name) story = Story.get_by_id(int(storyid)) for link in category.stories: if int(storyid)==link.story.key().id(): link.delete() break self.redirect('/category/'+key_name)
def get(self, keyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(keyid)) f_data = story.to_formdict() s_form = StoryInfoForm(f_data) context = { 'static_path': STATIC_PATH, 'APP_TITLE': APP_TITLE, 'form': s_form } self.render_to_response('story_update.html', context)
def get(self, keyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(keyid)) i = 1 pagelist = [] for page in story.pages: pagelist.append(page) pagelist = sorted(pagelist, key=lambda p: p.index) for page in pagelist: page.index = i i = i + 1 page.put() self.redirect('/story/' + keyid)
def get(self,keyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = Story.get_by_id(int(keyid)) i = 1 pagelist = [] for page in story.pages: pagelist.append(page) pagelist = sorted(pagelist, key=lambda p: p.index) for page in pagelist: page.index = i i=i+1 page.put() self.redirect('/story/'+keyid)
def get(self, storyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = None try: story = Story.get_by_id(int(storyid)) except: print "Storyid(" + storyid + ") Err!" return params = {} params['dataID'] = self.request.get('dataID') params['cost'] = self.request.get('cost') params['receipt_type'] = self.request.get('receipt_type') Receipt.new(params, account) self.redirect('/story/' + storyid)
def get(self,storyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return story = None try: story = Story.get_by_id(int(storyid)) except: print "Storyid("+storyid+") Err!" return params = {} params['dataID'] = self.request.get('dataID') params['cost'] = self.request.get('cost') params['receipt_type'] = self.request.get('receipt_type') Receipt.new(params,account) self.redirect('/story/'+storyid)
def get(self): self.response.headers['Content-Type'] = 'application/json' lang = self.request.get('lang') ret = Story.api_index(lang) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(json.dumps(ret))
def get(self, keyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return pageidtodel = self.request.get('del') show = True purchased = True story = Story.get_by_id(int(keyid)) key_name = [] for link in story.categories: key_name.append(link.category.key().name()) story.category_key_name = key_name startpageIDs = [] pagelist = [] for page in story.pages: page.keyid = str(page.key().id()) page.contentsize = page.contents.count() if page.contents.count() > 0: try: page.contentid = str(page.contents[0].content.key().id()) except: pass nexts = [] for link in page.childs: pnext = {} p = link.child_page if p.contents.count() > 0: try: pnext['pageid'] = p.key().id() pnext['contentid'] = p.contents[0].content.key().id() nexts.append(pnext) except: pass page.nexts = nexts pagelist.append(page) pagelist = sorted(pagelist, key=lambda p: p.index) pageindexdic = {} for page in pagelist: tlist = None try: tlist = pageindexdic[str(page.index)] except: tlist = [] tlist.append(page) pageindexdic[str(page.index)] = tlist pageindexlist = [] keys = pageindexdic.keys() keylist = sorted(keys, key=lambda k: int(k)) for key in keylist: pageindexlist.append(pageindexdic[key]) context = { 'static_path': STATIC_PATH, 'APP_TITLE': APP_TITLE, 'story': story, 'pages': pageindexlist, 'pagesize': len(pageindexlist), 'pageidtodel': pageidtodel, 'purchased': purchased, 'show': show, 'picshow': STORY_PIC_SHOW, 'pagenameshow': STORY_PAGE_NAME_SHOW, 'pagedescshow': STORY_PAGE_DESCRIPTION_SHOW, 'pagepriceshow': STORY_PAGE_PRICE_SHOW, 'pagescoreshow': STORY_PAGE_SCORE_SHOW, 'pagecontentsizeshow': STORY_PAGE_CONTENTSIZE_SHOW, 'pagenextshow': STORY_PAGE_NEXT_SHOW, 'keyid': story.key().id() } self.render_to_response('story_read.html', context)
def test_story_index(): for lang in conftest.langs(): det = Story.api_index(lang) assert True == det['success']
def get(self,keyid): accountid = self.session.get('accountid') account = Account.get_by_accountid(accountid) if 1 != account.mod: return pageidtodel = self.request.get('del') show = True purchased = True story = Story.get_by_id(int(keyid)) key_name = [] for link in story.categories: key_name.append(link.category.key().name()) story.category_key_name = key_name startpageIDs = [] pagelist = [] for page in story.pages: page.keyid = str(page.key().id()) page.contentsize = page.contents.count() if page.contents.count() > 0: try: page.contentid = str(page.contents[0].content.key().id()) except: pass nexts = [] for link in page.childs: pnext = {} p = link.child_page if p.contents.count() > 0: try: pnext['pageid'] = p.key().id() pnext['contentid'] = p.contents[0].content.key().id() nexts.append(pnext) except: pass page.nexts = nexts pagelist.append(page) pagelist = sorted(pagelist, key=lambda p: p.index) pageindexdic = {} for page in pagelist: tlist = None try: tlist = pageindexdic[str(page.index)] except: tlist = [] tlist.append(page) pageindexdic[str(page.index)] = tlist pageindexlist = [] keys = pageindexdic.keys() keylist = sorted(keys, key=lambda k: int(k)) for key in keylist: pageindexlist.append(pageindexdic[key]) context = {'static_path': STATIC_PATH, 'APP_TITLE' : APP_TITLE, 'story':story, 'pages':pageindexlist, 'pagesize':len(pageindexlist), 'pageidtodel':pageidtodel, 'purchased':purchased, 'show':show, 'picshow':STORY_PIC_SHOW, 'pagenameshow':STORY_PAGE_NAME_SHOW, 'pagedescshow':STORY_PAGE_DESCRIPTION_SHOW, 'pagepriceshow':STORY_PAGE_PRICE_SHOW, 'pagescoreshow':STORY_PAGE_SCORE_SHOW, 'pagecontentsizeshow':STORY_PAGE_CONTENTSIZE_SHOW, 'pagenextshow':STORY_PAGE_NEXT_SHOW, 'keyid':story.key().id()} self.render_to_response('story_read.html',context)
def post(self, storyid): facebookid = self.request.get('facebookid') account = Account.get_by_facebookid(facebookid) ret = Story.api_purchase(storyid, account) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(json.dumps(ret))
def get(self,storyid): lang = self.request.get('lang') ret = Story.api_read(storyid,lang) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(json.dumps(ret))
def get(self, storyid): lang = self.request.get('lang') ret = Story.api_read(storyid, lang) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(json.dumps(ret))
def post(self,storyid): facebookid = self.request.get('facebookid') account = Account.get_by_facebookid(facebookid) ret = Story.api_purchase(storyid,account) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(json.dumps(ret))