Skip to content

Commit

Permalink
fix: User able to save a new record many times
Browse files Browse the repository at this point in the history
in forms that have Add, Edit, Delete function together
  • Loading branch information
Polyanyanwu committed Aug 19, 2022
1 parent d28bea0 commit 834fdc6
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ There is no known current bugs in the system after an exhaustive testing.

- Edit artwork gives Error 500 when SKU is edited. Fixed by using the Artwork ID to fetch the record and passing the ID properly through a context variable. See Commit [dbabea](https://github.com/Polyanyanwu/graces-art-pp5/commit/dbabeae8be439caebfcaf5d8bc1a231539a3714f)

- Edit?Delete artwork gives Error 500 when Edit button is clicked. Caused by a JavaScript crash when looking for sort element not on current page. Resolved by enclosing the offending function in an if statement to check the existence of the element before proceeding with setting the event listener. It was hard to notice because the sort element involved only goes away when on mobile devices. Resolved through [Commit 38e09d](https://github.com/Polyanyanwu/graces-art-pp5/commit/38e09daf9259f0ed83de95be9ddb7fd2766f2ee2)

## **Deployment**

The application was deployed to [Heroku](https://heroku.com) where all the code and database is hosted. The static files were hosted on [Amazon S3 Object Storage](https://aws.amazon.com/s3/). [Strip](https://dashboard.stripe.com) was used for card payment collection. Details of the fork, clone and deployment process [is available here](/docs/deploy/deployment.md)
20 changes: 16 additions & 4 deletions artworks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def maintain_artist(request):
else:
form = ArtistForm(request.POST)
if form.is_valid():
form.save()
new_rec = form.save()
# put the newly saved record in edit mood to prevent
# creating a new record again if the save key is pressed twice
request.session['current_rec'] = new_rec.id
messages.success(request,
('Your Artist was successfully saved!'))
else:
Expand Down Expand Up @@ -134,7 +137,10 @@ def maintain_art_style(request):
else:
form = ArtStyleForm(request.POST, request.FILES)
if form.is_valid():
form.save()
new_rec = form.save()
# put the newly saved record in edit mood to prevent
# creating a new record again if the save key is pressed twice
request.session['current_rec'] = new_rec.id
messages.success(request,
('Your Art Style was successfully saved!'))
else:
Expand Down Expand Up @@ -202,7 +208,10 @@ def maintain_art_genre(request):
else:
form = ArtGenreForm(request.POST)
if form.is_valid():
form.save()
new_rec = form.save()
# put the newly saved record in edit mood to prevent
# creating a new record again if the save key is pressed twice
request.session['current_rec'] = new_rec.id
messages.success(request,
('Your Art Genre was successfully saved!'))
else:
Expand Down Expand Up @@ -527,7 +536,10 @@ def maintain_art_frame(request):
else:
form = ArtFrameForm(request.POST, request.FILES)
if form.is_valid():
form.save()
new_rec = form.save()
# put the newly saved record in edit mood to prevent
# creating a new record again if the save key is pressed twice
request.session['current_rec'] = new_rec.id
messages.success(request,
('Your Art Frame was successfully saved!'))
else:
Expand Down
55 changes: 45 additions & 10 deletions docs/testing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -825,25 +825,60 @@ Note that validations are fully done. The SKU is unique and must be 12 character

![Edit/Delete Artwork](/docs/images/edit_artwork.png)

- Notice the search bar
- Notice the search bar has a form that accepts SKU and artwork name
- Input any part of the name of the artwork and click the search button
- the list is updated to reflect the result of your search (**A4.2**)
- Update any of the desired field, noting that the Artist, Style, Genre is almost not supposed to change except it was an error initially.
- Click Save button to save your updates in the database.
- The success message is displayed or error message if there is error.

#### A5. Delete artwork

Menu item to delete artwork is available on Admin menu
Admin is able to search and locate artwork to delete
Delete is successful
1. Menu item to delete artwork is available on Admin menu
2. Admin is able to search and locate artwork to delete
3. Delete is successful

- The delete functionality was included on the page for the Edit/Delete which was tested in A4 above.

- follow the process in A4
- Click Edit button on the row of the artwork you wish to delete
- Click Okay when the confirmation prompt displays
- The artwork is delete and leaves the list of artworks displayed and a success message is displayed.

#### A6. Edit/update photo frames

Menu item to Edit photo frames is available on Admin menu
Admin is able to locate photo frame to update
Update is successful
1. Menu item to Edit photo frames is available on Admin menu
2. Admin is able to locate photo frame to update
3. Update is successful

The Art Frame feature was discussed with Project Owner during the development and the Add, Edit and Delete process was developed on one page.

- Login with a username that belongs to administrator group
- Click on Admin/Ops icon
- From the dropdown menu, click on Maintain Art Frame (**A6.1**)
- The Maintain Art Frames page opens with a list of existing art frames on the right and a form for editing/adding new frame on the left.
**- To edit an art frame:**
- Click edit button on the row of the art frame of interest
- the art frame is loaded on the form
- change any of the fields of interest
- click Save button and a success message is displayed
**- To cancel your inputs on a form**
- Click the Cancel button and the current edits/entry on the form is cleared
**- To Delete an Art Frame**
- Click the Delete button on the row of the art frame to delete
- Click Okay to confirm the delete action
- A success message is displayed or error message if any.
**- To Add a new Art Frame**
- Click New button
- Fill the form with the necessary data
- Upload the image if any
- Click Save and a success message is given or error message if any

#### A7. Delete photo frames

Menu item to delete photo frame is available on Admin menu
Admin is able to locate photo frame to delete
Delete is successful
1. Menu item to delete photo frame is available on Admin menu
2. Admin is able to locate photo frame to delete
3. Delete is successful

#### A8. Add/update general information

Expand Down
5 changes: 4 additions & 1 deletion home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ def maintain_faq(request):
else:
form = FAQForm(request.POST)
if form.is_valid():
form.save()
new_rec = form.save()
# put the newly saved record in edit mood to prevent
# creating a new record again if the save key is pressed twice
request.session['current_rec'] = new_rec.id
messages.success(request,
('Your FAQ was successfully saved!'))
else:
Expand Down

0 comments on commit 834fdc6

Please sign in to comment.