Skip to content

A web application completed as Project 3 of the Udacity Full Stack Web Developer Nanodegree; provides a list of items within a variety of categories as well as providing a user registration and authentication system

samfrances/udacity-item-catalog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

udacity-item-catalog

Forked from: udacity/rdb-fullstack

Description

A web application that provides a list of items within a variety of categories as well as providing a user registration and authentication system. Registered users will have the ability to post, edit and delete their own items.

Test-driving the app with vagrant

(Using $repo to refer to the path of the repository)

  1. Install Vagrant and VirtualBox
  2. Clone this repository
  3. Create a directory $repo/vagrant/catalog/instance/, and within it a blank file config.py. This can be used to hold instance specific config, overriding the testing config variables.
  4. Download your Oauth client secret json file and rename it to client_secrets.json, placing it in $repo/vagrant/catalog/instance/.
  5. Launch the Vagrant VM with the command vagrant up anywhere under $repo/vagrant.
  6. Use the command vagrant ssh to ssh into the VM.
  7. In the VM, go to /vagrant/catalog/ and run python populatedb.py to create the database and populate it with tags and items.
  8. In /vagrant/catalog/ and run python runserver.py to start the server.
  9. In your browser, navigate to http://localhost:5000.
  10. Sign in with Google to experience full functionality. Note that the first user you sign in with will be considered the owner of all the items and tags created by populatedb.py. Sign out and sign in with a second user to verify that users cannot change other users' items or tags.

Admin interface

The admin interface can be found at /admin/. This allows the admin to view a table of information about users, and to activate and deactivate users. Deactivated users can no longer add, edit or delete items or tags, whereas activated users can add items and tags, and can edit and delete their own items and tags.

Admin users can also edit and delete any item or category, regardless of ownership.

Admin privileges script

To make a user into an admin, use the script make_admin.py in $repo/vagrant/catalog/, specifying either revoke or grant and the email address of the relevant user, and then follow the prompts. For example:

vagrant@vagrant-ubuntu-trusty-32:/vagrant/catalog$ python make_admin.py grant example@example.com
Looking for a user with email address: example@example.com
Found the following users:

<User: name='Bob Example', email='example@example.com', id=2, activated=True, admin=False>

Grant admin privileges? (y/n): y
Admin privileges changed.

<User: name='Bob Example', email='example@example.com', id=2, activated=True, admin=True>

Goodbye

JSON API endpoints

  • /catalog.json
    • Shows information on all tags and all items, referenced from 'Items' and 'Tags' keys
  • /catalog/items.json
    • Shows only the 'Items' portion of the information in /catalog.json
  • /catalog/tags.json
    • Shows only the 'Tags' portion of the information in /catalog.json
  • /catalog/tags/view/<tag_name>.json
    • Shows information for the tag with name <tag_name>
  • /catalog/items/view/<item_name>-<int:item_id>.json
    • Shows information for the tag with the specified name and id

Atom Feed

An atom feed of the latest items can be accessed at /catalog/recent.atom .

Logging

Creation, deletion and editing of tags and items is recorded in a log file, configured by default as catalog.log in $repo/vagrant/catalog/.

Third-party code

About

A web application completed as Project 3 of the Udacity Full Stack Web Developer Nanodegree; provides a list of items within a variety of categories as well as providing a user registration and authentication system

Resources

Stars

Watchers

Forks

Packages

No packages published