• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python settings.use_editable函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mezzanine.conf.settings.use_editable函数的典型用法代码示例。如果您正苦于以下问题:Python use_editable函数的具体用法?Python use_editable怎么用?Python use_editable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: blog_post_home

def blog_post_home(request, template="index.html"):
    settings.use_editable()
    templates = []

    cnt = 8
    news = BlogPost.objects.published(for_user=request.user).filter(categories=cate_dics['news'])[:cnt]

    acts = list(BlogPost.objects.published(for_user=request.user).filter(categories=cate_dics['activity'])[:cnt])

    briefs = BlogPost.objects.published(for_user=request.user).filter(categories=cate_dics['brief'])[:cnt]
    
    coms = BlogPost.objects.published(for_user=request.user).filter(categories=cate_dics['company'])[:cnt]

    clubs = BlogPost.objects.published(for_user=request.user).filter(categories=cate_dics['club'])[:cnt]

    jobs = BlogPost.objects.published(for_user=request.user).filter(categories=cate_dics['job'])[:cnt]

    ap_links = ApplyLink.objects.filter(permit=True)

    images = []
    for a in acts:
        if a.featured_image:
            images.append(a.featured_image.url)
    if len(images) < 6:
        images += static_images[:cnt-len(images)]
    #print images

    context = {"news":news, "blog_posts": acts, "briefs":briefs, "coms":coms, "clubs":clubs,  "jobs":jobs, 'imgs':images, 'ap_links':ap_links}

    templates.append(template)
    return render(request, templates, context)
开发者ID:toway,项目名称:chuanda,代码行数:31,代码来源:views.py


示例2: blog_homepage

def blog_homepage(request):
    """ 
    Display the homepage
    """
    current_site = get_current_site(request).domain

#    if current_site == "gracebreedlove.com": 
#        page = get_object_or_404(Page, slug="grace-breedlove-photography")
#        content = mark_safe(page.richtextpage.content)
#        context = { 'page' : page, 'content' : content  }
#        return render(request, "photo_index.html", context)

    if current_site == "solarpoweredyogi.com":
        settings.use_editable()
        blog_posts = BlogPost.objects.published(for_user=request.user)

        slider_posts = blog_posts[:4]
        section_posts = blog_posts[0:15]

        context = { "slider_posts" : slider_posts, "section_posts": section_posts }

        return render(request, "index.html", context)

    settings.use_editable()
    blog_posts = BlogPost.objects.published(for_user=request.user)

    slider_posts = blog_posts[:4]
    section_posts = blog_posts[0:15]

    context = { "slider_posts" : slider_posts, "section_posts": section_posts }

    return render(request, "index.html", context)
开发者ID:numon,项目名称:graces-site,代码行数:32,代码来源:views.py


示例3: sign_agreement

def sign_agreement(request):
    """Display the user agreement and allow the user to sign it."""
    settings.use_editable()

    form = AgreementForm()
    agreement = get_object_or_404(
        Agreement, version=settings.DOWNLOAD_AGREEMENT_VERSION)

    if request.method == "POST":
        form = AgreementForm(request.POST)
        if form.is_valid():
            ip = (request.META.get('HTTP_X_FORWARDED_FOR', '').split(',')[0]
                  or request.META.get('REMOTE_ADDR'))
            SignedAgreement.objects.create(
                user=request.user,
                ip=ip,
                agreement=agreement,
            )
            redirect_field_name = 'next'
            default_next = '/'
            next_page = request.POST.get(
                redirect_field_name, request.GET.get(redirect_field_name))
            next_page = next_page or default_next
            if not is_safe_url(url=next_page, host=request.get_host()):
                next_page = default_next
            if 'waiting_download' in request.session:
                request.session['ready_download'] = request.session[
                    'waiting_download']
                del request.session['waiting_download']
            return redirect(next_page)

    return render(request, 'protected_assets/download-agreement.html', {
        'form': form,
        'agreement': agreement,
    })
开发者ID:jgmize,项目名称:fxoss,代码行数:35,代码来源:views.py


示例4: blog_post_list

def blog_post_list(request, tag=None, year=None, month=None, username=None,
                   category=None, template="blog/blog_post_list.html"):
    """
    Display a list of blog posts that are filtered by tag, year, month,
    author or category. Custom templates are checked for using the name
    ``blog/blog_post_list_XXX.html`` where ``XXX`` is either the
    category slug or author's username if given.
    """
    settings.use_editable()
    templates = []
    blog_posts = BlogPost.objects.published(for_user=request.user)
    if tag is not None:
        tag = get_object_or_404(Keyword, slug=tag)
        blog_posts = blog_posts.filter(keywords__in=tag.assignments.all())
    if year is not None:
        blog_posts = blog_posts.filter(publish_date__year=year)
        if month is not None:
            blog_posts = blog_posts.filter(publish_date__month=month)
            month = month_name[int(month)]
    if category is not None:
        category = get_object_or_404(BlogCategory, slug=category)
        blog_posts = blog_posts.filter(categories=category)
        templates.append(u"blog/blog_post_list_%s.html" %
                          unicode(category.slug))
    author = None
    if username is not None:
        author = get_object_or_404(User, username=username)
        blog_posts = blog_posts.filter(user=author)
        templates.append(u"blog/blog_post_list_%s.html" % username)
    # Create dicts mapping blog post IDs to lists of categories and
    # keywords, and assign these to each blog post, to avoid querying
    # the database inside the template loop for posts.
    blog_posts = list(blog_posts.select_related("user"))
    categories = defaultdict(list)
    if blog_posts:
        ids = ",".join([str(p.id) for p in blog_posts])
        for cat in BlogCategory.objects.raw(
            "SELECT * FROM blog_blogcategory "
            "JOIN blog_blogpost_categories "
            "ON blog_blogcategory.id = blogcategory_id "
            "WHERE blogpost_id IN (%s)" % ids):
            categories[cat.blogpost_id].append(cat)
    keywords = defaultdict(list)
    blogpost_type = ContentType.objects.get(app_label="blog", model="blogpost")
    assigned = AssignedKeyword.objects.filter(blogpost__in=blog_posts,
                          content_type=blogpost_type).select_related("keyword")
    for a in assigned:
        keywords[a.object_pk].append(a.keyword)
    for i, post in enumerate(blog_posts):
        setattr(blog_posts[i], "category_list", categories[post.id])
        setattr(blog_posts[i], "keyword_list", keywords[post.id])
    blog_posts = paginate(blog_posts,
                          request.GET.get("page", 1),
                          settings.BLOG_POST_PER_PAGE,
                          settings.MAX_PAGING_LINKS)
    context = {"blog_page": blog_page(), "blog_posts": blog_posts,
               "year": year, "month": month, "tag": tag,
               "category": category, "author": author}
    templates.append(template)
    return render(request, templates, context)
开发者ID:n1k0,项目名称:mezzanine,代码行数:60,代码来源:views.py


示例5: send_order_email

def send_order_email(request, order):
    """
    Send order receipt email on successful order.
    """
    settings.use_editable()
    order_context = {"order": order, "request": request,
                     "order_items": order.items.all()}
    if order.has_reservables:
        order_context["has_reservables"] = True
    else:
        order_context["has_reservables"] = False
    order_context["hide_shipping"] = settings.SHOP_ALWAYS_SAME_BILLING_SHIPPING
    order_context.update(order.details_as_dict())
    try:
        get_template("shop/email/order_receipt.html")
    except TemplateDoesNotExist:
        receipt_template = "email/order_receipt"
    else:
        receipt_template = "shop/email/order_receipt"
        from warnings import warn
        warn("Shop email receipt templates have moved from "
             "templates/shop/email/ to templates/email/")
    send_mail_template(settings.SHOP_ORDER_EMAIL_SUBJECT,
                       receipt_template, settings.SHOP_ORDER_FROM_EMAIL,
                       order.billing_detail_email, context=order_context,
                       addr_bcc=settings.SHOP_ORDER_EMAIL_BCC or None)
开发者ID:jaywink,项目名称:cartridge-reservable,代码行数:26,代码来源:checkout.py


示例6: search

def search(request, template="search_results.html"):
    """
    Display search results. Takes an optional "contenttype" GET parameter
    in the form "app-name.ModelName" to limit search results to a single model.
    """
    settings.use_editable()
    query = request.GET.get("q", "")
    page = request.GET.get("page", 1)
    per_page = settings.SEARCH_PER_PAGE
    max_paging_links = settings.MAX_PAGING_LINKS
    try:
        search_model = get_model(*request.GET.get("type", "").split(".", 1))
        if not issubclass(search_model, Displayable):
            raise TypeError
    except TypeError:
        search_model = Displayable
        search_type = _("Everything")
    else:
        search_type = search_model._meta.verbose_name_plural.capitalize()
    results = search_model.objects.search(query, for_user=request.user)

    if 'location' and 'age' in request.session:
        if 'cart loaded' in request.session:
            stores = request.session['stores']

        else:
            avail_store_ids = request.session['store ids']

            if avail_store_ids:
                stores = Store.objects.filter(id__in=avail_store_ids)
            else:
                return HttpResponseRedirect('/shop/no-stores-yet')

        avail_prod_ids = []
        for p in stores:
            for k in results:
                if p == k.store:
                    avail_prod_ids.append(k.id)

        results = Product.objects.filter(id__in=avail_prod_ids)

        sort_options = [(slugify(option[0]), option[1])
                    for option in settings.SHOP_PRODUCT_SORT_OPTIONS]
        sort_by = request.GET.get("sort", sort_options[0][1])
        results = paginate(results.order_by(sort_by),
                        request.GET.get("page", 1),
                        settings.SHOP_PER_PAGE_CATEGORY,
                        settings.MAX_PAGING_LINKS)
        results.sort_by = sort_by

    else:
#        return render(request, template, {"have_loc": False})
	info(request, _("Enter your location to use the search"))
        return HttpResponseRedirect('/')

#    paginated = paginate(results, page, per_page, max_paging_links)
    paginated = results
    context = {"query": query, "results": paginated,
               "search_type": search_type, "have_loc": True}
    return render(request, template, context)
开发者ID:obsjames,项目名称:md-production-public,代码行数:60,代码来源:views.py


示例7: correios_billship_handler

def correios_billship_handler(request, order_form):
	"""
	Default billing/shipping handler - called when the first step in
	the checkout process with billing/shipping address fields is
	submitted. Implement your own and specify the path to import it
	from via the setting ``SHOP_HANDLER_BILLING_SHIPPING``.
	This function will typically contain any shipping calculation
	where the shipping amount can then be set using the function
	``cartridge.shop.utils.set_shipping``. The Cart object is also
	accessible via ``request.cart``
	"""
	logger.debug("integration.checkout.correios_billship_handler()")
	if not request.session.get("free_shipping"):
        	settings.use_editable()
        
		# http://www.correios.com.br/webservices/default.cfm
		# http://www.correios.com.br/webServices/PDF/SCPP_manual_implementacao_calculo_remoto_de_precos_e_prazos.pdf

		client = Client("http://ws.correios.com.br/calculador/CalcPrecoPrazo.asmx?wsdl")
	
		"""
			40010 = SEDEX
		"""
		origin_cep = settings.CEP_ORIGIN
		data = order_form.cleaned_data
		dest_cep = data["billing_detail_postcode"]

		logger.debug("cep de %s para %s" % (origin_cep,dest_cep) )
		# Propriedades fixas apenas para testar por enquanto
		result = client.service.CalcPreco("","",40010, origin_cep, dest_cep , "1.0",1, 50.0, 50.0, 50.0, 50.0, "N", 0 , "N")

		price = Decimal(result.Servicos[0][0].Valor.replace(",","."))
		logger.debug("preço %s" % price)

		set_shipping(request, _("SEDEX"), price)
开发者ID:brunobbbs,项目名称:cartridge-mezzanine-django-heroku,代码行数:35,代码来源:checkout.py


示例8: __init__

 def __init__(self, *args, **kwargs):
     super(SettingsForm, self).__init__(*args, **kwargs)
     # Create a form field for each editable setting's from its type.
     active_language = get_language()
     for name in sorted(registry.keys()):
         setting = registry[name]
         if setting["editable"]:
             codes = [active_language]
             if settings.USE_MODELTRANSLATION and setting["translatable"]:
                 codes = SortedDict(settings.LANGUAGES)
             field_class = FIELD_TYPES.get(setting["type"], forms.CharField)
             for code in codes:
                 try:
                     activate(code)
                 except:
                     pass
                 else:
                     # refresh settings cache for each language to properly
                     # handle initial values.
                     settings.use_editable()
                     kwargs = {
                         "label": setting["label"] + ":",
                         "required": setting["type"] in (int, float),
                         "initial": getattr(settings, name),
                         "help_text":
                             self.format_help(setting["description"]),
                     }
                     if setting["choices"]:
                         field_class = forms.ChoiceField
                         kwargs["choices"] = setting["choices"]
                     field_instance = field_class(**kwargs)
                     self.fields[name + "/" + code] = field_instance
                     css_class = field_class.__name__.lower()
                     field_instance.widget.attrs["class"] = css_class
     activate(active_language)
开发者ID:aaronkyle,项目名称:mezzanine,代码行数:35,代码来源:forms.py


示例9: test_settings

 def test_settings(self):
     """
     Test that an editable setting can be overridden with a DB
     value and that the data type is preserved when the value is
     returned back out of the DB. Also checks to ensure no
     unsupported types are defined for editable settings.
     """
     # Find an editable setting for each supported type.
     names_by_type = {}
     for setting in registry.values():
         if setting["editable"] and setting["type"] not in names_by_type:
             names_by_type[setting["type"]] = setting["name"]
     # Create a modified value for each setting and save it.
     values_by_name = {}
     for (setting_type, setting_name) in names_by_type.items():
         setting_value = registry[setting_name]["default"]
         if setting_type in (int, float):
             setting_value += 1
         elif setting_type is bool:
             setting_value = not setting_value
         elif setting_type is str:
             setting_value += "test"
         elif setting_type is bytes:
             setting_value += b"test"
         else:
             setting = "%s: %s" % (setting_name, setting_type)
             self.fail("Unsupported setting type for %s" % setting)
         values_by_name[setting_name] = setting_value
         Setting.objects.create(name=setting_name, value=setting_value)
     # Load the settings and make sure the DB values have persisted.
     settings.use_editable()
     for (name, value) in values_by_name.items():
         self.assertEqual(getattr(settings, name), value)
开发者ID:vdt,项目名称:mezzanine,代码行数:33,代码来源:tests.py


示例10: send_order_email

def send_order_email(request, order):
    """
    Send order receipt email on successful order.
    """
    settings.use_editable()

    address = request.session['address']

    store = request.session['stores']
    store_name = store[0].name
    store_address = store[0].address
    store_contact = store[0].contact_number

    order_context = {"order": order, "request": request,
                     "order_items": order.items.all(), "address": address,
                     "store_name": store_name, "store_address": store_address,
                     "store_contact": store_contact}
    order_context.update(order.details_as_dict())
    try:
        get_template("shop/email/order_receipt.html")
    except TemplateDoesNotExist:
        receipt_template = "email/order_receipt"
    else:
        receipt_template = "shop/email/order_receipt"
        from warnings import warn
        warn("Shop email receipt templates have moved from "
             "templates/shop/email/ to templates/email/")
    send_mail_template(settings.SHOP_ORDER_EMAIL_SUBJECT,
        receipt_template, settings.SHOP_ORDER_FROM_EMAIL,
        order.billing_detail_email, context=order_context,
        fail_silently=settings.DEBUG)
开发者ID:obsjames,项目名称:md-production-public,代码行数:31,代码来源:checkout.py


示例11: search

def search(request, template="search_results.html", extra_context=None):
    """
    Display search results. Takes an optional "contenttype" GET parameter
    in the form "app-name.ModelName" to limit search results to a single model.
    """
    settings.use_editable()
    query = request.GET.get("q", "")
    page = request.GET.get("page", 1)
    per_page = settings.SEARCH_PER_PAGE
    max_paging_links = settings.MAX_PAGING_LINKS
    try:
        parts = request.GET.get("type", "").split(".", 1)
        search_model = apps.get_model(*parts)
        search_model.objects.search  # Attribute check
    except (ValueError, TypeError, LookupError, AttributeError):
        search_model = Displayable
        search_type = _("Everything")
    else:
        search_type = search_model._meta.verbose_name_plural.capitalize()
    results = search_model.objects.search(query, for_user=request.user)
    paginated = paginate(results, page, per_page, max_paging_links)
    context = {"query": query, "results": paginated,
               "search_type": search_type}
    context.update(extra_context or {})
    return render(request, template, context)
开发者ID:aagarg,项目名称:mezzanine,代码行数:25,代码来源:views.py


示例12: send_store_order_email

def send_store_order_email(request, order):
    """
    Send order email to store on successful order.
    """
    settings.use_editable()

    address = request.session['address']
    store = request.session['stores']
    store_name = store[0].name
    store_email = [store[0].email]

    store_name_no_spaces = store_name.replace(" ", "")

    order_context = {"order": order, "request": request,
                     "order_items": order.items.all(), "address": address,
                     "store_name": store_name, "store_name_no_spaces": store_name_no_spaces}
    order_context.update(order.details_as_dict())
    try:
        get_template("shop/email/store_order.html")
    except TemplateDoesNotExist:
        receipt_template = "email/store_order"
    else:
        receipt_template = "shop/email/store_order"
        from warnings import warn
        warn("Shop email receipt templates have moved from "
             "templates/shop/email/ to templates/email/")
    send_mail_template(settings.SHOP_STORE_ORDER_EMAIL_SUBJECT,
        receipt_template, settings.SHOP_ORDER_FROM_EMAIL,
        store_email, context=order_context,
        fail_silently=settings.DEBUG)
开发者ID:obsjames,项目名称:md-production-public,代码行数:30,代码来源:checkout.py


示例13: get_app_setting

def get_app_setting(app_label, setting):
    settings.use_editable()
    setting_root_slug_key = "{0}_{1}".format(app_label.upper(), setting.upper())
    slug = getattr(settings, setting_root_slug_key, None)
    if not slug:
        raise ImproperlyConfigured("The {0} setting must not be empty.".format(setting_root_slug_key))
    return slug
开发者ID:simodalla,项目名称:mezzanine_nowait,代码行数:7,代码来源:utils.py


示例14: article_list

def article_list(request, tag=None, category=None, template="article/article_list.html"):
    """
    Display a list of blog posts that are filtered by tag, year, month,
    author or category. Custom templates are checked for using the name
    ``blog/blog_post_list_XXX.html`` where ``XXX`` is either the
    category slug or author's username if given.
    """
    settings.use_editable()
    templates = []
    articles = Article.objects.published(for_user=request.user)
    if tag is not None:
        tag = get_object_or_404(Keyword, slug=tag)
        articles = articles.filter(keywords__in=tag.assignments.all())
    if category is not None:
        category = get_object_or_404(BlogCategory, slug=category)
        articles = articles.filter(categories=category)
        # templates.append(u"article/blog_post_list_%s.html" %
        #                  str(category.slug))
    author = None
    prefetch = ("categories", "keywords__keyword")
    articles = articles.select_related("user").prefetch_related(*prefetch)
    articles = paginate(articles, request.GET.get("page", 1),
                          settings.BLOG_POST_PER_PAGE,
                          settings.MAX_PAGING_LINKS)
    context = {"articles": articles,
               "tag": tag, "category": category, "author": author}
    templates.append(template)
    return render(request, templates, context)
开发者ID:mihirk,项目名称:vikalp,代码行数:28,代码来源:views.py


示例15: blog_post_list

def blog_post_list(request, tag=None, year=None, month=None, username=None,
    category=None, template="blog/blog_post_list.html"):
    """
    Display a list of blog posts.
    """
    settings.use_editable()
    blog_posts = BlogPost.objects.published(for_user=request.user)
    if tag is not None:
        tag = get_object_or_404(Keyword, slug=tag)
        blog_posts = blog_posts.filter(keywords=tag)
    if year is not None:
        blog_posts = blog_posts.filter(publish_date__year=year)
        if month is not None:
            blog_posts = blog_posts.filter(publish_date__month=month)
            month = month_name[int(month)]
    if category is not None:
        category = get_object_or_404(BlogCategory, slug=category)
        blog_posts = blog_posts.filter(category=category)
    user = None
    if username is not None:
        user = get_object_or_404(User, username=username)
        blog_posts = blog_posts.filter(user=user)
    blog_posts = paginate(blog_posts, request.GET.get("page", 1),
        settings.BLOG_POST_PER_PAGE,
        settings.BLOG_POST_MAX_PAGING_LINKS)
    context = {"blog_posts": blog_posts, "year": year, "month": month, 
        "tag": tag, "category": category, "user": user, 
        "use_disqus": bool(settings.COMMENTS_DISQUS_SHORTNAME), 
        "blog_page": blog_page()}
    return render_to_response(template, context, RequestContext(request))
开发者ID:alyoung,项目名称:mezzanine,代码行数:30,代码来源:views.py


示例16: get_redirect_url

 def get_redirect_url(self, *args, **kwargs):
     code = self.request.GET.get("code")
     settings.use_editable()
     site = Site.objects.get_current()
     
     conf = {
         "redirect_uri": "http://{0}{1}".format(site.domain, reverse('instagram_oauth')),
         "client_id": settings.INSTAGRAM_CLIENT_ID,
         "client_secret": settings.INSTAGRAM_CLIENT_SECRET,
     }
     unauthorized_api = InstagramAPI(**conf)
     logger.debug(unauthorized_api)
     access_token = unauthorized_api.exchange_code_for_access_token(code)
     try:
         instagram = Instagram.objects.all()[0]
         instagram.access_token = access_token[0]
         instagram.user_id = int(access_token[1]['id'])
         instagram.full_name = access_token[1]['full_name']
         instagram.username = access_token[1]['username']
         instagram.save()
     except IndexError:
         Instagram.objects.create(access_token=access_token[0],
                                  user_id=int(access_token[1]['id']),
                                  full_name=access_token[1]['full_name'],
                                  username=access_token[1]['username'])
     return "/admin/"
开发者ID:instag,项目名称:instag,代码行数:26,代码来源:views.py


示例17: save

    def save(self, *args, **kwargs):
        kwargs["commit"] = False
        user = super(AddUserForm, self).save(*args, **kwargs)
        try:
            self.cleaned_data["username"]
        except KeyError:
            if not self.instance.username:
                username = "%(first_name)s %(last_name)s" % self.cleaned_data
                if not username.strip():
                    username = self.cleaned_data["email"].split("@")[0]
                qs = User.objects.exclude(id=self.instance.id)  # @UndefinedVariable PyDev limitation ("exclude")
                user.username = unique_slug(qs, "username", slugify(username))
        password = self.cleaned_data.get("password1")
        if password:
            user.set_password(password)
        user.save()

        # Save profile model.
        ProfileFieldsForm(self.data, self.files, instance=user.profile).save()
        settings.use_editable()
        #if (settings.ACCOUNTS_VERIFICATION_REQUIRED or
        #    settings.ACCOUNTS_APPROVAL_REQUIRED):
        #    user.is_active = False
        #    user.save()
        return user
开发者ID:hderaps,项目名称:bccf,代码行数:25,代码来源:forms.py


示例18: search

def search(request, template="search_results.html"):
    """
    Display search results. Takes an optional "contenttype" GET parameter
    in the form "app-name.ModelName" to limit search results to a single model.
    """
    settings.use_editable()
    query = request.GET.get("q", "")
    # page = request.GET.get("page", 1)
    page_template = "search_results_page.html"
    # per_page = settings.SEARCH_PER_PAGE
    # max_paging_links = settings.MAX_PAGING_LINKS
    try:
        search_model = get_model(*request.GET.get("type", "").split(".", 1))
        if not issubclass(search_model, Displayable):
            raise TypeError
    except TypeError:
        search_model = Displayable
        search_type = _("Everything")
    else:
        search_type = search_model._meta.verbose_name_plural.capitalize()
    results = search_model.objects.search(query, for_user=request.user)
    if request.is_ajax():
        template = page_template
    article_map = get_article_map(True)
    context = {
        "query": query,
        "results": results,
        "search_type": search_type,
        "page_template": page_template,
        "form": MapFormForSideBar(initial={"map": article_map}),
        "latest_commented_articles": article_service.get_latest_unique_commented_on_articles(),
    }
    return render(request, template, context, context_instance=RequestContext(request))
开发者ID:vikalpindia,项目名称:vikalp,代码行数:33,代码来源:views.py


示例19: settings

def settings(request=None):
    """
    Add the settings object to the template context.
    """
    from mezzanine.conf import settings
    settings_dict = None
    cache_settings = request and cache_installed()
    if cache_settings:
        cache_key = cache_key_prefix(request) + "context-settings"
        settings_dict = cache_get(cache_key)
    if not settings_dict:
        settings.use_editable()
        settings_dict = TemplateSettings()
        for k in settings.TEMPLATE_ACCESSIBLE_SETTINGS:
            settings_dict[k] = getattr(settings, k, "")
        for k in DEPRECATED:
            settings_dict[k] = getattr(settings, k, DEPRECATED)
        if cache_settings:
            cache_set(cache_key, settings_dict)
    # This is basically the same as the old ADMIN_MEDIA_PREFIX setting,
    # we just use it in a few spots in the admin to optionally load a
    # file from either grappelli or Django admin if grappelli isn't
    # installed. We don't call it ADMIN_MEDIA_PREFIX in order to avoid
    # any confusion.
    if settings.GRAPPELLI_INSTALLED:
        settings_dict["MEZZANINE_ADMIN_PREFIX"] = "grappelli/"
    else:
        settings_dict["MEZZANINE_ADMIN_PREFIX"] = "admin/"
    return {"settings": settings_dict}
开发者ID:AdnanHodzic,项目名称:mezzanine,代码行数:29,代码来源:context_processors.py


示例20: process_request

 def process_request(self, request):
     settings.use_editable()
     force_host = settings.SSL_FORCE_HOST
     response = None
     if force_host and request.get_host().split(":")[0] != force_host:
         url = "http://%s%s" % (force_host, request.get_full_path())
         response = HttpResponsePermanentRedirect(url)
     elif settings.SSL_ENABLED and not settings.DEV_SERVER:
         url = "%s%s" % (request.get_host(), request.get_full_path())
         if request.path.startswith(settings.SSL_FORCE_URL_PREFIXES):
             if not request.is_secure():
                 response = HttpResponseRedirect("https://%s" % url)
         elif request.is_secure() and settings.SSL_FORCED_PREFIXES_ONLY:
             response = HttpResponseRedirect("http://%s" % url)
     if response and request.method == "POST":
         if resolve(request.get_full_path()).url_name == "fb_do_upload":
             # The handler for the flash file uploader in filebrowser
             # doesn't have access to the http headers Django will use
             # to determine whether the request is secure or not, so
             # in this case we don't attempt a redirect - note that
             # when /admin is restricted to SSL using Mezzanine's SSL
             # setup, the flash uploader will post over SSL, so
             # someone would need to explictly go out of their way to
             # trigger this.
             return
         # Tell the client they need to re-POST.
         response.status_code = 307
     return response
开发者ID:Memode,项目名称:mezzanine,代码行数:28,代码来源:middleware.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python admin.DisplayableAdmin类代码示例发布时间:2022-05-27
下一篇:
Python conf.register_setting函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap