Django Imager: Create Views to Edit Models

In this series of assignments you will build a simple image management website using Django. In this sixth step, you will provide users with a way to edit resources from the front-end of the application. Now you’ll be able to interact with your site fully from the front end.

Tasks

Do your work for this assignment on a branch called front-end-4. Be sure that the branch contains your work for all previous parts of this work.

Editing

Create views that allow updating existing albums and photos. On the library page, add an edit button to each album and photo that will load this view when clicked. The view that loads should show a form with the fields of the object to be edited. The album form should offer the user the ability to choose photos from their library to add to the album. When the form is submitted, the user should be returned to the library page.

The URLs for these pages should be

  • /images/albums/<album_id>/edit/
  • /images/photos/<photo_id>/edit/

Finally, create a view that allows a user to edit their Profile. This view should provide access not only to the data on the user’s ImagerProfile, but also to fields like email or first_name and last_name that are defined on the User object instead. When the form is submitted, the User should be returned to their profile page where they can see the updated information.

The URL for this page should be /profile/edit/

Tests

You must implement tests to ensure your views are functioning properly. In particular ensure that no user may edit resources that do not belong to him or her.

Submitting Your Work

When you are done working and all your tests are passing, create a Pull Request from the front-end-4 branch to master. Submit the URL for that pull request. When you are done, you can merge the pull request in preparation for the next stage of your work.