本文整理汇总了Python中mozillians.users.models.UserProfile.privacy_fields方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.privacy_fields方法的具体用法?Python UserProfile.privacy_fields怎么用?Python UserProfile.privacy_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozillians.users.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.privacy_fields方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_privacy_level_without_save
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
def test_set_privacy_level_without_save(self):
user = UserFactory.create()
user.userprofile.set_privacy_level(9, save=False)
for field in UserProfile.privacy_fields():
eq_(getattr(user.userprofile, "privacy_{0}".format(field)), 9, "Field {0} not set".format(field))
user = User.objects.get(id=user.id)
for field in UserProfile.privacy_fields():
# Compare to default privacy setting for each field.
f = UserProfile._meta.get_field_by_name("privacy_{0}".format(field))[0]
eq_(getattr(user.userprofile, "privacy_{0}".format(field)), f.default, "Field {0} not set".format(field))
示例2: test_caching
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
def test_caching(self):
# It would be better if this test didn't need to know how the
# caching worked.
# To compute the privacy fields, the code has to get all the
# field names. Use mock so we can tell if that gets called.
with patch.object(UserProfile._meta, 'get_all_field_names') as mock_get_all_field_names:
UserProfile.privacy_fields()
ok_(mock_get_all_field_names.called)
# If we call privacy_fields() again, it shouldn't need to compute it all again
with patch.object(UserProfile._meta, 'get_all_field_names') as mock_get_all_field_names:
UserProfile.privacy_fields()
ok_(not mock_get_all_field_names.called)
示例3: test_profile_model
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
def test_profile_model(self):
fields = UserProfile.privacy_fields()
eq_('', fields['ircname'])
eq_('', fields['email'])
ok_('is_vouched' not in fields)
ok_('date_vouched' not in fields)
ok_(fields['tshirt'] is None)
示例4: test_set_privacy_level_with_save
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
def test_set_privacy_level_with_save(self):
user = UserFactory.create()
user.userprofile.set_privacy_level(9)
user = User.objects.get(id=user.id)
for field in UserProfile.privacy_fields():
eq_(getattr(user.userprofile, 'privacy_{0}'.format(field)), 9,
'Field {0} not set'.format(field))
示例5: test_profile_model
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
def test_profile_model(self):
fields = UserProfile.privacy_fields()
eq_("", fields["ircname"])
eq_("", fields["email"])
ok_("is_vouched" not in fields)
ok_("date_vouched" not in fields)
ok_(fields["tshirt"] is None)
示例6: import
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
from import_export.resources import ModelResource
from sorl.thumbnail.admin import AdminImageMixin
import mozillians.users.tasks
from mozillians.common.helpers import get_datetime
from mozillians.groups.models import GroupMembership, Skill
from mozillians.users.cron import index_all_profiles
from mozillians.users.models import (PUBLIC, Language, ExternalAccount, Vouch,
UserProfile, UsernameBlacklist)
admin.site.unregister(Group)
Q_PUBLIC_PROFILES = Q()
for field in UserProfile.privacy_fields():
key = 'privacy_%s' % field
Q_PUBLIC_PROFILES |= Q(**{key: PUBLIC})
def subscribe_to_basket_action():
"""Subscribe to Basket action."""
def subscribe_to_basket(modeladmin, request, queryset):
"""Subscribe to Basket or update details of already subscribed."""
ts = [(mozillians.users.tasks.update_basket_task
.subtask(args=[userprofile.id]))
for userprofile in queryset]
TaskSet(ts).apply_async()
messages.success(request, 'Basket update started.')
subscribe_to_basket.short_description = 'Subscribe to or Update Basket'
示例7: test_is_public
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
def test_is_public(self):
for field in UserProfile.privacy_fields():
user = UserFactory.create(
userprofile={'privacy_{0}'.format(field): PUBLIC})
ok_(user.userprofile.is_public,
'Field {0} did not set profile to public'.format(field))
示例8: test_tshirt_public
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
def test_tshirt_public(self):
user = UserFactory.create(userprofile={'tshirt': 9})
public_profile = user.userprofile
public_profile.set_instance_privacy_level(PUBLIC)
eq_(public_profile.tshirt, UserProfile.privacy_fields()['tshirt'])
示例9: test_email_private
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import privacy_fields [as 别名]
def test_email_private(self):
user = UserFactory.create()
public_profile = user.userprofile
public_profile.set_instance_privacy_level(PUBLIC)
eq_(public_profile.email, UserProfile.privacy_fields()['email'])