本文整理汇总了Python中muecke.caching.utils.muecke_get_object_or_404函数的典型用法代码示例。如果您正苦于以下问题:Python muecke_get_object_or_404函数的具体用法?Python muecke_get_object_or_404怎么用?Python muecke_get_object_or_404使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了muecke_get_object_or_404函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: delete_cart_item
def delete_cart_item(request, cart_item_id):
"""
Deletes the cart item with the given id.
"""
muecke_get_object_or_404(CartItem, pk=cart_item_id).delete()
cart = cart_utils.get_cart(request)
cart_changed.send(cart, request=request)
return HttpResponse(cart_inline(request))
开发者ID:zenith0,项目名称:django-muecke,代码行数:10,代码来源:views.py
示例2: as_html
def as_html(self, request, position):
"""Renders the criterion as html in order to be displayed within several
forms.
"""
shop = muecke_get_object_or_404(Shop, pk=1)
countries = []
for country in shop.shipping_countries.all():
if country in self.countries.all():
selected = True
else:
selected = False
countries.append({
"id": country.id,
"name": country.name,
"selected": selected,
})
return render_to_string("manage/criteria/country_criterion.html", RequestContext(request, {
"id": "%s%s" % (self.content_type, self.id),
"operator": self.operator,
"value": self.value,
"position": position,
"countries": countries,
}))
开发者ID:zenith0,项目名称:django-muecke,代码行数:26,代码来源:criteria.py
示例3: category_view
def category_view(request, category_id, template_name="manage/category/view.html"):
"""Displays the view data for the category with passed category id.
This is used as a part of the whole category form.
"""
category = muecke_get_object_or_404(Category, pk=category_id)
if request.method == "POST":
form = ViewForm(instance=category, data=request.POST)
if form.is_valid():
form.save()
message = _(u"View data has been saved.")
else:
message = _(u"Please correct the indicated errors.")
else:
form = ViewForm(instance=category)
view_html = render_to_string(template_name, RequestContext(request, {
"category": category,
"form": form,
}))
if request.is_ajax():
html = [["#view", view_html]]
return HttpResponse(simplejson.dumps({
"html": html,
"message": message,
}, cls=LazyEncoder))
else:
return view_html
开发者ID:zenith0,项目名称:django-muecke,代码行数:30,代码来源:view.py
示例4: get_parent_for_portlets
def get_parent_for_portlets(self):
"""Returns the parent for parents.
"""
if self.id == 1:
return get_default_shop()
else:
return muecke_get_object_or_404(Page, pk=1)
开发者ID:zenith0,项目名称:django-muecke,代码行数:7,代码来源:models.py
示例5: add_accessory_to_cart
def add_accessory_to_cart(request, product_id, quantity=1):
"""
Adds the product with passed product_id as an accessory to the cart and
updates the added-to-cart view.
"""
try:
quantity = float(quantity)
except TypeError:
quantity = 1
product = muecke_get_object_or_404(Product, pk=product_id)
session_cart_items = request.session.get("cart_items", [])
cart = cart_utils.get_cart(request)
cart_item = cart.add(product=product, amount=quantity)
# Update session
if cart_item not in session_cart_items:
session_cart_items.append(cart_item)
else:
for session_cart_item in session_cart_items:
if cart_item.product == session_cart_item.product:
session_cart_item.amount += quantity
request.session["cart_items"] = session_cart_items
cart_changed.send(cart, request=request)
return HttpResponse(added_to_cart_items(request))
开发者ID:zenith0,项目名称:django-muecke,代码行数:28,代码来源:views.py
示例6: get
def get(self, request, id):
""" Handle GET request
"""
obj = muecke_get_object_or_404(self.model_klass, pk=id)
form = self.form_klass(instance=obj)
return self.render_to_response(form)
开发者ID:zenith0,项目名称:django-muecke,代码行数:7,代码来源:views.py
示例7: edit_seo
def edit_seo(request, category_id, template_name="manage/category/seo.html"):
"""Displays an edit form for category seo fields and saves the entered
values.
If it is called by an ajax request it returns the result and a status
message as json.
This is used as a part of the whole category form.
"""
category = muecke_get_object_or_404(Category, pk=category_id)
if request.method == "POST":
form = SEOForm(instance=category, data=request.POST)
if form.is_valid():
form.save()
message = _(u"SEO data has been saved.")
else:
message = _(u"Please correct the indicated errors.")
else:
form = SEOForm(instance=category)
seo_html = render_to_string(template_name, RequestContext(request, {
"category": category,
"form": form,
}))
if request.is_ajax():
return HttpResponse(simplejson.dumps({
"seo": seo_html,
"message": message,
}, cls=LazyEncoder))
else:
return seo_html
开发者ID:zenith0,项目名称:django-muecke,代码行数:33,代码来源:seo.py
示例8: product_form_dispatcher
def product_form_dispatcher(request):
"""Dispatches to the added-to-cart view or to the selected variant.
This is needed as the product form can have several submit buttons:
- The add-to-cart button
- The switch to the selected variant button (only in the case the
variants of of the product are displayed as select box. This may change
in future, when the switch may made with an ajax request.)
"""
if request.REQUEST.get("add-to-cart") is not None:
return add_to_cart(request)
else:
product_id = request.POST.get("product_id")
product = muecke_get_object_or_404(Product, pk=product_id)
options = muecke_utils.parse_properties(request)
variant = product.get_variant(options)
if variant is None:
variant = product.get_default_variant()
return muecke.core.utils.set_message_cookie(
variant.get_absolute_url(),
msg=_(u"The choosen combination of properties is not deliverable.")
)
return HttpResponseRedirect(variant.get_absolute_url())
开发者ID:zenith0,项目名称:django-muecke,代码行数:27,代码来源:views.py
示例9: cart_inline
def cart_inline(request, cart_id, template_name="manage/cart/cart_inline.html"):
"""Displays cart with provided cart id.
"""
cart = muecke_get_object_or_404(Cart, pk=cart_id)
total = 0
for item in cart.get_items():
total += item.get_price_gross(request)
try:
if cart.user:
customer = Customer.objects.get(user=cart.user)
else:
customer = Customer.objects.get(session=cart.session)
except Customer.DoesNotExist:
customer = None
cart_filters = request.session.get("cart-filters", {})
return render_to_string(template_name, RequestContext(request, {
"cart": cart,
"customer": customer,
"total": total,
"start": cart_filters.get("start", ""),
"end": cart_filters.get("end", ""),
}))
开发者ID:zenith0,项目名称:django-muecke,代码行数:25,代码来源:carts.py
示例10: customer_inline
def customer_inline(request, customer_id, template_name="manage/customer/customer_inline.html"):
"""Displays customer with provided customer id.
"""
customer_filters = request.session.get("customer-filters", {})
customer = muecke_get_object_or_404(Customer, pk=customer_id)
orders = Order.objects.filter(session=customer.session)
try:
cart = Cart.objects.get(session=customer.session)
cart_price = cart.get_price_gross(request)
except Cart.DoesNotExist:
cart = None
cart_price = None
else:
# Shipping
selected_shipping_method = muecke.shipping.utils.get_selected_shipping_method(request)
shipping_costs = muecke.shipping.utils.get_shipping_costs(request, selected_shipping_method)
# Payment
selected_payment_method = muecke.payment.utils.get_selected_payment_method(request)
payment_costs = muecke.payment.utils.get_payment_costs(request, selected_payment_method)
cart_price = cart.get_price_gross(request) + shipping_costs["price"] + payment_costs["price"]
return render_to_string(template_name, RequestContext(request, {
"customer": customer,
"orders": orders,
"cart": cart,
"cart_price": cart_price,
}))
开发者ID:zenith0,项目名称:django-muecke,代码行数:30,代码来源:customer.py
示例11: manage_product
def manage_product(request, product_id, template_name="manage/product/product.html"):
"""
Displays the whole manage/edit form for the product with the passed id.
"""
product = muecke_get_object_or_404(Product, pk=product_id)
products = _get_filtered_products_for_product_view(request)
paginator = Paginator(products, 25)
temp = product.parent if product.is_variant() else product
page = get_current_page(request, products, temp, 25)
try:
page = paginator.page(page)
except EmptyPage:
page = paginator.page(1)
return render_to_response(template_name, RequestContext(request, {
"product": product,
"product_filters": product_filters_inline(request, page, paginator, product_id),
"pages_inline": pages_inline(request, page, paginator, product_id),
"product_data": product_data_form(request, product_id),
"images": manage_images(request, product_id, as_string=True),
"attachments": manage_attachments(request, product_id, as_string=True),
"selectable_products": selectable_products_inline(request, page, paginator, product.id),
"seo": manage_seo(request, product_id),
"stock": stock(request, product_id),
"portlets": portlets_inline(request, product),
"properties": manage_properties(request, product_id),
"form": ProductSubTypeForm(instance=product),
"name_filter_value": request.session.get("product_filters", {}).get("product_name", ""),
}))
开发者ID:zenith0,项目名称:django-muecke,代码行数:30,代码来源:product.py
示例12: manage_categories
def manage_categories(request, product_id, template_name="manage/product/categories.html"):
"""Displays the manage category view.
"""
product = muecke_get_object_or_404(Product, pk=product_id)
product_category_ids = [p.id for p in product.get_categories()]
categories = []
for category in Category.objects.filter(parent=None):
children = children_categories(request, category, product_category_ids)
categories.append({
"id": category.id,
"slug": category.slug,
"name": category.name,
"url": category.get_absolute_url(),
"checked": category.id in product_category_ids,
"children": children,
})
result = render_to_string(template_name, RequestContext(request, {
"product": product,
"categories": categories
}))
return HttpResponse(result)
开发者ID:zenith0,项目名称:django-muecke,代码行数:26,代码来源:categories.py
示例13: file
def file(request, language=None, id=None):
"""Delivers files to the browser.
"""
file = muecke_get_object_or_404(File, pk=id)
response = HttpResponse(file.file, mimetype='application/binary')
response['Content-Disposition'] = 'attachment; filename=%s' % file.title
return response
开发者ID:zenith0,项目名称:django-muecke,代码行数:8,代码来源:views.py
示例14: popup_view
def popup_view(request, slug, template_name="muecke/page/popup.html"):
"""Displays page with passed slug
"""
page = muecke_get_object_or_404(Page, slug=slug)
return render_to_response(template_name, RequestContext(request, {
"page": page
}))
开发者ID:zenith0,项目名称:django-muecke,代码行数:8,代码来源:views.py
示例15: delete_product
def delete_product(request, product_id):
"""Deletes product with passed id.
"""
product = muecke_get_object_or_404(Product, pk=product_id)
product.delete()
url = reverse("muecke_manage_product_dispatcher")
return HttpResponseRedirect(url)
开发者ID:zenith0,项目名称:django-muecke,代码行数:8,代码来源:product.py
示例16: shop_view
def shop_view(request, template_name="muecke/shop/shop.html"):
"""Displays the shop.
"""
shop = muecke_get_object_or_404(Shop, pk=1)
return render_to_response(template_name, RequestContext(request, {
"shop": shop
}))
开发者ID:zenith0,项目名称:django-muecke,代码行数:8,代码来源:views.py
示例17: page_view_by_id
def page_view_by_id(request, id, template_name="muecke/page/page.html"):
"""Displays page with passed id.
"""
if id == 1:
raise Http404()
page = muecke_get_object_or_404(Page, pk=id)
url = reverse("muecke_page_view", kwargs={"slug": page.slug})
return HttpResponseRedirect(url)
开发者ID:zenith0,项目名称:django-muecke,代码行数:9,代码来源:views.py
示例18: delete_category
def delete_category(request, id):
"""Deletes category with given id.
"""
category = muecke_get_object_or_404(Category, pk=id)
parent = category.parent
category.delete()
manage_utils.update_category_positions(parent)
url = reverse("muecke_manage_categories")
return HttpResponseRedirect(url)
开发者ID:zenith0,项目名称:django-muecke,代码行数:10,代码来源:category.py
示例19: customer_filters_inline
def customer_filters_inline(request, customer_id, template_name="manage/customer/customer_filters_inline.html"):
"""Renders the filters section of the customer view.
"""
customer_filters = request.session.get("customer-filters", {})
customer = muecke_get_object_or_404(Customer, pk=customer_id)
return render_to_string(template_name, RequestContext(request, {
"customer": customer,
"name": customer_filters.get("name", ""),
}))
开发者ID:zenith0,项目名称:django-muecke,代码行数:10,代码来源:customer.py
示例20: send_order
def send_order(request, order_id):
"""Sends order with passed order id to the customer of this order.
"""
order = muecke_get_object_or_404(Order, pk=order_id)
mail_utils.send_order_received_mail(order)
return muecke.core.utils.set_message_cookie(
url=reverse("muecke_manage_order", kwargs={"order_id": order.id}),
msg=_(u"Order has been sent."),
)
开发者ID:zenith0,项目名称:django-muecke,代码行数:10,代码来源:orders.py
注:本文中的muecke.caching.utils.muecke_get_object_or_404函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论