Esempio n. 1
0
    def deserialize(self, properties):
        ControlBase.deserialize(self, properties)

        self.horizontal_headers = properties['horizontal_headers']
        self._read_only = properties['read_only'] == 1
        self._selected_index = properties['selected_index']
        self._select_entire_row = properties['select_entire_row'] == 1
 def __init__(self, *args, **kwargs):
     self._css = 'fluid'
     self._filename = ''
     self._video_index = 0
     self.process_frame_event = kwargs.get('process_frame_event',
                                           self.process_frame_event)
     ControlBase.__init__(self, *args, **kwargs)
Esempio n. 3
0
 def deserialize(self, properties):
     ControlBase.deserialize(self, properties)
     self.search_field_key = properties.get('search_field_key', None)
     self.sort_by = properties.get('sort_by', [])
     self.filter_by = properties.get('filter_by', [])
     self._current_page = int(properties['pages']['current_page'])
     self._selected_row_id = properties.get('selected_row_id', -1)
    def deserialize(self, properties):
        value = properties.get('value', [])
        values = []
        for v in value:
            if len(v.strip()) > 0:
                values.append(v)
        properties.update({'value': values})

        ControlBase.deserialize(self, properties)
    def serialize(self):
        data = ControlBase.serialize(self)
        items = []
        for key, value in self._items.items():
            items.append({
                'text': str(key),
                'value': str(value),
                'name': str(key)
            })

        #value = str(self._value) if self._value is not None else None
        if isinstance(self._value, list) and len(self._value) > 0:
            value = list(map(str, sorted(self._value)))
        else:
            value = None

        data.update({
            'items': items,
            'value': value,
            'mode': self.mode,
            'update_items': self._update_items
        })

        self._update_items = False
        return data
Esempio n. 6
0
	def serialize(self):
		data  = ControlBase.serialize(self)
		data.update({ 
			'legend': 	self.legend, 
			'value': 	self._value 
		})
		return data
Esempio n. 7
0
	def serialize(self):
		data = ControlBase.serialize(self)
		items = []
		for key, value in self.queryset:
			items.append({'label': key, 'value': value }) 
		data.update({ 'items': items, 'value': self._value })
		return data
    def serialize(self):
        data = ControlBase.serialize(self)

        items = []
        for row in (self.queryset if self.queryset else []):
            items.append({
                'text': str(row),
                'value': str(row.pk),
                'name': str(row)
            })

        if self.value:
            value = list(sorted(map(str, self.value)))
        else:
            value = None

        data.update({
            'items': items,
            'value': value,
            'mode': self.mode,
            'update_items': self._update_items
        })

        self._update_items = False
        return data
Esempio n. 9
0
    def serialize(self):
        data = ControlBase.serialize(self)

        data.update({
            'headers':        self.headers,
            'selected_index': self._selected_index,
        })
        return data
Esempio n. 10
0
 def serialize(self):
     data = ControlBase.serialize(self)
     if isinstance(self.value, BaseWidget):
         data.update({'value': self.value.uid})
         self.value.parent = self.parent.uid
     else:
         data.update({'value': None})
     return data
Esempio n. 11
0
    def serialize(self):
        data = ControlBase.serialize(self)

        data.update({
            'horizontal_headers': self.horizontal_headers,
            'read_only': 1 if self._read_only else 0,
            'selected_index': self._selected_index,
            'select_entire_row': 1 if self._select_entire_row else 0,
        })
        return data
Esempio n. 12
0
 def serialize(self):
     res = ControlBase.serialize(self)
     res.update({
         'clear': self._clear,
         'has_more': self.has_more,
         'mode': self.mode
     })
     self._clear = False
     self.value = []
     return res
Esempio n. 13
0
    def serialize(self):
        data = ControlBase.serialize(self)
        queryset = self.value

        rows = []
        filters_list = []
        headers = []

        if queryset:
            model = queryset.model

            row_start = self.rows_per_page * (self._current_page - 1)
            row_end = self.rows_per_page * (self._current_page)

            for sort in self.sort_by:
                direction = '-' if sort['desc'] else ''
                queryset = queryset.order_by(direction + sort['column'])

            rows = self.queryset_to_list(queryset, self.list_display,
                                         row_start, row_end)

            if self.list_display:
                #configure the headers titles
                for column_name in self.list_display:
                    headers.append({
                        'label':
                        get_verbose_name(model, column_name),
                        'column':
                        column_name
                    })

            filters_list = self.serialize_filters(self.list_filter, queryset)

        if len(self.search_fields) > 0: data.update({'search_field_key': ''})

        data.update({
            'filters_list': filters_list,
            'filter_by': self.filter_by,
            'sort_by': self.sort_by,
            'pages': {
                'current_page': self._current_page,
                'pages_list': self.__get_pages_2_show(queryset)
            },
            'value': '',
            'values': rows,
            'horizontal_headers': headers,
            'selected_row_id': self._selected_row_id
        })

        if self._selected_row_id:
            data.update({})

        return data
Esempio n. 14
0
    def serialize(self):
        data = ControlBase.serialize(self)
        items = []
        for key, value in self._items.items():
            items.append({'text': key, 'value': value, 'name': key})

        value = self._value
        if value == True: value = 'true'
        if value == False: value = 'false'
        if value == None: value = 'null'

        data.update({'items': items, 'value': value})
        return data
Esempio n. 15
0
    def serialize(self):
        data = ControlBase.serialize(self)
        image = self.value
        if isinstance(image, np.ndarray):
            if len(image.shape) > 2:
                image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
            image = Image.fromarray(image)
            buff = StringIO.StringIO()
            image.save(buff, format="PNG")
            content = buff.getvalue()
            buff.close()

            data.update({'base64content': base64.b64encode(content)})
        data.update({'filename': self._filename})
        return data
Esempio n. 16
0
    def serialize(self):
        data = ControlBase.serialize(self)
        items = []

        if self.allow_none:
             items.append({'label': '---', 'value': None})

        for obj in self.queryset:
            if self._column:
                items.append({'label': str(getattr(obj,self._column)), 'value': obj.pk })
            else:
                items.append({'label': str(obj), 'value': obj.pk })

        data.update({ 'items': items, 'value': self._value })
        return data
Esempio n. 17
0
    def serialize(self):
        data = ControlBase.serialize(self)

        values = []
        for obj in (self.value if self.value else []):
            pk = obj.pk
            row = self.obj2list(obj) + [obj.pk]
            row[0] = self._checked.get(pk, False)
            values.append(row)

        data.update({
            'value': values,
            'headers': self.headers,
            'selected_index': self._selected_index,
            'add_button': self.add_func is not None,
            'remove_button': self.remove_func is not None
        })
        return data
Esempio n. 18
0
	def deserialize(self, properties):
		ControlBase.deserialize(self, properties)
		self.legend = properties[u'legend']
		self.value 	= properties[u'value']
		
Esempio n. 19
0
    def deserialize(self, properties):
        properties.update({'value': properties.get('value', [])})

        ControlBase.deserialize(self, properties)
Esempio n. 20
0
 def deserialize(self, properties):
     ControlBase.deserialize(self, properties)
     self._filename = properties['filename']
     self.value = self._filename
Esempio n. 21
0
 def deserialize(self, properties):
     ControlBase.deserialize(self,properties)
     self._selected_index    = properties['selected_index']
     
Esempio n. 22
0
    def serialize(self, init_form=False):
        data = ControlBase.serialize(self)
        queryset = self.value

        rows = []

        if self._update_list and queryset:
            row_start = self.rows_per_page * (self._current_page - 1)
            row_end = self.rows_per_page * (self._current_page)
            model = queryset.model

            if len(self.sort_by) > 0:
                for sort in self.sort_by:
                    direction = '-' if sort['desc'] else ''
                    queryset = queryset.order_by(direction + sort['column'])

            # if no order by exists add one, to avoid the values to be show randomly in the list
            order_by = list(queryset.query.order_by)
            if 'pk' not in order_by or '-pk' not in order_by:
                order_by.append('-pk')
                queryset = queryset.order_by(*order_by)

            rows = self.queryset_to_list(queryset, self.list_display,
                                         row_start, row_end)

            if init_form:
                filters_list = self.serialize_filters(self.list_filter,
                                                      queryset)
                data.update({'filters_list': filters_list})

        if init_form and self.list_display:
            #configure the headers titles
            headers = []
            for column_name in self.list_display:
                label = get_lookup_verbose_name(queryset.model, column_name)

                headers.append({'label': label, 'column': column_name})
            data.update({
                'horizontal_headers': headers,
            })

        if len(self.search_fields) > 0:
            data.update({
                'search_field_key':
                self.search_field_key
                if self.search_field_key is not None else ''
            })

        total_rows = queryset.count()
        total_n_pages = (total_rows / self.rows_per_page) + (0 if (
            total_rows % self.rows_per_page) == 0 else 1)

        data.update({
            'filter_by': self.filter_by,
            'sort_by': self.sort_by,
            'pages': {
                'current_page': self._current_page,
                'pages_list': self.__get_pages_2_show(queryset)
            },
            'pages_total': total_n_pages,
            'value': '',
            'values': rows,
            'values_total': total_rows,
            'selected_row_id': self._selected_row_id
        })

        return data
Esempio n. 23
0
 def __init__(self, *args, **kwargs):
     self._updateSlider = True
     self._min = kwargs.get('min', 0)
     self._max = kwargs.get('max', 100)
     ControlBase.__init__(self, *args, **kwargs)
Esempio n. 24
0
    def serialize(self):
        data = ControlBase.serialize(self)

        if self.value:
            data.update({'value': self.value.isoformat()})
        return data
Esempio n. 25
0
 def deserialize(self, properties):
     ControlBase.deserialize(self, properties)
     self._value = []
     self.action_param = properties.get('action_param', None)