本文整理汇总了Python中core.models.User方法的典型用法代码示例。如果您正苦于以下问题:Python models.User方法的具体用法?Python models.User怎么用?Python models.User使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models
的用法示例。
在下文中一共展示了models.User方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def list(self, djangoClass, user):
try:
queryset = djangoClass.objects.all()
filtered_queryset = (
elt
for elt in queryset
if self.xos_security_check(elt, user, read_access=True)
)
# FIXME: Implement auditing here
# logging.info("User requested x objects, y objects were filtered out by policy z")
response = self.querysetToProto(djangoClass, filtered_queryset)
return response
except BaseException:
log.exception("Exception in apihelper.list")
raise
示例2: xos_security_gate
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def xos_security_gate(self, obj, user, **access_types):
sec_ctx = XOSDefaultSecurityContext()
if not user:
user = xos_anonymous_user
sec_ctx.user = user
for k, v in access_types.items():
setattr(sec_ctx, k, v)
verdict, policy_name = obj.can_access(ctx=sec_ctx)
# FIXME: This is the central point of enforcement for security policies
# Implement Auditing here.
# logging.info( ... )
if not verdict:
# logging.critical( ... )
if obj.id:
object_descriptor = "object %d" % obj.id
else:
object_descriptor = "new object"
raise XOSPermissionDenied(
"User %(user_email)s cannot access %(django_class_name)s %(descriptor)s due to policy %(policy_name)s"
% {
"user_email": user.email,
"django_class_name": obj.__class__.__name__,
"policy_name": policy_name,
"descriptor": object_descriptor,
}
)
示例3: pm_name_field
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def pm_name_field(self, obj):
user = get_object_or_404(models.User, id=obj.proposed_by.id)
return user.name
示例4: pm_email_field
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def pm_email_field(self, obj):
user = get_object_or_404(models.User, id=obj.proposed_by.id)
return user.email
示例5: clean_email
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def clean_email(self):
email = self.cleaned_data.get('email')
if User.objects.filter(email=email):
raise forms.ValidationError(u'Email addresses must be unique.')
return email
示例6: get_email
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def get_email(self):
user = get_object_or_404(User, id=self.assigned_to.id)
return user.email
示例7: get_name
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def get_name(self):
user = get_object_or_404(User, id=self.member.id)
return user.name
示例8: filter
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def filter(self, djangoClass, user, request):
try:
if request.kind == request.DEFAULT:
query = self.build_filter(request, None)
queryset = djangoClass.objects.filter(query)
elif request.kind == request.SYNCHRONIZER_DIRTY_OBJECTS:
query = (
(
Q(enacted=None)
| Q(enacted__lt=F("updated"))
| Q(enacted__lt=F("changed_by_policy"))
)
& Q(lazy_blocked=False)
& Q(no_sync=False)
)
query = self.build_filter(request, query)
queryset = djangoClass.objects.filter(query)
elif request.kind == request.SYNCHRONIZER_DELETED_OBJECTS:
query = self.build_filter(request, None)
if query:
queryset = djangoClass.deleted_objects.filter(query)
else:
queryset = djangoClass.deleted_objects.all()
elif request.kind == request.SYNCHRONIZER_DIRTY_POLICIES:
query = (
Q(policed=None)
| Q(policed__lt=F("updated"))
| Q(policed__lt=F("changed_by_step"))
) & Q(no_policy=False)
query = self.build_filter(request, query)
queryset = djangoClass.objects.filter(query)
elif request.kind == request.SYNCHRONIZER_DELETED_POLICIES:
query = Q(policed__lt=F("updated")) | Q(policed=None)
query = self.build_filter(request, query)
queryset = djangoClass.deleted_objects.filter(query)
elif request.kind == request.ALL:
queryset = djangoClass.objects.all()
filtered_queryset = (
elt
for elt in queryset
if self.xos_security_check(elt, user, read_access=True)
)
# FIXME: Implement auditing here
# logging.info("User requested x objects, y objects were filtered out by policy z")
response = self.querysetToProto(djangoClass, filtered_queryset)
return response
except BaseException:
log.exception("Exception in apihelper.filter")
raise
示例9: search
# 需要导入模块: from core import models [as 别名]
# 或者: from core.models import User [as 别名]
def search(request, *args, **kwargs):
payload = json.loads(request.body.decode())
if 'steam' in payload:
steamid = SteamID.from_url('https://steamcommunity.com/id/' + payload['steam'])
if not steamid:
data = []
else:
data = User.objects.filter(username=str(steamid.as_64))
if not data:
user = User()
user.is_steam = True
user.is_active = False
user.username = str(steamid.as_64)
user.save()
populate(user)
data = [user]
elif 'steam64' in payload:
data = User.objects.filter(username=str(payload['steam64']))
if not data:
user = User()
user.is_steam = True
user.is_active = False
user.username = str(payload['steam64'])
populate(user)
data = [user]
elif 'local' in payload:
data = User.objects.filter(is_steam=True, namespace__icontains=payload['local'])
data = list(data)
elif 'steam' in payload:
user = User()
user.is_steam = False
user.is_active = False
user.username = payload['steam']
user.save()
data = [user]
return render(request, 'components/globals/dropdown/wrapper.pug',
{'data': data[:settings.PAGE_SIZE]})