Commit f255a12a authored by Christine Dela Rosa's avatar Christine Dela Rosa

Fix cancel buttons for store forms

parent 2c4cb527
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
{{ form.as_p }} {{ form.as_p }}
</div> </div>
<div class="button-space"> <div class="button-space">
<button type="button" class="btn btn-danger"><a class="link-text" href= "{% url 'storeid' request.user.id %}">Cancel</a></button> <button type="button" class="btn btn-danger"><a class="link-text" href= "{% url 'storeid' current_store.storeid %}">Cancel</a></button>
<button type="submit" class="btn btn-dark" name="Add Item"> Add Item </button> <button type="submit" class="btn btn-dark" name="Add Item"> Add Item </button>
</div> </div>
</form> </form>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
{{ form.as_p }} {{ form.as_p }}
</div> </div>
<div class="button-space"> <div class="button-space">
<button type="button" class="btn btn-danger"><a class="link-text" href= "{% url 'storeid' request.user.id %}">Cancel</a></button> <button type="button" class="btn btn-danger"><a class="link-text" href= "{% url 'storeid' current_store.storeid %}">Cancel</a></button>
<button type="submit" class="btn btn-dark" name="savesauction">Save Auction</button> <button type="submit" class="btn btn-dark" name="savesauction">Save Auction</button>
</div> </div>
</form> </form>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{{ form.as_p }} {{ form.as_p }}
</div> </div>
<div class="button-space"> <div class="button-space">
<button type="button" class="btn btn-danger"><a class="link-text" href= "{% url 'storeid' request.user.id %}">Cancel</a></button> <button type="button" class="btn btn-danger"><a class="link-text" href= "{% url 'storeid' current_store %}">Cancel</a></button>
<button type="submit" class="btn btn-dark" name="Add Item"> Save Changes </button> <button type="submit" class="btn btn-dark" name="Add Item"> Save Changes </button>
</div> </div>
</form> </form>
......
...@@ -222,6 +222,7 @@ def mystore(request, pk): ...@@ -222,6 +222,7 @@ def mystore(request, pk):
'current_store':current_store, 'current_store':current_store,
'store_owner':store_owner, 'store_owner':store_owner,
'store_items':store_items, 'store_items':store_items,
'all_auctions':all_auctions,
'form':form 'form':form
} }
...@@ -259,7 +260,7 @@ def editItem(request, pk): ...@@ -259,7 +260,7 @@ def editItem(request, pk):
This view is a form wherin users [sellers] can edit item details on their store. After successfully editing the item, they will be redirected back to the store. This view is a form wherin users [sellers] can edit item details on their store. After successfully editing the item, they will be redirected back to the store.
A user also has access to the other parts of the site from here through the navigation bar. A user also has access to the other parts of the site from here through the navigation bar.
''' '''
item = Item.objects.get(itemid=pk) item = Item.objects.get(itemid=pk)
current_store = item.storeid current_store = item.storeid
form = AddItemForm(instance=item) form = AddItemForm(instance=item)
...@@ -268,10 +269,11 @@ def editItem(request, pk): ...@@ -268,10 +269,11 @@ def editItem(request, pk):
form = AddItemForm(request.POST, instance=item) form = AddItemForm(request.POST, instance=item)
if form.is_valid(): if form.is_valid():
form.save() form.save()
return redirect('storeid', pk=current_store) return redirect('storeid', pk=current_store.storeid)
context = { context = {
'form':form, 'form':form,
'current_store':current_store,
'title': 'Edit item information' 'title': 'Edit item information'
} }
...@@ -285,7 +287,7 @@ def startAuction(request, pk): ...@@ -285,7 +287,7 @@ def startAuction(request, pk):
They will have to fill in the details of their auction such as when they want it to start and end, and the particular item that is up for grabs. They will have to fill in the details of their auction such as when they want it to start and end, and the particular item that is up for grabs.
A user also has access to the other parts of the site from here through the navigation bar. A user also has access to the other parts of the site from here through the navigation bar.
''' '''
all_auctions = Auction.objects.all()
current_store = Store.objects.get(pk=pk) current_store = Store.objects.get(pk=pk)
store_id = current_store.storeid store_id = current_store.storeid
store_items = Item.objects.filter(storeid=store_id) store_items = Item.objects.filter(storeid=store_id)
...@@ -399,7 +401,7 @@ def editStore(request, pk): ...@@ -399,7 +401,7 @@ def editStore(request, pk):
''' '''
store= Store.objects.get(storeid=pk) store= Store.objects.get(storeid=pk)
current_store = store.storeid current_store = store.stgitoreid
form = CreateStoreForm(instance=store) form = CreateStoreForm(instance=store)
if request.method == 'POST': if request.method == 'POST':
...@@ -410,6 +412,7 @@ def editStore(request, pk): ...@@ -410,6 +412,7 @@ def editStore(request, pk):
context = { context = {
'form': form, 'form': form,
'current_store':current_store,
'title': 'Edit Store Information' 'title': 'Edit Store Information'
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment