Beispiel #1
0
    def get_init_widget(self):
        portal = []
        widgets = self.widgets
        for col in widgets:
            portal_col = []
            for opts in col:
                try:
                    widget = UserWidget(user=self.user,
                                        page_id=self.get_page_id(),
                                        widget_type=opts['type'])
                    widget.set_value(opts)
                    if self.widget_customiz:
                        widget.save()
                    else:
                        widget.id = 0
                    portal_col.append(self.get_widget(widget))
                except (PermissionDenied, WidgetDataError):
                    if self.widget_customiz:
                        widget.delete()
                    continue
            portal.append(portal_col)
        if self.widget_customiz:
            UserSettings(user=self.user,
                         key="dashboard:%s:pos" % self.get_page_id(),
                         value='|'.join([
                             ','.join([str(w.id) for w in col])
                             for col in portal
                         ])).save()

        return portal
Beispiel #2
0
    def get_init_widget(self):
        portal = []
        widgets = self.widgets
        for col in widgets:
            portal_col = []
            for opts in col:
                try:
                    widget = UserWidget(user=self.user, page_id=self.get_page_id(), widget_type=opts['type'])
                    widget.set_value(opts)
                    if self.widget_customiz:
                        widget.save()
                    else:
                        widget.id = 0
                    portal_col.append(self.get_widget(widget))
                except (PermissionDenied, WidgetDataError):
                    if self.widget_customiz:
                        widget.delete()
                    continue
            portal.append(portal_col)
        if self.widget_customiz:
            UserSettings(
                user=self.user, key="dashboard:%s:pos" % self.get_page_id(),
                value='|'.join([','.join([str(w.id) for w in col]) for col in portal])).save()

        return portal
Beispiel #3
0
    def get_init_widget(self):
        portal = []
        widgets = self.widgets
        for col in widgets:
            portal_col = []
            for opts in col:
                try:
                    widget = UserWidget(
                        user=self.user,
                        page_id=self.get_page_id(),
                        widget_type=opts["type"],
                    )
                    widget.set_value(opts)
                    widget.save()
                    portal_col.append(self.get_widget(widget))
                except (PermissionDenied, WidgetDataError):
                    widget.delete()
                    continue
            portal.append(portal_col)

        UserSettings(
            user=self.user,
            key="dashboard:%s:pos" % self.get_page_id(),
            value="|".join(
                [",".join([str(w.id) for w in col]) for col in portal]),
        ).save()

        return portal
    def get_init_widget(self):
        portal = []
        widgets = self.widgets
        # print('zheline')
        for col in widgets:
            portal_col = []
            for opts in col:
                try:
                    # print("zhelizhixinglema")
                    widget = UserWidget(user=self.user,
                                        page_id=self.get_page_id(),
                                        widget_type=opts['type'])
                    # widget = UserWidget( page_id=self.get_page_id(), widget_type=opts['type'])
                    widget.set_value(opts)
                    widget.save()
                    portal_col.append(self.get_widget(widget))
                except (PermissionDenied, WidgetDataError):
                    # raise Exception
                    widget.delete()
                    continue
            portal.append(portal_col)

        UserSettings(user=self.user,
                     key="dashboard:%s:pos" % self.get_page_id(),
                     value='|'.join([
                         ','.join([str(w.id) for w in col]) for col in portal
                     ])).save()

        return portal
Beispiel #5
0
    def get_init_widget(self):
        portal = []
        widgets = self.widgets
        for col in widgets:
            portal_col = []
            for opts in col:
                try:
                    widget = UserWidget(user=self.user, page_id=self.get_page_id(), widget_type=opts['type'])
                    widget.set_value(opts)
                    widget.save()
                    portal_col.append(self.get_widget(widget))
                except (PermissionDenied, WidgetDataError):
                    logging.error('add widget fail %s', opts, exc_info=True)
                    widget.delete()
                    continue
            portal.append(portal_col)

        UserSettings(
            user=self.user, key="dashboard:%s:pos" % self.get_page_id(),
            value='|'.join([','.join([str(w.id) for w in col]) for col in portal])).save()

        return portal
    def get_init_widget(self):
        portal = []
        widgets = self.widgets
        for col in widgets:
            portal_col = []
            for opts in col:
                try:
                    widget = UserWidget(user=self.user, page_id=self.get_page_id(), widget_type=opts["type"])
                    widget.set_value(opts)
                    widget.save()
                    portal_col.append(self.get_widget(widget))
                except (PermissionDenied, WidgetDataError):
                    widget.delete()
                    continue
            portal.append(portal_col)

        UserSettings(
            user=self.user,
            key="dashboard:%s:pos" % self.get_page_id(),
            value="|".join([",".join([str(w.id) for w in col]) for col in portal]),
        ).save()

        return portal
Beispiel #7
0
 def convert_widget_params(self, wizard, cleaned_data, form):
     widget = UserWidget()
     value = dict([(f.name, f.value()) for f in form])
     widget.set_value(value)
     cleaned_data['value'] = widget.value
     cleaned_data['user'] = self.user
 def convert_widget_params(self, wizard, cleaned_data, form):
     widget = UserWidget()
     value = dict([(f.name, f.value()) for f in form])
     widget.set_value(value)
     cleaned_data['value'] = widget.value
     cleaned_data['user'] = self.user.pk