當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。