Fix product-create "cancel" link to redirect to catalog
This commit is contained in:
parent
bfeb3718f5
commit
d0621b2d47
@ -10,7 +10,7 @@
|
||||
{% csrf_token %}
|
||||
{{form.as_p}}
|
||||
<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>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@ -20,8 +20,12 @@ from dashboard.forms import (
|
||||
from dashboard.views import (
|
||||
DashboardHomeView,
|
||||
DashboardConfigView,
|
||||
ShippingRateCreateView,
|
||||
CatalogView,
|
||||
StockView,
|
||||
ShippingRateDetailView,
|
||||
ShippingRateCreateView,
|
||||
ShippingRateUpdateView,
|
||||
ShippingRateDeleteView,
|
||||
CouponListView,
|
||||
CouponCreateView,
|
||||
CouponDetailView,
|
||||
@ -30,24 +34,74 @@ from dashboard.views import (
|
||||
OrderListView,
|
||||
OrderDetailView,
|
||||
OrderFulfillView,
|
||||
OrderCancelView,
|
||||
OrderTrackingView,
|
||||
CategoryListView,
|
||||
CategoryCreateView,
|
||||
CategoryDetailView,
|
||||
CategoryUpdateView,
|
||||
CategoryDeleteView,
|
||||
ProductListView,
|
||||
ProductDetailView,
|
||||
ProductUpdateView,
|
||||
ProductCreateView,
|
||||
ProductUpdateView,
|
||||
ProductDeleteView,
|
||||
ProductPhotoCreateView,
|
||||
ProductPhotoDeleteView,
|
||||
ProductVariantCreateView,
|
||||
ProductVariantUpdateView,
|
||||
ProductVariantDeleteView,
|
||||
ProductVariantStockUpdateView,
|
||||
ProductOptionDetailView,
|
||||
ProductOptionCreateView,
|
||||
ProductOptionUpdateView,
|
||||
ProductOptionDeleteView,
|
||||
CustomerListView,
|
||||
CustomerDetailView,
|
||||
CustomerUpdateView
|
||||
CustomerUpdateView,
|
||||
)
|
||||
|
||||
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):
|
||||
fixtures = [
|
||||
'shipping_rates.json',
|
||||
'accounts.json',
|
||||
'coupons.json',
|
||||
'products.json',
|
||||
|
||||
@ -346,13 +346,6 @@ class ProductDetailView(LoginRequiredMixin, DetailView):
|
||||
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):
|
||||
model = Product
|
||||
template_name = 'dashboard/product_create_form.html'
|
||||
@ -360,10 +353,17 @@ class ProductCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView):
|
||||
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):
|
||||
model = Product
|
||||
template_name = 'dashboard/product_confirm_delete.html'
|
||||
success_url = reverse_lazy('dashboard:product-list')
|
||||
success_url = reverse_lazy('dashboard:catalog')
|
||||
success_message = 'Product deleted.'
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user