From: Guillaume Pellerin Date: Fri, 23 Sep 2016 15:11:46 +0000 (+0200) Subject: Init shop templates, cleanup X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f153b0d6ccfa67992e8b5858d8f97ef836a4a41f;p=mezzo.git Init shop templates, cleanup --- diff --git a/app/organization/shop/urls.py b/app/organization/shop/urls.py index 524bc486..6164c0bb 100644 --- a/app/organization/shop/urls.py +++ b/app/organization/shop/urls.py @@ -11,5 +11,4 @@ from organization.shop.views import * urlpatterns = [ url("^shop/", include("cartridge.shop.urls")), - url("^product/(?P.*)/$", ProductDetailView.as_view(), name='shop_product'), ] diff --git a/app/organization/shop/views.py b/app/organization/shop/views.py index d338301c..2372cb29 100644 --- a/app/organization/shop/views.py +++ b/app/organization/shop/views.py @@ -2,21 +2,3 @@ from django.shortcuts import render from organization.projects.models import * from organization.core.views import * - - -# class ProjectListView(ListView): -# -# model = Project -# template_name='projects/project_list.html' -# -# -# class ProjectDetailView(SlugMixin, DetailView): -# -# model = Project -# template_name='projects/project_detail.html' -# context_object_name = 'project' - - -class ProductDetailView(SlugMixin, DetailView): - - pass diff --git a/app/settings.py b/app/settings.py index cf8a7d31..c8373614 100644 --- a/app/settings.py +++ b/app/settings.py @@ -221,12 +221,12 @@ INSTALLED_APPS = [ # "mezzanine.galleries", "mezzanine.twitter", "mezzanine.accounts", + "cartridge.shop", # "mezzanine.mobile", # "eve", 'djangobower', "meta", "mezzanine_agenda", - "cartridge.shop", # "orderable", "organization.core", "organization.media", diff --git a/app/templates/shop/base.html b/app/templates/shop/base.html new file mode 100644 index 00000000..94d9808c --- /dev/null +++ b/app/templates/shop/base.html @@ -0,0 +1 @@ +{% extends "base.html" %} diff --git a/app/templates/shop/billing_shipping.html b/app/templates/shop/billing_shipping.html new file mode 100644 index 00000000..c0b54644 --- /dev/null +++ b/app/templates/shop/billing_shipping.html @@ -0,0 +1,49 @@ +{% extends "shop/checkout.html" %} +{% load staticfiles i18n mezzanine_tags %} + +{% block extra_head %} +{{ block.super }} + +{% endblock %} + +{% block fields %} +{% if request.cart.has_items %} +{% if not request.user.is_authenticated %} +{% ifinstalled mezzanine.accounts %} +

+{% url "login" as login_url %} +{% url "signup" as signup_url %} +{% with request.path as next %} +{% blocktrans %} +If you have an existing account or would like to create one, please +log in or +sign up. +{% endblocktrans %} +{% endwith %} +

+{% endifinstalled %} +{% endif %} + +{% errors_for form %} + +
+ {% trans "Billing Details" %} + {% fields_for form.billing_detail_fields %} +
+ +
+ {% trans "Delivery Details" %} + {% fields_for form.same_billing_shipping_field %} +
{% fields_for form.shipping_detail_fields %}
+ {% fields_for form.additional_instructions_field %} + {% fields_for form.remember_field %} +
+ +{% if not settings.SHOP_CHECKOUT_STEPS_SPLIT and settings.SHOP_PAYMENT_STEP_ENABLED %} +{% include "shop/includes/payment_fields.html" %} +{% endif %} + +{% fields_for form.other_fields %} + +{% endif %} +{% endblock %} diff --git a/app/templates/shop/cart.html b/app/templates/shop/cart.html new file mode 100644 index 00000000..2a817437 --- /dev/null +++ b/app/templates/shop/cart.html @@ -0,0 +1,113 @@ +{% extends "shop/base.html" %} +{% load mezzanine_tags shop_tags i18n %} + +{% block meta_title %}{% trans "Your Cart" %}{% endblock %} +{% block title %}{% trans "Your Cart" %}{% endblock %} +{% block body_id %}cart{% endblock %} + +{% block breadcrumb_menu %} +{{ block.super }} +
  • {% trans "Your Cart" %}
  • +{% endblock %} + +{% block main %} +{% if cart_formset.forms %} +
    +{% csrf_token %} +{% if cart_formset.errors %} +{% for error in cart_formset.errors %} +{% if error.values.0 %}{{ error.values.0 }}{% endif %} +{% endfor %} +{% endif %} +{{ cart_formset.management_form }} + + + + + + + + + + + + {% for form in cart_formset.forms %} + {% with form.instance as item %} + + + + + + + + + {% endwith %} + {% endfor %} + + + + + +
    {% trans "Item" %}{% trans "Unit Price" %}{% trans "Qty" %}{% trans "Price" %}{% trans "Remove?" %}
    + {{ form.id }} + {% if item.image %} + + {{ item.description }} + + {% endif %} + + {{ item.description }} + {{ item.unit_price|currency }}{{ form.quantity }}{{ item.total_price|currency }}{{ form.DELETE }}
    {% order_totals %} 
    + + +
    + +{% if discount_form %} +
    + {% fields_for discount_form %} + +
    +{% endif %} + +{% if settings.SHOP_USE_UPSELL_PRODUCTS %} +{% with request.cart.upsell_products as upsell_products %} +{% if upsell_products %} +

    {% trans "You may also like:" %}

    + +{% endif %} +{% endwith %} +{% endif %} + +{% else %} +

    {% trans "Your Cart is empty." %}

    +{% endif %} +{% endblock %} diff --git a/app/templates/shop/checkout.html b/app/templates/shop/checkout.html new file mode 100644 index 00000000..554c6016 --- /dev/null +++ b/app/templates/shop/checkout.html @@ -0,0 +1,83 @@ +{% extends "shop/base.html" %} +{% load shop_tags mezzanine_tags i18n %} + +{% block meta_title %}{% trans "Checkout" %} - {{ step_title }}{% endblock %} +{% block title %}{% trans "Checkout" %} - {% trans "Step" %} {{ step }} {% trans "of" %} {{ steps|length }}{% endblock %} +{% block body_id %}checkout{% endblock %} + +{% block extra_head %} + +{% endblock %} + +{% block breadcrumb_menu %} +{% for step in steps %} +
  • + {% if step.title == step_title %} + {{ step.title }} + {% else %} + {{ step.title }} + {% endif %} +
  • +{% endfor %} +
  • {% trans "Complete" %}
  • +{% endblock %} + +{% block main %} + +{% block before-form %}{% endblock %} +
    +
    + {% csrf_token %} + + {% block fields %}{% endblock %} + + {% block nav-buttons %} + {% if request.cart.has_items %} +
    + + {% if not CHECKOUT_STEP_FIRST %} + + {% endif %} +
    + {% else %} +

    {% trans "Your cart is empty." %}

    +

    {% trans "This may be due to your session timing out after a period of inactivity." %}

    +

    {% trans "We apologize for the inconvenience." %}

    +
    +

    {% trans "Continue Shopping" %}

    + {% endif %} + {% endblock %} + +
    + +{% if request.cart.has_items %} +
    +
    +
    +
      + {% for item in request.cart %} +
    • + {% if item.image %} + {{ item.description }} + {% endif %} +
      + {{ item.quantity }} x {{ item.description }} + {{ item.total_price|currency }} +
      +
    • + {% endfor %} +
    + {% order_totals %} +
    + {% trans "Edit Cart" %} +
    +
    +
    +{% endif %} + +{% block after-form %}{% endblock %} +
    +{% endblock %} diff --git a/app/templates/shop/complete.html b/app/templates/shop/complete.html new file mode 100644 index 00000000..0403cfd7 --- /dev/null +++ b/app/templates/shop/complete.html @@ -0,0 +1,75 @@ +{% extends "shop/base.html" %} +{% load i18n %} + +{% block body_id %}complete{% endblock %} + +{% block meta_title %}{% trans "Order Complete" %}{% endblock %} + +{% block footer_js %} +{{ block.super }} +{% if settings.GOOGLE_ANALYTICS_ID and not request.user.is_staff %} + +{% endif %} +{% endblock %} + +{% block title %}{% trans "Order Complete" %}{% endblock %} + +{% block breadcrumb_menu %} +{% for step in steps %} +
  • {{ step.title }}
  • +{% endfor %} +
  • {% trans "Complete" %}
  • +{% endblock %} + + +{% block main %} +

    {% trans "Thank you for shopping with us, your order is complete." %}

    +

    {% trans "We've sent you a receipt via email." %}

    +

    {% trans "You can also view your invoice using one of the links below." %}

    +
    +
    + {% csrf_token %} + {% if has_pdf %} + {% trans "Download PDF invoice" %} + {% endif %} + {% trans "View invoice in your browser" %} + +
    +{% endblock %} diff --git a/app/templates/shop/confirmation.html b/app/templates/shop/confirmation.html new file mode 100644 index 00000000..b87ee607 --- /dev/null +++ b/app/templates/shop/confirmation.html @@ -0,0 +1,80 @@ +{% extends "shop/checkout.html" %} +{% load i18n shop_tags %} + +{% block fields %} +{% if request.cart.has_items %} + +
    +
    +
    +

    {% trans "Billing Details" %}

    +
      + + {% for field, value in form.billing_detail_fields.values %} +
    • {{ value }}
    • + {% endfor %} + +
    +
    +
    +
    + +
    +
    +
    +

    {% trans "Shipping Details" %}

    +
      + + {% for field, value in form.shipping_detail_fields.values %} +
    • {{ value }}
    • + {% endfor %} + + {% for field, value in form.additional_instructions_field.values %} +
    • {{ value }}
    • + {% endfor %} + +
    +
    +
    +
    +{% if settings.SHOP_PAYMENT_STEP_ENABLED %} +{% comment %} +
    +
    +
    +
    +

    {% trans "Payment Details" %}

    +
      + + {% for field, value in form.card_name_field.values %} +
    • {{ value }}
    • + {% endfor %} + + {% for field, value in form.card_type_field.values %} +
    • {{ value }}
    • + {% endfor %} + +
    • + {% with form.card_expiry_fields.values as expiry_fields %} + {% with expiry_fields.next as month_field %} + {{ month_field.1 }}/{{ expiry_fields.next.1 }} + {% endwith %} + {% endwith %} +
    • + + {% for field, value in form.card_fields.values %} +
    • {{ value }}
    • + {% endfor %} + +
    +
    +
    +
    +{% endcomment %} +{% endif %} +
    + +{% for field in form %}{{ field }}{% endfor %} + +{% endif %} +{% endblock %} diff --git a/app/templates/shop/includes/order_details.html b/app/templates/shop/includes/order_details.html new file mode 100644 index 00000000..b6aa60a3 --- /dev/null +++ b/app/templates/shop/includes/order_details.html @@ -0,0 +1,55 @@ +{% load shop_tags i18n %} + +

    {{ settings.SITE_TITLE }}

    + + + + + + +
    {% trans "Order ID:" %} {{ order.id }}{{ order.time }}
    + +

    {% trans "Your Details" %}

    + + + + + + + + + +
    {% trans "Billing Details" %}{% trans "Shipping Details" %}
    + + {% for field, value in order_billing_detail_fields %} + + {% endfor %} +
    {{ field }}:   {{ value }}
    +
    + + {% for field, value in order_shipping_detail_fields %} + + {% endfor %} +
    {{ field }}:   {{ value }}
    +
    + +

    {% trans "Items Ordered" %}

    + + + + + + + + {% for item in order.items.all %} + + + + + + + {% endfor %} + + + +
    {% trans "Item" %}{% trans "Unit Price" %}{% trans "Qty" %}{% trans "Price" %}
    {{ item.description }}{{ item.unit_price|currency }}{{ item.quantity }}{{ item.total_price|currency }}
    {% order_totals %}
    diff --git a/app/templates/shop/includes/order_details_rtl.html b/app/templates/shop/includes/order_details_rtl.html new file mode 100644 index 00000000..e1760a14 --- /dev/null +++ b/app/templates/shop/includes/order_details_rtl.html @@ -0,0 +1,61 @@ +{% load shop_tags i18n %} + +

    {{ settings.SITE_TITLE }}

    + + + + + + +
    {{ order.time }}{% trans "Order ID:" %} {{ order.id }}
    + +

    {% trans "Your Details" %}

    + + + + + + + + + +
    {% trans "Billing Details" %}{% trans "Shipping Details" %}
    + + {% for field, value in order_billing_detail_fields %} + + {% endfor %} +
    {{ value }}    : {{ field }}
    +
    + + {% for field, value in order_shipping_detail_fields %} + + {% endfor %} +
    {{ value }}    : {{ field }}
    +
    + +

    {% trans "Items Ordered" %}

    + + + + + + + + + + + {% for item in order.items.all %} + + + + + + + + + + {% endfor %} + + + +
    {% trans "Price" %}{% trans "Qty" %}{% trans "Unit Price" %}{% trans "Item" %}
    {{ item.total_price|currency }}{{ item.quantity }}{{ item.unit_price|currency }}{{ item.description }}
    {% order_totals %}
    diff --git a/app/templates/shop/includes/order_totals.html b/app/templates/shop/includes/order_totals.html new file mode 100644 index 00000000..ffe3cf4a --- /dev/null +++ b/app/templates/shop/includes/order_totals.html @@ -0,0 +1,40 @@ +{% load shop_tags i18n %} +
    + {% if discount_total or shipping_total %} +
    {{ item_total|currency }}
    + {% endif %} + {% if discount_total %} +
    + {{ discount_total|currency }} +
    + {% endif %} + {% if shipping_type or shipping_total %} +
    + {{ shipping_total|currency }} +
    + {% endif %} + {% if tax_total %} +
    + {{ tax_total|currency }} +
    + {% endif %} +
    {{ order_total|currency }}
    +
    diff --git a/app/templates/shop/includes/order_totals.txt b/app/templates/shop/includes/order_totals.txt new file mode 100644 index 00000000..fdbb3a89 --- /dev/null +++ b/app/templates/shop/includes/order_totals.txt @@ -0,0 +1,11 @@ +{% load shop_tags i18n %}{% if discount_total or shipping_total %} +{% trans "Sub total" %}: {{ item_total|currency }} +{% endif %}{% if discount_total %} +{% if discount_type %}{{ discount_type }}{% else %}{% trans "Discount" %}{% endif %}: {{ discount_total|currency }} +{% endif %}{% if shipping_type or shipping_total %} +{% if shipping_type %}{{ shipping_type }}{% else %}{% trans "Shipping" %}{% endif %}: {{ shipping_total|currency }} +{% endif %} {% if tax_total %} +{% if tax_type %}{{ tax_type }}{% else %}{% trans "Tax" %}{% endif %}: {{ tax_total|currency }} +{% endif %}{% trans "Total" %}: {{ order_total|currency }} + + diff --git a/app/templates/shop/includes/payment_fields.html b/app/templates/shop/includes/payment_fields.html new file mode 100644 index 00000000..235519a2 --- /dev/null +++ b/app/templates/shop/includes/payment_fields.html @@ -0,0 +1,14 @@ +{% load i18n mezzanine_tags %} +
    + {% trans "Payment Details" %} + {% fields_for form.card_name_field %} + {% fields_for form.card_type_field %} + {% with form.card_expiry_fields as card_expiry_fields %} +
    + + {% fields_for card_expiry_fields %} +
    +
    + {% endwith %} + {% fields_for form.card_fields %} +
    diff --git a/app/templates/shop/includes/user_panel.html b/app/templates/shop/includes/user_panel.html new file mode 100644 index 00000000..db8f64c4 --- /dev/null +++ b/app/templates/shop/includes/user_panel.html @@ -0,0 +1,18 @@ +{% load i18n shop_tags mezzanine_tags %} +{% spaceless %} + + +{% blocktrans count request.cart.total_quantity as cart_quantity %}1 item{% plural %}{{ cart_quantity }} items{% endblocktrans %} +{% trans "in cart" %}: +{{ request.cart.total_price|currency }}
    +{% if request.cart.total_quantity != 0 %} + + {% if request.session.order.step %}{% trans "Return to Checkout" %}{% else %}{% trans "Go to Checkout" %}{% endif %} +
    +{% endif %} +{% if settings.SHOP_USE_WISHLIST %} + + +{% blocktrans count request.wishlist|length as wishlist_count %}Wishlist contains 1 item{% plural %} Wishlist contains {{ wishlist_count }} items{% endblocktrans %} +{% endif %} +{% endspaceless %} diff --git a/app/templates/shop/order_history.html b/app/templates/shop/order_history.html new file mode 100644 index 00000000..cb319e07 --- /dev/null +++ b/app/templates/shop/order_history.html @@ -0,0 +1,51 @@ +{% extends "shop/base.html" %} +{% load mezzanine_tags shop_tags i18n %} + +{% block meta_title %}{% trans "Order History" %}{% endblock %} +{% block title %}{% trans "Order History" %}{% endblock %} + +{% block breadcrumb_menu %} +{{ block.super }} +
  • {% trans "Order History" %}
  • +{% endblock %} + +{% block main %} + +{% if orders %} + + + + + + + + + + + {% for order in orders.object_list %} + + + + + + + + {% endfor %} + +
    ID{% trans "Date" %}{% trans "Qty" %}{% trans "Paid" %} 
    {{ order.id }}{{ order.time|date:"SHORT_DATE_FORMAT" }}{{ order.quantity_total }}{{ order.total|currency }} +
    + {% csrf_token %} + {% if has_pdf %} + {% trans "Download PDF" %} + {% endif %} + {% trans "View invoice" %} + +
    +
    +{% pagination_for orders %} + +{% else %} +

    {% trans "You have not ordered anything from us yet." %}

    +{% endif %} + +{% endblock %} diff --git a/app/templates/shop/order_invoice.html b/app/templates/shop/order_invoice.html new file mode 100644 index 00000000..5dcda6c9 --- /dev/null +++ b/app/templates/shop/order_invoice.html @@ -0,0 +1,5 @@ +{% if not LANGUAGE_BIDI %} + {% include "shop/includes/order_details.html" %} +{% else %} + {% include "shop/includes/order_details_rtl.html" %} +{% endif %} diff --git a/app/templates/shop/order_invoice_pdf.html b/app/templates/shop/order_invoice_pdf.html new file mode 100644 index 00000000..da6b04fc --- /dev/null +++ b/app/templates/shop/order_invoice_pdf.html @@ -0,0 +1 @@ +{% extends "shop/order_invoice.html" %} diff --git a/app/templates/shop/payment.html b/app/templates/shop/payment.html new file mode 100644 index 00000000..6be458e6 --- /dev/null +++ b/app/templates/shop/payment.html @@ -0,0 +1,10 @@ +{% extends "shop/checkout.html" %} +{% load i18n mezzanine_tags %} + +{% block fields %} +{% if request.cart.has_items %} +{% errors_for form %} +{% include "shop/includes/payment_fields.html" %} +{% fields_for form.other_fields %} +{% endif %} +{% endblock %} diff --git a/app/templates/shop/product.html b/app/templates/shop/product.html new file mode 100644 index 00000000..4ef715d0 --- /dev/null +++ b/app/templates/shop/product.html @@ -0,0 +1,159 @@ +{% extends "shop/base.html" %} +{% load staticfiles mezzanine_tags shop_tags rating_tags i18n %} + +{% block meta_title %}{{ product.meta_title }}{% endblock %} +{% block body_id %}category{% endblock %} + +{% block meta_keywords %}{% metablock %} +{% for keyword in product.keywords.all %} + {% if not forloop.first %}, {% endif %} + {{ keyword }} +{% endfor %} +{% endmetablock %}{% endblock %} + +{% block meta_description %}{% metablock %} +{{ product.description }} +{% endmetablock %}{% endblock %} + +{% block extra_css %} +{{ block.super }} + +{% endblock %} + +{% block extra_js %} +{{ block.super }} + + +{% endblock %} + +{% block extra_head %} +{{ block.super }} + + +{% endblock %} + +{% block breadcrumb_menu %} +{{ block.super }} +
  • {{ product.title }}
  • +{% endblock %} + +{% block title %} +{% editable product.title %}{{ product.title }}{% endeditable %} +{% endblock %} + +{% block main %} + +{% if images %} +{% spaceless %} + + +{% if images|length != 1 %} + +{% endif %} + +{% endspaceless %} +{% endif %} + +{% editable product.content %} +{{ product.content|richtext_filters|safe }} +{% endeditable %} + +{% if product.available and has_available_variations %} + + +{% errors_for add_product_form %} + +
    + {% fields_for add_product_form %} +
    + + {% if settings.SHOP_USE_WISHLIST %} + + {% endif %} +
    +
    +{% else %} +

    {% trans "This product is currently unavailable." %}

    +{% endif %} + +{% if settings.SHOP_USE_RATINGS %} +
    +
    {% rating_for product %}
    +
    +{% endif %} + +{% if settings.SHOP_USE_RELATED_PRODUCTS and related_products %} +

    {% trans "Related Products" %}

    + +{% endif %} + +{% endblock %} diff --git a/app/templates/shop/wishlist.html b/app/templates/shop/wishlist.html new file mode 100644 index 00000000..fefde92c --- /dev/null +++ b/app/templates/shop/wishlist.html @@ -0,0 +1,46 @@ +{% extends "shop/base.html" %} +{% load mezzanine_tags shop_tags i18n %} + +{% block meta_title %}{% trans "Your Wishlist" %}{% endblock %} +{% block title %}{% trans "Your Wishlist" %}{% endblock %} + +{% block breadcrumb_menu %} +{{ block.super }} +
  • {% trans "Your Wishlist" %}
  • +{% endblock %} + +{% block main %} +{% if error %}{{ error }}{% endif %} +{% if request.wishlist %} + + {% for item in wishlist_items %} + + + + + + {% endfor %} +
    + {% if item.image %} + {{ item }} + {% else %} +   + {% endif %} + + {{ item }} + +
    + {{ item.unit_price|currency }} + {% csrf_token %} + + + + +
    +
    +{% else %} +

    {% trans "Your wishlist is empty." %}

    +
    +

    {% trans "Continue Shopping" %}

    +{% endif %} +{% endblock %} diff --git a/app/urls.py b/app/urls.py index 5ade0f91..e4210986 100644 --- a/app/urls.py +++ b/app/urls.py @@ -28,7 +28,6 @@ if settings.USE_MODELTRANSLATION: urlpatterns += [ # App urls - url("^", include('organization.urls')), url("^styles/$", direct_to_template, {"template": "styles.html"}, name="styles"),