当前位置: 首页>>代码示例>>Python>>正文


Python UserSettings.DoesNotExist方法代码示例

本文整理汇总了Python中xadmin.models.UserSettings.DoesNotExist方法的典型用法代码示例。如果您正苦于以下问题:Python UserSettings.DoesNotExist方法的具体用法?Python UserSettings.DoesNotExist怎么用?Python UserSettings.DoesNotExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xadmin.models.UserSettings的用法示例。


在下文中一共展示了UserSettings.DoesNotExist方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_widget

# 需要导入模块: from xadmin.models import UserSettings [as 别名]
# 或者: from xadmin.models.UserSettings import DoesNotExist [as 别名]
def get_widget(self, widget_or_id, data=None):
        try:
            if isinstance(widget_or_id, UserWidget):
                widget = widget_or_id
            else:
                widget = UserWidget.objects.get(user=self.user, page_id=self.get_page_id(), id=widget_or_id)
            wid = widget_manager.get(widget.widget_type)

            class widget_with_perm(wid):
                def context(self, context):
                    super(widget_with_perm, self).context(context)
                    context.update({'has_change_permission': self.request.user.has_perm('xadmin.change_userwidget')})
            wid_instance = widget_with_perm(self, data or widget.get_value())
            return wid_instance
        except UserWidget.DoesNotExist:
            return None 
开发者ID:stormsha,项目名称:StormOnline,代码行数:18,代码来源:dashboard.py

示例2: post

# 需要导入模块: from xadmin.models import UserSettings [as 别名]
# 或者: from xadmin.models.UserSettings import DoesNotExist [as 别名]
def post(self, request, *args, **kwargs):
        if 'id' in request.POST:
            widget_id = request.POST['id']
            if request.POST.get('_delete', None) != 'on':
                widget = self.get_widget(widget_id, request.POST.copy())
                widget.save()
            else:
                try:
                    widget = UserWidget.objects.get(
                        user=self.user, page_id=self.get_page_id(), id=widget_id)
                    widget.delete()
                    try:
                        portal_pos = UserSettings.objects.get(user=self.user, key="dashboard:%s:pos" % self.get_page_id())
                        pos = [[w for w in col.split(',') if w != str(
                            widget_id)] for col in portal_pos.value.split('|')]
                        portal_pos.value = '|'.join([','.join(col) for col in pos])
                        portal_pos.save()
                    except Exception:
                        pass
                except UserWidget.DoesNotExist:
                    pass

        return self.get(request) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:25,代码来源:dashboard.py

示例3: get_widget

# 需要导入模块: from xadmin.models import UserSettings [as 别名]
# 或者: from xadmin.models.UserSettings import DoesNotExist [as 别名]
def get_widget(self, widget_or_id, data=None):
        try:
            if isinstance(widget_or_id, UserWidget):
                widget = widget_or_id
            else:
                widget = UserWidget.objects.get(user=self.user, page_id=self.get_page_id(), id=widget_or_id)
            wid = widget_manager.get(widget.widget_type)

            class widget_with_perm(wid):

                def context(self, context):
                    super(widget_with_perm, self).context(context)
                    context.update({'has_change_permission': self.request.user.has_perm('xadmin.change_userwidget')})
            wid_instance = widget_with_perm(self, data or widget.get_value())
            return wid_instance
        except UserWidget.DoesNotExist:
            return None 
开发者ID:Superbsco,项目名称:weibo-analysis-system,代码行数:19,代码来源:dashboard.py

示例4: update_dashboard

# 需要导入模块: from xadmin.models import UserSettings [as 别名]
# 或者: from xadmin.models.UserSettings import DoesNotExist [as 别名]
def update_dashboard(self, obj):
        try:
            portal_pos = UserSettings.objects.get(
                user=obj.user, key="dashboard:%s:pos" % obj.page_id)
        except UserSettings.DoesNotExist:
            return
        pos = [[w for w in col.split(',') if w != str(
            obj.id)] for col in portal_pos.value.split('|')]
        portal_pos.value = '|'.join([','.join(col) for col in pos])
        portal_pos.save() 
开发者ID:stormsha,项目名称:StormOnline,代码行数:12,代码来源:dashboard.py


注:本文中的xadmin.models.UserSettings.DoesNotExist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。