feat: add Products form to admin
This commit is contained in:
45
home/templates/purchase/admin/admin_purchase.html
Normal file
45
home/templates/purchase/admin/admin_purchase.html
Normal file
@@ -0,0 +1,45 @@
|
||||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load static i18n %}
|
||||
|
||||
{% block titletag %}
|
||||
{% trans "Product" %} {% if product %} — {{ product.name }}{% endif %}
|
||||
{% endblock titletag %}
|
||||
|
||||
{% block content %}
|
||||
{% include "wagtailadmin/shared/header.html" with title="Products" icon="tag" %}
|
||||
<div style="padding: 0 3em;">
|
||||
<a href="{% url 'admin_purchase_dashboard' %}" class="button button-secondary">← {% trans "Back" %}</a>
|
||||
<h1>{% if product %}{% trans "Edit product" %}{% else %}{% trans "Add product" %}{% endif %}</h1>
|
||||
|
||||
{% if error %}
|
||||
<div class="message error">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
<label for="id_name">{% trans "Name" %}</label>
|
||||
<input id="id_name" name="name" type="text" value="{{ product.name|default_if_none:'' }}" required>
|
||||
|
||||
<label for="id_description">{% trans "Description" %}</label>
|
||||
<textarea id="id_description" name="description">{{ product.description|default_if_none:'' }}</textarea>
|
||||
|
||||
<label for="id_price">{% trans "Price (cents)" %}</label>
|
||||
<input id="id_price" name="price_cents" type="number" value="{{ product.price_cents|default_if_none:'' }}" required>
|
||||
|
||||
<label for="id_currency">{% trans "Currency" %}</label>
|
||||
<input id="id_currency" name="currency" type="text" value="{{ product.currency|default_if_none:'usd' }}">
|
||||
|
||||
<p>
|
||||
{% trans "Stripe product" %}: {{ product.stripe_product_id|default:"—" }}<br>
|
||||
{% trans "Stripe price" %}: {{ product.stripe_price_id|default:"—" }}
|
||||
</p>
|
||||
|
||||
<div style="margin-top:1em;">
|
||||
<button type="submit" class="button button-primary">{% trans "Save" %}</button>
|
||||
{% if product %}
|
||||
<button type="submit" name="action" value="delete" class="button button-secondary" style="margin-left:0.5em">{% trans "Delete" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
23
home/templates/purchase/admin/admin_purchase_dashboard.html
Normal file
23
home/templates/purchase/admin/admin_purchase_dashboard.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load static i18n %}
|
||||
|
||||
{% block titletag %}
|
||||
{% trans "Products" %}
|
||||
{% endblock titletag %}
|
||||
|
||||
{% block content %}
|
||||
{% include "wagtailadmin/shared/header.html" with title="Products" icon="tag" %}
|
||||
<h1>{% trans "Purchasable Products" %}</h1>
|
||||
<a href="{% url 'admin_purchase_add' %}" class="button button-primary">{% trans "Add product" %}</a>
|
||||
<ul>
|
||||
{% for p in products %}
|
||||
<li>
|
||||
<a href="{% url 'admin_purchase' p.id %}">
|
||||
{{ p.name }} — {{ p.price_cents|floatformat:-2 }} {{ p.currency|upper }}
|
||||
</a>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li>{% trans "No products found." %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock content %}
|
||||
Reference in New Issue
Block a user