Esempio n. 1
0
def test_category_new():
	facebookid = "*****@*****.**"
	account = Account.get_by_facebookid(facebookid)
	key_name = "TOEIC"
	category = Category.new(key_name,account)
	assert None != category
	return
Esempio n. 2
0
def test_category_new():
    facebookid = "*****@*****.**"
    account = Account.get_by_facebookid(facebookid)
    key_name = "TOEIC"
    category = Category.new(key_name, account)
    assert None != category
    return
Esempio n. 3
0
	def get(self,keyID):
		if False == (USER_AGENT in self.request.headers["User-Agent"]):
			self.response.out.write(json.dumps({'success':False}))
			return

		lang = self.request.get('lang')
		ret = Category.api_read(keyID, lang)
		self.response.headers['Content-Type'] = 'application/json'
		self.response.out.write(json.dumps(ret))
Esempio n. 4
0
    def get(self, keyID):
        if False == (USER_AGENT in self.request.headers["User-Agent"]):
            self.response.out.write(json.dumps({'success': False}))
            return

        lang = self.request.get('lang')
        ret = Category.api_read(keyID, lang)
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(ret))
Esempio n. 5
0
 def get(self, categoryid):
     accountid = self.session.get('accountid')
     account = Account.get_by_accountid(accountid)
     if 1 != account.mod:
         return
     lang = self.request.get('lang')
     category = Category.getter(categoryid)
     category.support_tostudy_del(lang)
     category.put()
     self.redirect('/category/' + categoryid)
Esempio n. 6
0
	def get(self,categoryid):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return
		lang = self.request.get('lang')
		category = Category.getter(categoryid)
		category.support_tostudy_del(lang)
		category.put()
		self.redirect('/category/'+categoryid)
Esempio n. 7
0
	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 = Category.api_read(d['id'],d['lang'])
		self.redirect(self.request.url + 'input?result='+str(det))
Esempio n. 8
0
	def get(self,key_name):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		category = Category.getter(key_name)
		for link in category.stories:
			link.delete()
		category.delete()
		self.redirect('/category')
Esempio n. 9
0
    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 = Category.api_read(d['id'], d['lang'])
        self.redirect(self.request.url + 'input?result=' + str(det))
Esempio n. 10
0
	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)
Esempio n. 11
0
    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)
Esempio n. 12
0
    def get(self, key_name):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        category = Category.getter(key_name)
        for link in category.stories:
            link.delete()
        category.delete()
        self.redirect('/category')
Esempio n. 13
0
	def post(self,key_name):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		category = Category.getter(key_name)
		params = {}
		for key in self.request.arguments():
			params[key] = self.request.get(key)
		category.setter(params)
		self.redirect('/category')
Esempio n. 14
0
	def get(self,key_name):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		category = Category.getter(key_name)
		s_form = storyengine.model.TransForm.update_form(category)
		context = {'static_path': STATIC_PATH,
			'APP_TITLE' : APP_TITLE,
			'form':s_form}
		self.render_to_response('form.html',context)
Esempio n. 15
0
    def post(self, key_name):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        category = Category.getter(key_name)
        params = {}
        for key in self.request.arguments():
            params[key] = self.request.get(key)
        category.setter(params)
        self.redirect('/category')
Esempio n. 16
0
	def get(self):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		categories = Category.all()
		categorylist = []
		keytodel = self.request.get('del')
		for c in categories:
			c.key_name = c.key().name()
			categorylist.append(c)
		categorysortedlist = sorted(categorylist, key=lambda p: p.index)

		context = {'static_path': STATIC_PATH,
			'APP_TITLE' : APP_TITLE,
			'size':Category.all().count(),
			'keytodel':keytodel,
			'langsupport':CATEGORY_LANGSUPPORT_SHOW,
			'categories':categorysortedlist}
		self.render_to_response('category_index.html',context)
Esempio n. 17
0
	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)
Esempio n. 18
0
    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)
Esempio n. 19
0
    def get(self):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        categories = Category.all()
        categorylist = []
        keytodel = self.request.get('del')
        for c in categories:
            c.key_name = c.key().name()
            categorylist.append(c)
        categorysortedlist = sorted(categorylist, key=lambda p: p.index)

        context = {
            'static_path': STATIC_PATH,
            'APP_TITLE': APP_TITLE,
            'size': Category.all().count(),
            'keytodel': keytodel,
            'langsupport': CATEGORY_LANGSUPPORT_SHOW,
            'categories': categorysortedlist
        }
        self.render_to_response('category_index.html', context)
Esempio n. 20
0
    def get(self):
        if False == (USER_AGENT in self.request.headers["User-Agent"]):
            self.response.out.write(json.dumps({'success': False}))
            return

        lang = self.request.get('lang')
        tostudy = self.request.get('tostudy')
        logging.info('lang[%s] tostudy[%s]', lang, tostudy)
        if None == tostudy or "" == tostudy:
            tostudy = "en"

        ret = Category.api_index(lang, tostudy)
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(ret))
Esempio n. 21
0
	def get(self):
		if False == (USER_AGENT in self.request.headers["User-Agent"]):
			self.response.out.write(json.dumps({'success':False}))
			return

		lang = self.request.get('lang')
		tostudy = self.request.get('tostudy')
		logging.info('lang[%s] tostudy[%s]',lang,tostudy)
		if None == tostudy or "" == tostudy:
			tostudy = "en"

		ret = Category.api_index(lang,tostudy)
		self.response.headers['Content-Type'] = 'application/json'
		self.response.out.write(json.dumps(ret))
Esempio n. 22
0
    def get(self, key_name):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        category = Category.getter(key_name)
        s_form = storyengine.model.TransForm.update_form(category)
        context = {
            'static_path': STATIC_PATH,
            'APP_TITLE': APP_TITLE,
            'form': s_form
        }
        self.render_to_response('form.html', context)
Esempio n. 23
0
    def post(self):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        key_name = self.request.get('key_name')
        assert (None != re.match('^[A-Z0-9]+', key_name))
        category = Category.new(key_name, account)
        params = {}
        for key in self.request.arguments():
            params[key] = self.request.get(key)
        category.setter(params)
        self.redirect('/category')
Esempio n. 24
0
	def post(self): 
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		key_name = self.request.get('key_name')
		assert(None!=re.match('^[A-Z0-9]+', key_name))
		category = Category.new(key_name,account)
		params = {}
		for key in self.request.arguments():
			params[key] = self.request.get(key)
		category.setter(params)
		self.redirect('/category')
Esempio n. 25
0
	def get(self,key_name):
		accountid = self.session.get('accountid')
		account = Account.get_by_accountid(accountid)
		if 1 != account.mod:
			return

		category = Category.getter(key_name)
		stories = []
		links = category.stories
		for link in links:
			story = link.story
			story.keyid = story.key().id()
			stories.append(story)
		storysortedlist = sorted(stories, key=lambda p: p.index)
		context = {'static_path': STATIC_PATH,
			'APP_TITLE' : APP_TITLE,
			'category':category,
			'stories':storysortedlist,
			'keyid':category.key().name()}
		self.render_to_response('category_read.html',context)
Esempio n. 26
0
    def get(self, key_name):
        accountid = self.session.get('accountid')
        account = Account.get_by_accountid(accountid)
        if 1 != account.mod:
            return

        category = Category.getter(key_name)
        stories = []
        links = category.stories
        for link in links:
            story = link.story
            story.keyid = story.key().id()
            stories.append(story)
        storysortedlist = sorted(stories, key=lambda p: p.index)
        context = {
            'static_path': STATIC_PATH,
            'APP_TITLE': APP_TITLE,
            'category': category,
            'stories': storysortedlist,
            'keyid': category.key().name()
        }
        self.render_to_response('category_read.html', context)
Esempio n. 27
0
def test_category_read():
    key_name = "TOEIC"
    category = Category.getter(key_name)
    assert None != category
    return
Esempio n. 28
0
def test_category_index():
	det = Category.api_index('ko')
	assert True == det['success']
Esempio n. 29
0
def test_category_index():
    det = Category.api_index('ko')
    assert True == det['success']
Esempio n. 30
0
def test_category_read():
	key_name = "TOEIC"
	category = Category.getter(key_name)
	assert None != category
	return