Ejemplo n.º 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)
                    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
Ejemplo n.º 2
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.pk