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


Python HttpRequest.get_full_path方法代码示例

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


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

示例1: get

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
def get(request: HttpRequest, user_id: Optional[int]=None) -> HttpResponse:
    user = request.user if user_id is None else User.objects.get(pk=user_id)
    is_logged_in_user = request.user.id == user.id
    if not is_logged_in_user and not request.user.profile.is_verified_by_admin:
        raise PermissionDenied

    attendance = user.profile.try_fetch_current_attendance()
    if attendance:
        attendance_form = AttendanceProfileForm(instance=attendance)
    elif is_logged_in_user:
        attendance_form = AttendanceProfileForm()
    else:
        # There exists no AttendanceProfile already, so if the page isn't
        # editable we don't want to display a form.
        attendance_form = None

    all_skills_by_name = {s.name: s for s in Skill.objects.all()}
    my_skills_by_name = {s.name: s for s in user.profile.skills.all()}
    other_skills_by_name = {}
    for skill_name in all_skills_by_name:
        if skill_name in my_skills_by_name:
            continue
        other_skills_by_name[skill_name] = all_skills_by_name[skill_name]

    all_food_restrictions_by_name = {fr.name: fr for fr in FoodRestriction.objects.all()}
    my_food_restrictions_by_name = {fr.name: fr for fr in user.profile.food_restrictions.all()}
    other_food_restrictions_by_name = {}
    for fr_name in all_food_restrictions_by_name:
        if fr_name in my_food_restrictions_by_name:
            continue
        other_food_restrictions_by_name[fr_name] = all_food_restrictions_by_name[fr_name]

    notifications = []
    if is_logged_in_user:
        if attendance_form.instance.pk and not attendance_form.instance.paid_dues:
            notifications.append(Notification('pay_dues', current_url=request.get_full_path()))

        if user.profile.years_on_playa == 0 and not Notification.is_dismissed('newbie', request):
            notifications.append(Notification('newbie',
                                              current_url=request.get_full_path(),
                                              is_dismissible=True))

    return render(request, 'user_profile/view.html', context={
        'profile': user.profile,
        'is_editable': is_logged_in_user,
        'attendance_form': attendance_form,
        'messages': messages.get_messages(request),
        'other_skills': other_skills_by_name.values(),
        'other_food_restrictions': other_food_restrictions_by_name.values(),
        'notifications': notifications,
    })
开发者ID:joyfulflyer,项目名称:playacamp,代码行数:53,代码来源:user_profile.py

示例2: test_httprequest_full_path_with_query_string_and_fragment

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
 def test_httprequest_full_path_with_query_string_and_fragment(self):
     request = HttpRequest()
     request.path = '/foo#bar'
     request.path_info = '/prefix' + request.path
     request.META['QUERY_STRING'] = 'baz#quux'
     self.assertEqual(request.get_full_path(), '/foo%23bar?baz#quux')
     self.assertEqual(request.get_full_path_info(), '/prefix/foo%23bar?baz#quux')
开发者ID:GeyseR,项目名称:django,代码行数:9,代码来源:tests.py

示例3: company

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
def company(request):
    title = baseTitle + "Company Profile"
    eAddress = HttpRequest.get_full_path(request)

    index = eAddress.find("0x")
    aboutC= "None"
    phoneNr = ""
    emailC = ""
    addressCountryC = ""
    addressStreetC = ""
    addressZipC = ""

    if index > 0:
        address = eAddress[index:]
        c = Company.objects.get(admin=address)
        phoneNr = c.phoneNumber
        aboutC = c.about
        emailC = c.email
        addressCountryC = c.addressCountry
        addressStreetC = c.addressStreet
        addressZipC = c.addressPostCode

    context = RequestContext(request, dict(title=title, about=aboutC, phone=phoneNr, email=emailC, addressCountry=addressCountryC, addressStreet=addressStreetC, addressZip=addressZipC))
    template = loader.get_template('public/company_profile.html')
    return HttpResponse(template.render(context))
开发者ID:loreV,项目名称:Steadlly,代码行数:27,代码来源:views.py

示例4: __call__

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
    def __call__(self, request: HttpRequest) -> HttpResponseBase:
        domain = request.META.get('HTTP_HOST', '')

        if (not (domain == domain.lower())):
            url = '//{domain}{path}'.format(
                domain=domain.lower(),
                path=request.get_full_path(),
            )
            return redirect(to=url, permanent=(not (django_settings.DEBUG)))

        site = Site.objects.get_current()

        for language_code, language_name in django_settings.LANGUAGES:
            if (domain == "{language_code}.{domain}".format(language_code=language_code, domain=site.domain)):
                translation.activate(language_code)
                request.LANGUAGE_CODE = translation.get_language()
                return self.get_response(request=request)

        try:
            if (request.path == reverse('accounts:set_session')):
                return self.get_response(request=request)
        except NoReverseMatch:
            pass

        if (not (domain == "www.{domain}".format(domain=site.domain))):
            for _site in Site.objects.all().order_by("pk"):
                if (_site.domain in domain):
                    other_site = _site
                    return redirect_to_www(site=other_site)
            other_site = None
            if ("match" in domain):
                other_site = Site.objects.get(pk=django_settings.SPEEDY_MATCH_SITE_ID)
            elif ("composer" in domain):
                other_site = Site.objects.get(pk=django_settings.SPEEDY_COMPOSER_SITE_ID)
            elif ("mail" in domain):
                other_site = Site.objects.get(pk=django_settings.SPEEDY_MAIL_SOFTWARE_SITE_ID)
            else:
                other_site = Site.objects.get(pk=django_settings.SPEEDY_NET_SITE_ID)
            if ((other_site is not None) and (other_site.id in [_site.id for _site in Site.objects.all().order_by("pk")])):
                return redirect_to_www(site=other_site)
            else:
                raise Exception("Unexpected: other_site={}".format(other_site))

        if (not (request.get_full_path() == '/')):
            return redirect_to_www(site=site)

        return language_selector(request=request)
开发者ID:urievenchen,项目名称:speedy-net,代码行数:49,代码来源:middleware.py

示例5: test_httprequest_full_path

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
 def test_httprequest_full_path(self):
     request = HttpRequest()
     request.path = '/;some/?awful/=path/foo:bar/'
     request.path_info = '/prefix' + request.path
     request.META['QUERY_STRING'] = ';some=query&+query=string'
     expected = '/%3Bsome/%3Fawful/%3Dpath/foo:bar/?;some=query&+query=string'
     self.assertEqual(request.get_full_path(), expected)
     self.assertEqual(request.get_full_path_info(), '/prefix' + expected)
开发者ID:GeyseR,项目名称:django,代码行数:10,代码来源:tests.py

示例6: _wrapped_view

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
 def _wrapped_view(request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
     if test_func(request):
         return view_func(request, *args, **kwargs)
     path = request.build_absolute_uri()
     resolved_login_url = resolve_url(login_url or settings.LOGIN_URL)
     # If the login url is the same scheme and net location then just
     # use the path as the "next" url.
     login_scheme, login_netloc = urllib.parse.urlparse(resolved_login_url)[:2]
     current_scheme, current_netloc = urllib.parse.urlparse(path)[:2]
     if ((not login_scheme or login_scheme == current_scheme) and
             (not login_netloc or login_netloc == current_netloc)):
         path = request.get_full_path()
     return redirect_to_login(
         path, resolved_login_url, redirect_field_name)
开发者ID:brainwane,项目名称:zulip,代码行数:16,代码来源:decorator.py

示例7: token_splash_page

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
    def token_splash_page(request):
        """show token splash page"""
        if valid_token(request): #User got here by entering a non-existent URL
            raise Http404

        #This is shown on any page, to users who have no valid token 
        logout(request)
        template_vars = {}
        if settings.SPLASHPAGENOTOKENS:
            template_path = 'splash_no_tokens.html'
        else:
            template_path = 'splash.html'
            template_vars['thispage'] = HttpRequest.get_full_path(request)
        template_vars.update({
            'title' : _('Welcome to STIGMERGY!'),
            'subtitle' : _('<prj_subtitle>')
        })
        return render_to_response(template_path, template_vars,
                                  context_instance=RequestContext(request))
开发者ID:fason,项目名称:stigmergy,代码行数:21,代码来源:token.py

示例8: test_httprequest_full_path_with_query_string_and_fragment

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
 def test_httprequest_full_path_with_query_string_and_fragment(self):
     request = HttpRequest()
     request.path = request.path_info = "/foo#bar"
     request.META["QUERY_STRING"] = "baz#quux"
     self.assertEqual(request.get_full_path(), "/foo%23bar?baz#quux")
开发者ID:lazmicommunication,项目名称:django,代码行数:7,代码来源:tests.py

示例9: test_httprequest_full_path

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import get_full_path [as 别名]
 def test_httprequest_full_path(self):
     request = HttpRequest()
     request.path = request.path_info = "/;some/?awful/=path/foo:bar/"
     request.META["QUERY_STRING"] = ";some=query&+query=string"
     expected = "/%3Bsome/%3Fawful/%3Dpath/foo:bar/?;some=query&+query=string"
     self.assertEqual(request.get_full_path(), expected)
开发者ID:lazmicommunication,项目名称:django,代码行数:8,代码来源:tests.py


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