GithubHelp home page GithubHelp logo

api_yamdb-1's Introduction

api_yamdb

This project I've created during the course with the toy team of two developers. As a toy teamlead I described and separated tasks between developers, made architectural decision and defended the project during review. About 50% of code is written by me. I fully wrote users app, but I also contributed a lot to api app.

Project contains three apps: reviews, api, users. reviews app implement models, api app implements access to models via api, users app implements all the logic that needed for user management and access: permissions, singup and token endpoints. Full description of endpoints and queries are available on /redoc/

Run application locally

Create and activate virtual enviroment In /api_yamdb/api_yamdb/ run commands:

pip install -r requirements.txt
python manage.py migrate
python manage.py runserver

users app

It the application implemented extended user model, permissions and API to users management for users as well as for admins.

Roles

  • Anonim — can get titles decriptions, reviews and comments
  • Authenticated user (user) — as well as Anonim can get all and additionally can publish reviews and scores to titles, can comment another reviews. This role is granted by default
  • Moderator — has same rights with authenticated user and additionally can delete any reviews and comments
  • Admin — has full rights to manage a content. Can created and delete titles, cateogries, genres, can manage other users
  • Django Superusers — has same rights with admin, but role can't be changed

Endpoints

  • /auth/singup/ — sign up new user
  • /auth/token/ — retrieve token

Sign up and authentication algorithm:

  1. User sends an email and user name using POST
  2. Default Django PasswordResetTokenGenerator generates token, that sends to user's email. This token is required to retrieve JWT-token that is needed to send queries to base endpoints
  3. The user sends username and token given on email using 'confirmation_code' field using POST and retrieves JWT-token if data is valid
  • /users/ — users collection, handles all queries except PUT
  • /users/me/ — endpoint for getting and managing data about yourself

reviews app

Models

The app implements models for API:

  • Category - categories (types) of titles (ex: "Film", "Book", "Music");
  • Genre - genres of titles, one title might be related with few genres;
  • Title - specified titles, to which users write reviews (to film, book, song);
  • Review - reviews to titles;
  • Comment - comments to reviews;
  • GenreTitle - additional model for implementing Title-Genre many-to-many relationship;

Test data uploading

In the directory /api_yamdb/static/data are prepared .csv files with the test data could be used for resources To upload test data run following command:

py manage.py convert_csv_to_sqlite

api_yamdb-1's People

Contributors

bogdanburich avatar mollador avatar seryojka-dev avatar vitspaceone avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.