コード例 #1
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def get(self):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return
		mode = self.request.get('mode')
		keytodel = self.request.get('del')
		if 'all' == mode:
			pages = Page.all().order('-created')
		else:
			pages = Page.all().order('-created').fetch(limit=5)
		pagelist = []
		Next = namedtuple("Next", "pageid contentid")
		for page in pages:
			page.keyname = str(page.key().id())
			if page.contents.count() > 0: #content at foremost 
				page.content = page.contents[0].content
				page.content.keyid = page.content.key().id()
			childlist = []
			for l in page.childs:
				if l.child_page.contents.count() > 0:
					n = Next(l.child_page.key().id(), l.child_page.contents[0].content.key().id())
					childlist.append(n)
			page.childlist = childlist
			pagelist.append(page)
		context = {'static_path': STATIC_PATH,
			'APP_TITLE' : APP_TITLE,
			'pages':pagelist,
			'keytodel':keytodel,
			'size':len(pagelist)}
		self.render_to_response('page_index.html',context)
コード例 #2
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
 def get(self):
     accountid = self.session.get('accountid')
     account = Account.get_by_accountid(accountid)
     if 1 != account.mod:
         return
     mode = self.request.get('mode')
     keytodel = self.request.get('del')
     if 'all' == mode:
         pages = Page.all().order('-created')
     else:
         pages = Page.all().order('-created').fetch(limit=5)
     pagelist = []
     Next = namedtuple("Next", "pageid contentid")
     for page in pages:
         page.keyname = str(page.key().id())
         if page.contents.count() > 0:  #content at foremost
             page.content = page.contents[0].content
             page.content.keyid = page.content.key().id()
         childlist = []
         for l in page.childs:
             if l.child_page.contents.count() > 0:
                 n = Next(l.child_page.key().id(),
                          l.child_page.contents[0].content.key().id())
                 childlist.append(n)
         page.childlist = childlist
         pagelist.append(page)
     context = {
         'static_path': STATIC_PATH,
         'APP_TITLE': APP_TITLE,
         'pages': pagelist,
         'keytodel': keytodel,
         'size': len(pagelist)
     }
     self.render_to_response('page_index.html', context)
コード例 #3
0
ファイル: story.py プロジェクト: zedoul/storyengine-gae
 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)
コード例 #4
0
ファイル: story.py プロジェクト: zedoul/storyengine-gae
	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)
コード例 #5
0
ファイル: story.py プロジェクト: zedoul/storyengine-gae
 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)
コード例 #6
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def post(self,pageid1):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		pageid2 = self.request.get('pageid')
		page1 = Page.get_by_id(int(pageid1))
		page2 = Page.get_by_id(int(pageid2))
		PagePageLink.new(page1,page2)
		self.redirect('/page/'+pageid1)
コード例 #7
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
    def post(self, pageid1):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        pageid2 = self.request.get('pageid')
        page1 = Page.get_by_id(int(pageid1))
        page2 = Page.get_by_id(int(pageid2))
        PagePageLink.new(page1, page2)
        self.redirect('/page/' + pageid1)
コード例 #8
0
ファイル: story.py プロジェクト: zedoul/storyengine-gae
	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)
コード例 #9
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def post(self,keyid): #logout
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return
		page = Page.get_by_id(int(keyid))
		pageid = int(self.request.get('pageid'))
		pageToImport = Page.get_by_id(int(pageid))
		for link in pageToImport.contents:
			try:
				if None != link and None != link.content and None != page:
					PageContentLink.new(page,link.content)
			except:
				pass
		self.redirect('/page/'+keyid)
コード例 #10
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
 def post(self, keyid):  #logout
     accountid = self.session.get('accountid')
     account = Account.get_by_accountid(accountid)
     if 1 != account.mod:
         return
     page = Page.get_by_id(int(keyid))
     pageid = int(self.request.get('pageid'))
     pageToImport = Page.get_by_id(int(pageid))
     for link in pageToImport.contents:
         try:
             if None != link and None != link.content and None != page:
                 PageContentLink.new(page, link.content)
         except:
             pass
     self.redirect('/page/' + keyid)
コード例 #11
0
ファイル: story.py プロジェクト: zedoul/storyengine-gae
	def get(self,storyid,pageid):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return
		page = Page.get_by_id(int(pageid))
		for link in page.contents:
			link.delete()
		page.delete()
		self.redirect("/story/"+storyid)
コード例 #12
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
    def get(self, pageid, contentid):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        page = Page.get_by_id(int(pageid))
        content = Content.get_by_id(int(contentid))
        PageContentLink.new(page, content)
        self.redirect('/page/' + pageid)
コード例 #13
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def get(self,pageid,contentid):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		page = Page.get_by_id(int(pageid))
		content = Content.get_by_id(int(contentid))
		PageContentLink.new(page,content)
		self.redirect('/page/'+pageid)
コード例 #14
0
ファイル: story.py プロジェクト: zedoul/storyengine-gae
 def get(self, storyid, pageid):
     accountid = self.session.get('accountid')
     account = Account.get_by_accountid(accountid)
     if 1 != account.mod:
         return
     page = Page.get_by_id(int(pageid))
     for link in page.contents:
         link.delete()
     page.delete()
     self.redirect("/story/" + storyid)
コード例 #15
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def post(self): #logout
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return
		page = Page.new(account)
		params = {}
		for key in self.request.arguments():
			params[key] = self.request.get(key)
		page.setter(params)
		self.redirect('/page')
コード例 #16
0
ファイル: apitest.py プロジェクト: zedoul/storyengine-gae
    def post(self):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        testcode = self.request.get('testcode')
        d = json.loads(testcode)
        assert (d)
        det = Page.api_read(d['id'], d['lang'])
        self.redirect(self.request.url + 'input?result=' + str(det))
コード例 #17
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
 def post(self):  #logout
     accountid = self.session.get('accountid')
     account = Account.get_by_accountid(accountid)
     if 1 != account.mod:
         return
     page = Page.new(account)
     params = {}
     for key in self.request.arguments():
         params[key] = self.request.get(key)
     page.setter(params)
     self.redirect('/page')
コード例 #18
0
ファイル: apitest.py プロジェクト: zedoul/storyengine-gae
	def post(self):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		testcode = self.request.get('testcode')
		d = json.loads(testcode)
		assert(d)
		det = Page.api_read(d['id'],d['lang'])
		self.redirect(self.request.url + 'input?result='+str(det))
コード例 #19
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def post(self,pageid):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		page = Page.get_by_id(int(pageid))
		params = {}
		for key in self.request.arguments():
			params[key] = self.request.get(key)
		page.setter(params)
		self.redirect('/page/'+pageid)
コード例 #20
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
    def post(self, pageid):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        page = Page.get_by_id(int(pageid))
        params = {}
        for key in self.request.arguments():
            params[key] = self.request.get(key)
        page.setter(params)
        self.redirect('/page/' + pageid)
コード例 #21
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
    def get(self, pageid, contentid):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        p = Page.get_by_id(int(pageid))
        c = Content.get_by_id(int(contentid))
        obj = PageContentLink.get_by_key_name(
            str(p.key().id()) + "+" + str(c.key().id()))
        obj.delete()
        self.redirect("/page/" + pageid)
コード例 #22
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def get(self,pageid,contentid):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		p = Page.get_by_id(int(pageid))
		c = Content.get_by_id(int(contentid))
		obj = PageContentLink.get_by_key_name(
				str(p.key().id())+"+"+str(c.key().id()))
		obj.delete()
		self.redirect("/page/"+pageid)
コード例 #23
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def post(self,pageid):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return
		content_ = Content.new(account)
		params = {}
		for key in self.request.arguments():
			params[key] = self.request.get(key)
		content_.setter(params)
		page_ = Page.get_by_id(int(pageid))
		PageContentLink.new(page_,content_)
		self.redirect('/page/'+pageid)
コード例 #24
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
 def post(self, pageid):
     accountid = self.session.get('accountid')
     account = Account.get_by_accountid(accountid)
     if 1 != account.mod:
         return
     content_ = Content.new(account)
     params = {}
     for key in self.request.arguments():
         params[key] = self.request.get(key)
     content_.setter(params)
     page_ = Page.get_by_id(int(pageid))
     PageContentLink.new(page_, content_)
     self.redirect('/page/' + pageid)
コード例 #25
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
    def get(self, keyid):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        page = Page.get_by_id(int(keyid))
        contents = []
        for link in page.contents:
            try:
                content = link.content
                content.keyid = content.key().id()
                contents.append(content)
            except:
                content = None
        contentsortedlist = sorted(contents, key=lambda p: p.index)

        parents = []
        for link in page.parents:
            p = link.parent_page
            p.keyid = p.key().id()
            parents.append(p)

        childs = []
        for link in page.childs:
            p = link.child_page
            p.keyid = p.key().id()
            childs.append(p)

        storykeyid = None
        if None != page.story:
            storykeyid = str(page.story.key().id())
        context = {
            'static_path': STATIC_PATH,
            'APP_TITLE': APP_TITLE,
            'pagemultisearchshow': PAGE_MULTISEARCH_SHOW,
            'pagemultiupdateshow': PAGE_MULTIUPDATE_SHOW,
            'pagesyncshow': PAGE_SYNC_SHOW,
            'pageimportshow': PAGE_IMPORT_SHOW,
            'page': page,
            'contents': contentsortedlist,
            'parents': parents,
            'childs': childs,
            'storyid': storykeyid,
            'keyid': page.key().id()
        }
        self.render_to_response('page_read.html', context)
コード例 #26
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def get(self,keyid):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		page = Page.get_by_id(int(keyid))
		contents = []
		for link in page.contents:
			try:
				content = link.content
				content.keyid = content.key().id()
				contents.append(content)
			except:
				content = None
		contentsortedlist = sorted(contents, key=lambda p: p.index)

		parents = []
		for link in page.parents:
			p = link.parent_page
			p.keyid = p.key().id()
			parents.append(p)

		childs = []
		for link in page.childs:
			p = link.child_page
			p.keyid = p.key().id()
			childs.append(p)

		storykeyid = None 
		if None != page.story:
			storykeyid = str(page.story.key().id())
		context = {'static_path': STATIC_PATH,
			'APP_TITLE' : APP_TITLE,
			'pagemultisearchshow':PAGE_MULTISEARCH_SHOW,
			'pagemultiupdateshow':PAGE_MULTIUPDATE_SHOW,
			'pagesyncshow':PAGE_SYNC_SHOW,
			'pageimportshow':PAGE_IMPORT_SHOW,
			'page':page,
			'contents':contentsortedlist,
			'parents':parents,
			'childs':childs,
			'storyid':storykeyid,
			'keyid':page.key().id()}
		self.render_to_response('page_read.html',context)
コード例 #27
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def get(self,pagekeyid):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		page = Page.get_by_id(int(pagekeyid))
		f_data = page.to_formdict()
		s_form = PageInfoForm (f_data)
		del s_form.fields['index']
		del s_form.fields['score']
		del s_form.fields['price']
		del s_form.fields['visible']
		del s_form.fields['expiration_days']
		del s_form.fields['expiration_mins']
		context = {'static_path': STATIC_PATH,
			'APP_TITLE' : APP_TITLE,
			'form':s_form}
		self.render_to_response('form.html',context)
コード例 #28
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
    def get(self, pagekeyid):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        page = Page.get_by_id(int(pagekeyid))
        f_data = page.to_formdict()
        s_form = PageInfoForm(f_data)
        del s_form.fields['index']
        del s_form.fields['score']
        del s_form.fields['price']
        del s_form.fields['visible']
        del s_form.fields['expiration_days']
        del s_form.fields['expiration_mins']
        context = {
            'static_path': STATIC_PATH,
            'APP_TITLE': APP_TITLE,
            'form': s_form
        }
        self.render_to_response('form.html', context)
コード例 #29
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
    def post(self, keyid):  #logout
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return
        page = Page.get_by_id(int(keyid))
        for link in page.contents:
            link.delete()
        indexfrom = int(self.request.get('indexfrom'))
        indexto = int(self.request.get('indexto'))
        pagelist = []
        for p in page.story.pages:
            pagelist.append(p)
        pagelist = sorted(pagelist, key=lambda p: p.index)
        for p in pagelist:
            if p.index >= indexfrom:
                for link in p.contents:
                    PageContentLink.new(page, link.content)
            if p.index > indexto:
                break

        self.redirect('/page/' + keyid)
コード例 #30
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def post(self,keyid): #logout
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return
		page = Page.get_by_id(int(keyid))
		for link in page.contents:
			link.delete()
		indexfrom = int(self.request.get('indexfrom'))
		indexto = int(self.request.get('indexto'))
		pagelist = []
		for p in page.story.pages:
			pagelist.append(p)
		pagelist = sorted(pagelist, key=lambda p: p.index)
		for p in pagelist:
			if p.index >= indexfrom:
				for link in p.contents:
					PageContentLink.new(page,link.content)
			if p.index > indexto:
				break

		self.redirect('/page/'+keyid)
コード例 #31
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
 def get(self, keyid):
     lang = self.request.get('lang')
     ret = Page.api_read(keyid, lang)
     self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(json.dumps(ret))
コード例 #32
0
def test_page_new():
	facebookid = "*****@*****.**"
	account = Account.get_by_facebookid(facebookid)
	page = Page.new(account)
	assert None != page
	return
コード例 #33
0
ファイル: page.py プロジェクト: zedoul/storyengine-gae
	def get(self,keyid):
		lang = self.request.get('lang')
		ret = Page.api_read(keyid,lang)
		self.response.headers['Content-Type'] = 'application/json'
		self.response.out.write(json.dumps(ret))