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


Python settings.use_editable函数代码示例

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


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


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