Fix product-create "cancel" link to redirect to catalog
This commit is contained in:
parent
bfeb3718f5
commit
d0621b2d47
@ -10,7 +10,7 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{form.as_p}}
|
{{form.as_p}}
|
||||||
<p class="form__submit">
|
<p class="form__submit">
|
||||||
<input class="action-button" type="submit" value="Create product"> or <a href="{% url 'dashboard:product-list' %}">cancel</a>
|
<input class="action-button" type="submit" value="Create product"> or <a href="{% url 'dashboard:catalog' %}">cancel</a>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -20,8 +20,12 @@ from dashboard.forms import (
|
|||||||
from dashboard.views import (
|
from dashboard.views import (
|
||||||
DashboardHomeView,
|
DashboardHomeView,
|
||||||
DashboardConfigView,
|
DashboardConfigView,
|
||||||
ShippingRateCreateView,
|
CatalogView,
|
||||||
|
StockView,
|
||||||
ShippingRateDetailView,
|
ShippingRateDetailView,
|
||||||
|
ShippingRateCreateView,
|
||||||
|
ShippingRateUpdateView,
|
||||||
|
ShippingRateDeleteView,
|
||||||
CouponListView,
|
CouponListView,
|
||||||
CouponCreateView,
|
CouponCreateView,
|
||||||
CouponDetailView,
|
CouponDetailView,
|
||||||
@ -30,24 +34,74 @@ from dashboard.views import (
|
|||||||
OrderListView,
|
OrderListView,
|
||||||
OrderDetailView,
|
OrderDetailView,
|
||||||
OrderFulfillView,
|
OrderFulfillView,
|
||||||
|
OrderCancelView,
|
||||||
OrderTrackingView,
|
OrderTrackingView,
|
||||||
|
CategoryListView,
|
||||||
|
CategoryCreateView,
|
||||||
|
CategoryDetailView,
|
||||||
|
CategoryUpdateView,
|
||||||
|
CategoryDeleteView,
|
||||||
ProductListView,
|
ProductListView,
|
||||||
ProductDetailView,
|
ProductDetailView,
|
||||||
ProductUpdateView,
|
|
||||||
ProductCreateView,
|
ProductCreateView,
|
||||||
|
ProductUpdateView,
|
||||||
ProductDeleteView,
|
ProductDeleteView,
|
||||||
ProductPhotoCreateView,
|
ProductPhotoCreateView,
|
||||||
ProductPhotoDeleteView,
|
ProductPhotoDeleteView,
|
||||||
|
ProductVariantCreateView,
|
||||||
|
ProductVariantUpdateView,
|
||||||
|
ProductVariantDeleteView,
|
||||||
|
ProductVariantStockUpdateView,
|
||||||
|
ProductOptionDetailView,
|
||||||
|
ProductOptionCreateView,
|
||||||
|
ProductOptionUpdateView,
|
||||||
|
ProductOptionDeleteView,
|
||||||
CustomerListView,
|
CustomerListView,
|
||||||
CustomerDetailView,
|
CustomerDetailView,
|
||||||
CustomerUpdateView
|
CustomerUpdateView,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ProductCreateViewTests(TestCase):
|
||||||
|
fixtures = [
|
||||||
|
'shipping_rates.json',
|
||||||
|
'accounts.json',
|
||||||
|
'coupons.json',
|
||||||
|
'products.json',
|
||||||
|
'orders.json'
|
||||||
|
]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(cls):
|
||||||
|
cls.admin_user = User.objects.get(pk=1)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.client = Client()
|
||||||
|
self.client.force_login(self.admin_user)
|
||||||
|
|
||||||
|
def test_view_url_exists_at_desired_location(self):
|
||||||
|
response = self.client.get('/dashboard/products/new/')
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_view_url_accesible_by_name(self):
|
||||||
|
response = self.client.get(
|
||||||
|
reverse('dashboard:product-create')
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_view_uses_correct_template(self):
|
||||||
|
response = self.client.get(
|
||||||
|
reverse('dashboard:product-create')
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertTemplateUsed(response, 'dashboard/product_create_form.html')
|
||||||
|
|
||||||
|
|
||||||
class OrderCancelViewTests(TestCase):
|
class OrderCancelViewTests(TestCase):
|
||||||
fixtures = [
|
fixtures = [
|
||||||
|
'shipping_rates.json',
|
||||||
'accounts.json',
|
'accounts.json',
|
||||||
'coupons.json',
|
'coupons.json',
|
||||||
'products.json',
|
'products.json',
|
||||||
|
|||||||
@ -346,13 +346,6 @@ class ProductDetailView(LoginRequiredMixin, DetailView):
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
class ProductUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
|
|
||||||
model = Product
|
|
||||||
template_name = 'dashboard/product_update_form.html'
|
|
||||||
fields = '__all__'
|
|
||||||
success_message = '%(name)s saved.'
|
|
||||||
|
|
||||||
|
|
||||||
class ProductCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView):
|
class ProductCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView):
|
||||||
model = Product
|
model = Product
|
||||||
template_name = 'dashboard/product_create_form.html'
|
template_name = 'dashboard/product_create_form.html'
|
||||||
@ -360,10 +353,17 @@ class ProductCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView):
|
|||||||
success_message = '%(name)s created.'
|
success_message = '%(name)s created.'
|
||||||
|
|
||||||
|
|
||||||
|
class ProductUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
|
||||||
|
model = Product
|
||||||
|
template_name = 'dashboard/product_update_form.html'
|
||||||
|
fields = '__all__'
|
||||||
|
success_message = '%(name)s saved.'
|
||||||
|
|
||||||
|
|
||||||
class ProductDeleteView(LoginRequiredMixin, SuccessMessageMixin, DeleteView):
|
class ProductDeleteView(LoginRequiredMixin, SuccessMessageMixin, DeleteView):
|
||||||
model = Product
|
model = Product
|
||||||
template_name = 'dashboard/product_confirm_delete.html'
|
template_name = 'dashboard/product_confirm_delete.html'
|
||||||
success_url = reverse_lazy('dashboard:product-list')
|
success_url = reverse_lazy('dashboard:catalog')
|
||||||
success_message = 'Product deleted.'
|
success_message = 'Product deleted.'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user