Skip to content

She Codes Project: A platform for people to fund projects that they believe in

Notifications You must be signed in to change notification settings

rosiejeays/Django-crowd-funding-project

Repository files navigation

Contributors Forks Stargazers Issues LinkedIn


Logo

Advocat

by Rosie Maguire
She Codes crowdfunding project - DRF Backend.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Features
  3. Getting Started
  4. Usage
  5. Contributing
  6. Contact

About The Project

This project is the back end of a crowdfunding website which has been created to support people with raising funds for their furry children's medical expenses. You can find the front end repository here.

(back to top)

Built With

Django

(back to top)

Features

  • User Log in/Out
  • Project creation (must be logged in user)
  • Project owner can update project
  • Pledge creation (must be logged in as user)
  • Pledge supporter can update pledge
  • Pledges able to be created without comment (optional field)
  • User able to update own details (and Admins able to update any user's details)
  • Created date field for projects and pledges are automatically set based on when the pledge/project was created
  • Last modified date for projects and pledges are automatically updated with each PUT request

Stretch Goals and Roadmap

  • Pledge put request does not allow any modification of which project it is attached to
  • Pledges cannot be created or modified for projects that are set to closed
  • Project owner only able to update open/closed and deleted field if project has been set to closed
  • Users able to "soft delete" projects and pledges they own (e.g. set deleted field to 1 which hides in front end) own pledges/projects
  • Put restrictions around user creation
  • Validation to ensure at least one field is modified in PUT Request (rather than just updating the last_modified date because PUT request fields are identical to data in table)

See the open issues for a full list of proposed features (and known issues).

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Deployed Project: Deployed website

Prerequisites

  • python
  • pip
  • unrestricted execution policy (Windows requirement)

Installation

  • Clone a copy of this repo to your local machine. This can be done in the command line by navigating to the desired directory, then running:

      git clone https://github.com/rosiemaguire/Django-crowd-funding-project.git
    
  • Once you have a local version of this repository, you'll need to set up your virtual environment:

    • navigate to the folder that contains the requirements.txt file

    • If you're on a windows machine, run the command . venv/Scripts/activate

    • If you're on a mac, run the command source venv/bin/activate

    • Install the Django library: python -m pip install -r requirements.txt

    • Check installation was successful:

        python -m pip freeze
      
    • Change directory to where manage.py is located: cd crowdfunding

    • Make the inital migrations:

        python manage.py migrate
      
    • Now with everything set up, you'll just need to run the server!

        python manage.py runserver
      
    • Use the url http://127.0.0.1:8000/, your favourite API Tool (e.g. Insomnia, Postman) and refer to the API Specifications to create HTTP requests

    • When you're finished press CTRL+C to quit the server

    • Deactivate the virtual environment by either using the command deactivate or terminate your terminal session.

Database Schema

Database Schema

API Specification

HTTP Method Url Purpose Request Body Successful Response Code Authentication
Authorization
GET projects/ Return all projects N/A 200 N/A
GET pledges/ Return all pledges N/A 200 N/A
GET users/ Return all users N/A 200 Bearer Token authentication.
Administrator user can view list of all users. Non administrator user will only return own user object.
POST projects/ Create a new project project object 201 Bearer Token authentication.
User must be logged in.
POST pledges/ Create a new pledge pledge object 201 Bearer Token authentication.
User must be logged in.
POST users/ Create a new user user object 201 N/A
POST api-token-auth/ Obtain Bearer Token for Authorisation username and password 200 N/A
PUT projects/< int:pk >/ Update project project object or project field 201 Bearer Token authentication.
User must be logged in.
Must be the owner of the project.
PUT pledges/< int:pk >/ Update pledge pledge object or pledge field 201 Bearer Token authentication.
User must be logged in.
Must be the owner of the pledge.
PUT users/< int:pk >/ Update user user object or user field 201 Bearer Token authentication.
User must be logged in.
Must be the user that is being updated or a user with Administrator permissions.
DEL projects/< int:pk >/ Delete Project N/A 204 Bearer Token authentication.
User must be logged in.
Must be a user with Administrator permissions.
DEL projects/< int:pk >/ Delete Project N/A 204 Bearer Token authentication.
User must be logged in as administrator.

(back to top)

Usage

Creating a user

  • Create a new HTTP Request in your favourite API Tool (e.g. Postman, Insomnia)

  • Choose the POST method

  • Change the body type to JSON

    • Minimum fields required to create a new user:

      • username
      • password
    • Example request body:

        {
          "username": "janedoe",
          "password": "strongrandompassword",
          "email": "[email protected]"
        }
      
  • A successful request will return a 200 response and return the user object

        {
          "username": "janedoe",
          "first_name": "",
          "last_name": "",
          "email": "[email protected]",
          "date_joined": "2023-08-12T12:45:29.767395+10:00"
        }
    

Logging In (Obtain the bearer token)

  • Create a new HTTP POST Request using the endpoint https://advocat.fly.dev/api-token-auth/

  • Change the body type to JSON

  • Provide the username and password in the body

    • Example request body:

        {
          "username": "janedoe",
          "password": "strongrandompassword"
        }
      
  • A successful request will return a 200 response along with the token you will need to make requests that require authentication

        {
          "token": "c07f7a567c5f29db440bfbd2846b97ffe34f0088"
        }
    

Creating a project

  • Create a new HTTP POST Request using the endpoint https://advocat.fly.dev/projects/

  • Change the body type to JSON

    • Minimum fields required:

      • title
      • description
      • goal
    • Example request body:

        {
          "title": "Test Project",
          "description": "This is a test project",
          "goal": 150,
          "image": "https://picsum.photos/600",
          "is_open": true
        }
      
  • A successful request will return a 201 response and the project object just created

      {
        "id": 1,
        "owner": "admin",
        "title": "Test Project",
        "description": "This is a test project",
        "goal": 150,
        "image": "https://picsum.photos/600",
        "is_open": true,
        "date_created": "2023-08-12T14:58:21.824004+10:00",
        "last_modified": "2023-08-12T14:58:21.824028+10:00"
      }
    

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Contact

Rosie Maguire - @rosie_maguire

Project Link: https://github.com/rosiemaguire/Django-crowd-funding-project

(back to top)

About

She Codes Project: A platform for people to fund projects that they believe in

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published