本文整理汇总了Python中mozillians.common.templatetags.helpers.urlparams函数的典型用法代码示例。如果您正苦于以下问题:Python urlparams函数的具体用法?Python urlparams怎么用?Python urlparams使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了urlparams函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
voucher = UserFactory.create()
country = CountryFactory()
region = RegionFactory()
city = CityFactory()
self.user = UserFactory.create(
userprofile={'vouched': False,
'geo_country': country,
'geo_region': region,
'geo_city': city})
self.user.userprofile.vouch(voucher.userprofile)
group = GroupFactory.create()
group.add_member(self.user.userprofile)
skill = SkillFactory.create()
self.user.userprofile.skills.add(skill)
self.user.userprofile.externalaccount_set.create(type=ExternalAccount.TYPE_SUMO,
identifier='Apitest')
self.resource_url = reverse(
'api_dispatch_list',
kwargs={'api_name': 'v1', 'resource_name': 'users'})
self.mozilla_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=True)
self.mozilla_resource_url = urlparams(
self.resource_url, app_name=self.mozilla_app.name,
app_key=self.mozilla_app.key)
self.community_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=False)
self.community_resource_url = urlparams(
self.resource_url, app_name=self.community_app.name,
app_key=self.community_app.key)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:31,代码来源:test_api_v1.py
示例2: test_get_detail_mozilla_app
def test_get_detail_mozilla_app(self):
client = Client()
url = reverse('api_dispatch_detail',
kwargs={'api_name': 'v1', 'resource_name': 'users',
'pk': self.user.userprofile.id})
url = urlparams(url, app_name=self.mozilla_app.name,
app_key=self.mozilla_app.key)
response = client.get(url, follow=True)
data = json.loads(response.content)
profile = self.user.userprofile
eq_(response.status_code, 200)
eq_(data['id'], profile.id)
eq_(data['full_name'], profile.full_name)
eq_(data['is_vouched'], profile.is_vouched)
eq_(data['vouched_by'], profile.vouched_by.id)
# eq_(data['date_vouched'], profile.date_vouched)
eq_(data['groups'], list(profile.groups.values_list('name', flat=True)))
eq_(data['skills'], list(profile.skills.values_list('name', flat=True)))
eq_(data['accounts'],
[{'identifier': a.identifier, 'type': a.type}
for a in profile.externalaccount_set.all()])
eq_(data['bio'], profile.bio)
eq_(data['photo'], profile.photo)
eq_(data['photo_thumbnail'], profile.get_photo_url())
eq_(data['ircname'], profile.ircname)
eq_(data['country'], profile.geo_country.code)
eq_(data['region'], profile.geo_region.name)
eq_(data['city'], profile.geo_city.name)
eq_(data['date_mozillian'], profile.date_mozillian)
eq_(data['timezone'], profile.timezone)
eq_(data['email'], profile.email)
eq_(data['url'],
absolutify(reverse('phonebook:profile_view',
args=[profile.user.username])))
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:34,代码来源:test_api_v1.py
示例3: test_filter_all
def test_filter_all(self):
"""If they specify no filters, they get all the members"""
# Make user 1 the group curator so they can see requests
self.group.curators.add(self.user_1.userprofile)
self.group.accepting_new_members = 'by_request'
self.group.save()
# Make user 2 a full member
self.group.add_member(self.user_2.userprofile, GroupMembership.MEMBER)
member_membership = self.group.groupmembership_set.get(userprofile__user=self.user_2)
# Make user 3 a pending member
self.user_3 = UserFactory.create()
self.group.add_member(self.user_3.userprofile, GroupMembership.PENDING)
pending_membership = self.group.groupmembership_set.get(userprofile__user=self.user_3)
# Make user 4 a pending_terms member
self.user_4 = UserFactory.create()
self.group.add_member(self.user_4.userprofile, GroupMembership.PENDING_TERMS)
pending_terms_membership = self.group.groupmembership_set.get(
userprofile__user=self.user_4)
url = urlparams(self.url, filtr='all')
with self.login(self.user_1) as client:
response = client.get(url, follow=True)
people = response.context['people'].object_list
ok_(member_membership in people)
ok_(pending_membership in people)
ok_(pending_terms_membership in people)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:28,代码来源:test_show.py
示例4: test_search_no_ajax
def test_search_no_ajax(self):
user = UserFactory.create()
group = GroupFactory.create()
url = urlparams(reverse('groups:search_groups'), term=group.name)
with self.login(user) as client:
response = client.get(url, follow=True)
ok_(isinstance(response, HttpResponseBadRequest))
开发者ID:fxa90id,项目名称:mozillians,代码行数:7,代码来源:test_search.py
示例5: process_request
def process_request(self, request):
prefixer = urlresolvers.Prefixer(request)
urlresolvers.set_url_prefix(prefixer)
full_path = prefixer.fix(prefixer.shortened_path)
if self._is_lang_change(request):
# Blank out the locale so that we can set a new one. Remove lang
# from the query params so we don't have an infinite loop.
prefixer.locale = ''
new_path = prefixer.fix(prefixer.shortened_path)
query = dict((smart_str(k), request.GET[k]) for k in request.GET)
query.pop('lang')
return HttpResponsePermanentRedirect(urlparams(new_path, **query))
if full_path != request.path:
query_string = request.META.get('QUERY_STRING', '')
full_path = urllib.quote(full_path.encode('utf-8'))
if query_string:
full_path = '%s?%s' % (full_path, query_string)
response = HttpResponsePermanentRedirect(full_path)
# Vary on Accept-Language if we changed the locale
old_locale = prefixer.locale
new_locale, _ = urlresolvers.split_path(full_path)
if old_locale != new_locale:
response['Vary'] = 'Accept-Language'
return response
request.path_info = '/' + prefixer.shortened_path
request.locale = prefixer.locale
activate(prefixer.locale)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:34,代码来源:middleware.py
示例6: test_request_with_huge_limit
def test_request_with_huge_limit(self):
client = Client()
url = urlparams(self.mozilla_resource_url, limit=200000000000000000000)
response = client.get(url, follow=True)
eq_(response.status_code, 200)
data = json.loads(response.content)
eq_(data['meta']['limit'], 1)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:7,代码来源:test_api_v1.py
示例7: test_community_app_does_not_allow_community_sites
def test_community_app_does_not_allow_community_sites(self):
user = UserFactory.create(userprofile={'allows_community_sites': False})
client = Client()
url = urlparams(self.community_resource_url, email=user.email)
response = client.get(url, follow=True)
data = json.loads(response.content)
eq_(response.status_code, 200)
eq_(len(data['objects']), 0)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:8,代码来源:test_api_v1.py
示例8: test_search_username
def test_search_username(self):
user = UserFactory.create()
url = urlparams(self.mozilla_resource_url, username=user.username)
client = Client()
response = client.get(url, follow=True)
data = json.loads(response.content)
eq_(len(data['objects']), 1)
eq_(data['objects'][0]['id'], user.userprofile.id)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:8,代码来源:test_api_v1.py
示例9: test_search_incomplete_profile
def test_search_incomplete_profile(self):
user = UserFactory.create(vouched=True, userprofile={"full_name": ""})
group = GroupFactory.create(visible=True)
url = urlparams(reverse("groups:skills-autocomplete"), q=group.name)
with self.login(user) as client:
response = client.get(url, follow=True, **{"HTTP_X_REQUESTED_WITH": "XMLHttpRequest"})
eq_(response.status_code, 200)
eq_(response.get("content-type"), "application/json")
开发者ID:johngian,项目名称:mozillians,代码行数:8,代码来源:test_search.py
示例10: test_search_unvouched
def test_search_unvouched(self):
user = UserFactory.create(vouched=False)
group = GroupFactory.create(visible=True)
url = urlparams(reverse("groups:search_groups"), term=group.name)
with self.login(user) as client:
response = client.get(url, follow=True, **{"HTTP_X_REQUESTED_WITH": "XMLHttpRequest"})
eq_(response.status_code, 200)
eq_(response.get("content-type"), "application/json")
开发者ID:johngian,项目名称:mozillians,代码行数:8,代码来源:test_search.py
示例11: test_mozilla_app_does_allows_mozilla_sites
def test_mozilla_app_does_allows_mozilla_sites(self):
user = UserFactory.create(userprofile={'allows_mozilla_sites': True})
client = Client()
url = urlparams(self.mozilla_resource_url, email=user.email)
response = client.get(url, follow=True)
data = json.loads(response.content)
eq_(response.status_code, 200)
eq_(len(data['objects']), 1)
eq_(data['objects'][0]['email'], user.email)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:9,代码来源:test_api_v1.py
示例12: test_is_vouched_false
def test_is_vouched_false(self):
UserFactory.create()
user = UserFactory.create(vouched=False)
client = Client()
url = urlparams(self.mozilla_resource_url, is_vouched='false')
response = client.get(url, follow=True)
data = json.loads(response.content)
eq_(len(data['objects']), 1)
eq_(data['objects'][0]['id'], user.userprofile.id)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:9,代码来源:test_api_v1.py
示例13: test_request_with_huge_offset
def test_request_with_huge_offset(self):
UserFactory.create()
UserFactory.create()
client = Client()
url = urlparams(self.mozilla_resource_url, offset=100000000)
response = client.get(url, follow=True)
eq_(response.status_code, 200)
data = json.loads(response.content)
eq_(data['meta']['offset'], data['meta']['total_count'])
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:9,代码来源:test_api_v1.py
示例14: test_get_detail_community_app
def test_get_detail_community_app(self):
client = Client()
url = reverse('api_dispatch_detail',
kwargs={'api_name': 'v1', 'resource_name': 'users',
'pk': self.user.userprofile.id})
url = urlparams(url, app_name=self.community_app.name,
app_key=self.community_app.key)
response = client.get(url, follow=True)
eq_(response.status_code, 403)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:9,代码来源:test_api_v1.py
示例15: test_send_invitation_email_no_curator_manager
def test_send_invitation_email_no_curator_manager(self):
inviter, redeemer = UserFactory.create_batch(2)
invite = InviteFactory.create(inviter=inviter.userprofile, redeemer=redeemer.userprofile)
user = UserFactory.create()
with self.login(user) as client:
url = urlparams(reverse("groups:send_invitation_email", args=[invite.pk]), "invitation")
response = client.get(url, follow=True)
eq_(response.status_code, 404)
开发者ID:johngian,项目名称:mozillians,代码行数:9,代码来源:test_invite.py
示例16: test_search_name
def test_search_name(self):
user = UserFactory.create(userprofile={'full_name': u'Νίκος Κούκος'})
client = Client()
url = urlparams(self.mozilla_resource_url,
name=user.userprofile.full_name)
request = client.get(url, follow=True)
data = json.loads(request.content)
eq_(len(data['objects']), 1)
eq_(data['objects'][0]['id'], user.userprofile.id)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:9,代码来源:test_api_v1.py
示例17: test_is_vouched_true
def test_is_vouched_true(self):
UserFactory.create()
UserFactory.create(vouched=False)
client = Client()
url = urlparams(self.mozilla_resource_url, is_vouched='true')
response = client.get(url, follow=True)
data = json.loads(response.content)
for obj in data['objects']:
ok_(obj['is_vouched'])
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:9,代码来源:test_api_v1.py
示例18: test_query_with_space
def test_query_with_space(self):
city = CityFactory.create(name='Mountain View')
user = UserFactory.create(userprofile={'geo_city': city})
client = Client()
url = urlparams(self.mozilla_resource_url, city='mountain view')
request = client.get(url, follow=True)
data = json.loads(request.content)
eq_(len(data['objects']), 1)
eq_(data['objects'][0]['id'], user.userprofile.id)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:9,代码来源:test_api_v1.py
示例19: test_search_region
def test_search_region(self):
region = RegionFactory.create(name='la lo')
user = UserFactory.create(userprofile={'geo_region': region})
url = urlparams(self.mozilla_resource_url,
region=user.userprofile.geo_region.name)
client = Client()
response = client.get(url, follow=True)
data = json.loads(response.content)
eq_(len(data['objects']), 1)
eq_(data['objects'][0]['id'], user.userprofile.id)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:10,代码来源:test_api_v1.py
示例20: test_search_city
def test_search_city(self):
city = CityFactory.create(name=u'αθήνα')
user = UserFactory.create(userprofile={'geo_city': city})
url = urlparams(self.mozilla_resource_url,
city=user.userprofile.geo_city.name)
client = Client()
response = client.get(url, follow=True)
data = json.loads(response.content)
eq_(len(data['objects']), 1)
eq_(data['objects'][0]['id'], user.userprofile.id)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:10,代码来源:test_api_v1.py
注:本文中的mozillians.common.templatetags.helpers.urlparams函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论