Beispiel #1
0
	def _generate_datetime_select(self, element, attribs, arrays, values, names):
		def _create_option(index, v, option_data):
			tag = tags.option(value=index)[option_data[index]]
			if(index == v):
				tag(selected=None)
			return tag
		
		output = ''
		for index in range(len(arrays)):
			selected_item = arrays[index].index(values[index])
			attribs['name'] = '%s[%s]' % (element.get_element_name(), names[index])
			output += tags.select(**attribs)[[
				tags.option(value='')['Select...']
			]+[
				_create_option(i, selected_item, arrays[index]) for i in range(len(arrays[index]))
			]]
		
		return output
Beispiel #2
0
	def test_longer_select(self):
		option = tags.option(value="some-value")['some-label']
		option2 = tags.option(value="some-other-value")['some-other-label']
		tag = tags.select(name="select_field")[(option, option2)]
		expected = '<select name="select_field"><option value="some-value">some-label</option><option value="some-other-value">some-other-label</option></select>'
		self.assertEqual(str(tag), expected, "Got '%s' instead of '%s'" % (str(tag), expected))
Beispiel #3
0
	def test_select_trick2(self):
		options = ['some-label', 'other-label']
		opt_tags = map(lambda(item): tags.option(value=item[0])[item[1]], [(i,options[i]) for i in range(len(options))])
		tag = tags.select(name="select_field")[opt_tags]
		expected = '<select name="select_field"><option value="0">some-label</option><option value="1">other-label</option></select>'
		self.assertEqual(str(tag), expected, "Got '%s' instead of '%s'" % (str(tag), expected))
Beispiel #4
0
	def test_select_trick(self):
		options = {1:'some-label', 2:'other-label'}
		opt_tags = map(lambda(item): tags.option(value=item[0])[item[1]], options.items())
		tag = tags.select(name="select_field")[opt_tags]
		expected = '<select name="select_field"><option value="1">some-label</option><option value="2">other-label</option></select>'
		self.assertEqual(str(tag), expected, "Got '%s' instead of '%s'" % (str(tag), expected))
Beispiel #5
0
		def _create_option(index, v, option_data):
			tag = tags.option(value=index)[option_data[index]]
			if(index == v):
				tag(selected=None)
			return tag
Beispiel #6
0
		def _create_option(k):
			tag = tags.option(value=k)[option_data[k]]
			if(str(k) in value):
				tag(selected=None)
			return tag