예제 #1
0
	def getJSON(self, lang):
		"""
		Inherited from Widget 
		"""
		
		j = super(CheckboxInputWidget, self).getJSON(lang)
		j['default'] = get_by_lang(self.attributes['defaults'], lang)
		
		"""
		"choices": [
			{
				"label": "Uomo",
				"description": "",
				"type": "xsd:string",
				"value": "http://w3id.com/gender-ontology/male"
			},
		]
		"""
		options = get_by_lang(self.attributes['options'], lang)
		
		j['choices'] = []
		if options:
			for opt in [ast.literal_eval(o.strip()) for o in options.split(',')]:
				choice = {}
				choice['label'] = opt
				choice['description'] = ""
				choice['type'] = ""
				choice['value'] = opt
				j['choices'] += [ choice ]
				
		return j
예제 #2
0
    def getJSON(self, lang):
        """
		Inherited from Widget 
		"""

        j = super(CheckboxInputWidget, self).getJSON(lang)
        j['default'] = get_by_lang(self.attributes['defaults'], lang)
        """
		"choices": [
			{
				"label": "Uomo",
				"description": "",
				"type": "xsd:string",
				"value": "http://w3id.com/gender-ontology/male"
			},
		]
		"""
        options = get_by_lang(self.attributes['options'], lang)

        j['choices'] = []
        if options:
            for opt in [
                    ast.literal_eval(o.strip()) for o in options.split(',')
            ]:
                choice = {}
                choice['label'] = opt
                choice['description'] = ""
                choice['type'] = ""
                choice['value'] = opt
                j['choices'] += [choice]

        return j
예제 #3
0
파일: text_input.py 프로젝트: caiok/bird-a
	def getJSON(self, lang):
		"""
		Inherited from Widget 
		"""
		
		j = super(TextInputWidget, self).getJSON(lang)
		j['default'] = get_by_lang(self.attributes['defaults'], lang)
		j['placeholder'] = get_by_lang(self.attributes['placeholders'], lang)
		return j
예제 #4
0
파일: text_input.py 프로젝트: caliuf/bird-a
    def getJSON(self, lang):
        """
		Inherited from Widget 
		"""

        j = super(TextInputWidget, self).getJSON(lang)
        j['default'] = get_by_lang(self.attributes['defaults'], lang)
        j['placeholder'] = get_by_lang(self.attributes['placeholders'], lang)
        return j
예제 #5
0
파일: individual.py 프로젝트: caiok/bird-a
		def update_single_field(d_orig, d_curr, field, property, lang):
			"""Utility function"""
			
			old_value = get_by_lang(d_orig[field], lang)
			new_value = get_by_lang(d_curr[field], lang)
			assert (not old_value and old_value.language == None) or (old_value.language == new_value.language), \
				"old language %r differ from new language %r" % (old_value.language, new_value.language)
			
			if old_value != new_value:
				if verbose: print "%(field)s (%(property)s): %(old_value)r -> %(new_value)r" % vars()
				update_triple(self.conn, self.individual_uri, property, old_value, new_value)
				return True
			else:
				return False
예제 #6
0
파일: widget.py 프로젝트: caliuf/bird-a
    def get_allowed_values(self, lang):
        assert self.attributes.has_key('options')

        options = get_by_lang(self.attributes['options'], lang)
        if options:
            return [ast.literal_eval(o.strip()) for o in options.split(',')]
        else:
            return []
예제 #7
0
파일: individual.py 프로젝트: caliuf/bird-a
        def update_single_field(d_orig, d_curr, field, property, lang):
            """Utility function"""

            old_value = get_by_lang(d_orig[field], lang)
            new_value = get_by_lang(d_curr[field], lang)
            assert (not old_value and old_value.language == None) or (old_value.language == new_value.language), \
             "old language %r differ from new language %r" % (old_value.language, new_value.language)

            if old_value != new_value:
                if verbose:
                    print "%(field)s (%(property)s): %(old_value)r -> %(new_value)r" % vars(
                    )
                update_triple(self.conn, self.individual_uri, property,
                              old_value, new_value)
                return True
            else:
                return False
예제 #8
0
파일: individual.py 프로젝트: caiok/bird-a
	def get_json(self, lang):
		
		j = collections.OrderedDict()
		j['uri'] = self.individual_uri
		j['type'] = self.type
		j['lang'] = lang
		j['label'] = get_by_lang(self.data_current['labels'], lang)
		j['description'] = get_by_lang(self.data_current['descriptions'], lang)
		# j['last_modified'] = ...
		# j['authors'] = ...
		
		j['properties'] = []
		for property in self.data_current['properties']:
			d = collections.OrderedDict()
			d['uri'] = property
			d['values'] = get_by_lang_mul(self.data_current['properties'][property], lang)
			j['properties'] += [ d ]
		
		return j
예제 #9
0
파일: individual.py 프로젝트: caliuf/bird-a
    def get_json(self, lang):

        j = collections.OrderedDict()
        j['uri'] = self.individual_uri
        j['type'] = self.type
        j['lang'] = lang
        j['label'] = get_by_lang(self.data_current['labels'], lang)
        j['description'] = get_by_lang(self.data_current['descriptions'], lang)
        # j['last_modified'] = ...
        # j['authors'] = ...

        j['properties'] = []
        for property in self.data_current['properties']:
            d = collections.OrderedDict()
            d['uri'] = property
            d['values'] = get_by_lang_mul(
                self.data_current['properties'][property], lang)
            j['properties'] += [d]

        return j
예제 #10
0
파일: widget.py 프로젝트: caliuf/bird-a
    def get_description(self, lang):
        assert self.attributes.has_key('descriptions')

        return get_by_lang(self.attributes['descriptions'], lang)
예제 #11
0
파일: widget.py 프로젝트: caliuf/bird-a
    def get_label(self, lang):
        assert self.attributes.has_key('labels')

        return get_by_lang(self.attributes['labels'], lang)