Example #1
0
	def post(self, abbrev_requested):
		
		## Check if this is a json_import port
		ptable = self.request.form.get('table')
		#cls = self.request.form.get('class')
		description = self.request.form.get('description')
		
		if ptable and ptable == abbrev_requested:
			#g = json.loads(group_str)
			payload = {'success': True}
			#q = db.GqlQuery("select * from group where group=:1", g['group'])
			#G = g.get()
			A = Abbrev.get_by_key_name(ptable)
			if A == None:
				A = Abbrev(key_name=ptable, table=ptable, description=description)
				A.put()
				payload['action'] = 'new'
				
			else:
				#G.cls = cls
				A.description = description
				payload['action'] = 'updated'
				A.put()
			payload['group'] = A.dic()
		else:
			payload = {'error': 'url/group mismatches'}
		#return render_response('container.html', c=context, g=appGlobal)
		return render_json_response(payload)
Example #2
0
	def get(self, abbrev_requested):
		payload = {'success': True}
		
		A = Abbrev.get_by_key_name(abbrev_requested)
		if A:
			#payload = {'abbrev': {}}
			payload['table'] = A.dic()
			query = db.GqlQuery("select * from AbbrevCode where table=:1", A.table)
			results = query.fetch(2000)
			payload['abbrev_codes'] = [r.dic() for r in results]
		else:
			payload['error'] = "Abbrev table '%s' not found" % abbrev_requested
			
		return render_json_response(payload)	
Example #3
0
	def post(self, abbrev_requested):
		
		## Check if this is a json_import port
		ptable = self.request.form.get('table')
		pcode = self.request.form.get('code')
		
		description = self.request.form.get('description')
		date_added_str = self.request.form.get('date_added')
		added_by = self.request.form.get('added_by')
		
		#if date_added != "":
		date_parts = date_added_str.split("-")
		date_added = datetime.date(int(date_parts[0]), int(date_parts[1]), int(date_parts[2]))
		
		if ptable and ptable == abbrev_requested:
			#g = json.loads(group_str)
			payload = {'success': True}
			#q = db.GqlQuery("select * from group where group=:1", g['group'])
			#G = g.get()
			A = Abbrev.get_by_key_name(ptable)
			if A == None:
				#A = Abbrev(key_name=ptable, table=ptable, description=description)
				#A.put()
				payload['error'] = "AbbrevTable '%s' not found" % ptable
				
			else:
				query = db.GqlQuery("select * from AbbrevCode where table=:1 and code=:2", ptable, pcode)
				AC = query.get()
				if AC == None:
					AC = AbbrevCode(key_name="%s/%s" % (ptable, pcode), 
									table=ptable, code=pcode, 
									description=description,
									date_added=date_added, added_by=added_by
									)
					payload['action'] = 'added'
				else:
					#if AC.description != description:
					AC.description = description
					#AC.date_added = date_added
					modi = True
					#if 
					payload['action'] = 'updated'
				AC.put()
			payload['abbrev_code'] = AC.dic()
		else:
			payload = {'error': 'url/group mismatches'}
		#return render_response('container.html', c=context, g=appGlobal)
		return render_json_response(payload)