Momentum logo
Team 12 Classroom

🐻 Search & Automatic Deploys 🐻

Posted on Jun 6th, 2022

Today’s Topics

  • Implementing search, including Postgres full-text search

🎯 Project due on Thursday afternoon

Please include a README in your project repo. The README should be:

  • written in Markdown
  • include a link to your production application
  • shave instructions for getting your application running locally, so that any developer could pull it down and run it. If your setup makes any assumptions about the environment (e.g., you have Python 3.10.2 installed locally), you should state them in the README.

Your README should include documentation for your API’s available endpoints.

πŸ‘‰ If your project meets minimum requirements today, HUZZAH! That is awesome. You should be working on at least one additional or spicy feature.

πŸ‘‰ If your project does not yet meet minimum requirements, you should aim for meeting them by the end of the day Wednesday.

Note

Depending on how you’ve constructed your API, you might have separate endpoints for all of the below, or you might have fewer endpoints (for instance, if you nested answers in the question detail endpoint, like questions/4/answers). What matters is that you have endpoints that your front-end team can use to access this data, and they are documented in your README.

Requirements for QuestionBox, Back End

⚠️ Be sure to test that you have implemented permissions-checking correctly for these endpoints. For example, your API should not allow a user who is not the question-asker to mark an answer as accepted.

  • token login, logout, and register (i.e., create a new user)
  • list all questions
  • list answers to a specific question
  • show details about a specific question
  • create a question if logged in
  • create an answer to a question (if you are not the question owner) if logged in
  • mark an answer as β€œaccepted” (if you are the question owner)
  • list of own questions for an authenticated user
  • list of own answers for an authenticated user
  • star/favorite questions or answers
  • unstar/unfavorite questions or answers
  • search questions (possibly both questions and answers)
  • A README with endpoints documented

πŸ“– Read | πŸ“Ί Watch | 🎧 Listen

πŸ”– Resources

@action decorator in ViewSets

πŸ¦‰ Code & Notes

  • DRF Library API
  • Notes on Django Queries These are the same notes you may have seen at the beginning of the Phase. I’m including them here for easy reference, as they show examples of queries and filters that might come in handy for search endpoints.

🦊 URL Routing in React 🦊

Posted on Jun 2nd, 2022

Today’s topics

  • React Router
  • User log in
  • Using local storage with state to store an auth token

🎯 Project

You should have detailed wireframes and a user flow outline by now, and components for at least the initial β€œpage” your user is going to see when they arrive at your site. By tomorrow, you should be able to make requests for questions and answers. Deploy to Netlify as soon as possible (πŸ’‘ Your code needs to run locally with no errors before you can deploy it).

πŸ“– Read | πŸ“Ί Watch | 🎧 Listen

⚠️ These two resources are for older versions of React Router, so you will see some outdated syntax. For instance Switch, Redirect, and the component prop on Route exist only in versions of React Router earlier than version 6. However, the main concepts are the same, so these resources can still help you understand the context and usage of React Router.

πŸ”– Resources

πŸ‘Ύ Code

🐻 API Progress Check-In 🐻

Posted on Jun 2nd, 2022

πŸ—“οΈ Today’s Topics

  • How are the projects coming along? πŸ‘€
  • Automatic deploys from GitHub
  • Paginating your API

🎯 Project

Keep on going. πŸ’ͺ πŸš€

We will use class time today to get you past any blockers you may be experiencing and to talk through next steps.

By now you should have provided your front end with a way to log in and log out, and endpoints to see data. By tomorrow you should have the ability to POST data.

πŸ“– Read | πŸ“Ί Watch | 🎧 Listen

On Monday we’ll be covering full-text search in your API, but if you have time you can check these resources out in advance.

πŸ”– Resources

Heroku GitHub integration

Authentication

Make sure you are sharing the Djoser information with your front end. You should include the authentication endpoints in your API documentation or project README.

Creating a properly hashed password

In order to save a properly hashed password when you create a new user in the Django Admin, make sure you are using UserAdmin in admin.py so that you have that option in the admin interface. If you don’t do this and save an unhashed password, you will run into authentication errors.

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
...
admin.site.register(User, UserAdmin)

You can also change a password from the command line:

Pagination

πŸ‘Ύ Code

🦊 Authentication in a React App 🦊

Posted on Jun 1st, 2022

πŸ—“οΈ Today’s topics

  • Using Forms in React
  • Revisit β€œWhat is logged in?” in code
  • Requesting an auth token for login

🎯 Project

Work with your team to get the initial components in place for the QuestionBox or Social E-cards project.

By Friday

  • be able to make GET requests for questions and answers / cards and friends
  • show them on the page
  • have a solid start on POST requests
  • deploy to Netlify as soon as possible (TIP ⭐ Your code needs to run locally with no errors before you can deploy it!)

πŸ”– Resources