예제 #1
0
파일: handlers.py 프로젝트: daffodil/nl
	def post(self, group_requested):
		
		## Check if this is a json_import port
		pgroup = self.request.form.get('group')
		cls = self.request.form.get('class')
		description = self.request.form.get('description')
		if pgroup and pgroup == group_requested:
			#g = json.loads(group_str)
			payload = {'success': True}
			G = Group.get_by_key_name(pgroup)
			if G == None:
				G = Group(key_name=pgroup, name=pgroup, cls=cls, description=description)
				G.put()
				payload['action'] = 'new'
				
			else:
				G.cls = cls
				G.description = description
				payload['action'] = 'updated'
				G.put()
			payload['group'] = G.dic()
		else:
			payload = {'error': 'url/group mismatches'}
		#return render_response('container.html', c=context, g=appGlobal)
		return render_json_response(payload)
예제 #2
0
파일: handlers.py 프로젝트: daffodil/nl
	def get(self, group_requested):
		
		payload = {'success': True}
		
		G = Group.get_by_key_name(group_requested)
		if G:
			query = db.GqlQuery("select * from Heading where group=:1 order by sort_order", G.name)
			heading_objects = query.fetch(1000)
			headings = []
			for h in heading_objects:
				headings.append(h.dic())
			payload['group'] = G.dic()
			payload['headings'] = headings
		else:
			payload['error'] = 'Group %s not found' % group_requested
		
		return render_json_response(payload)
예제 #3
0
파일: handlers.py 프로젝트: daffodil/nl
	def post(self, group_requested, heading_requested):
		

		pgroup = self.request.form.get('group')
		pfield = self.request.form.get('name') ##### TODO
	
		payload = {'success': True, 'V': [group_requested, pgroup, heading_requested, pfield]}
		"""
		{u'status': u'', u'description': u'Project title', u'data_type': u'X', u'heading': u'PROJ_NAME', u'unit': u'', u'example': u'ACME Gas Works Redevelopment', u'rev_date': u''}
		"""
		if pgroup and pfield and pgroup == group_requested and pfield == heading_requested:
			
			G = Group.get_by_key_name(pgroup)
			if G:
				status =  self.request.form.get('status')
				description =  self.request.form.get('description')
				data_type =  self.request.form.get('data_type')
				unit =  self.request.form.get('unit')
				example =  self.request.form.get('example')
				sort_order = int(self.request.form.get('sort_order'))
				
				query = db.GqlQuery("select * from Heading where group=:1 and field=:2", pgroup, pfield)
				F = query.get()
				if not F:
					F = Field(key_name="%s/%s" % (pgroup, pfield), group=pgroup, field=pfield)
				
				F.unit = unit
				F.description = description
				F.status = status
				F.data_type = data_type
				F.example = example
				F.sort_order = sort_order
				F.put()
				#payload['field'] = F.dic()
			
			else:
				payload['error'] = 'group %s does not exist' % pgroup
		else:
			payload['error'] =  'Mismatched request vars'
		#return render_response('container.html', c=context, g=appGlobal)
		return render_json_response(payload)