Skip to content

To track corporate assets such as phones, tablets, laptops and other gears handed out to employees.

Notifications You must be signed in to change notification settings

masum035/Corporate_Asset_Tracker_Django_REST_API

Repository files navigation

Project Name: Corporate Asset Tracker

App name: Asset Tracker

Project Description:

  1. To track corporate assets such as phones, tablets, laptops and other gears handed out to employees.
  2. The application might be used by several companies
  3. Each company might add all or some of its employees
  4. Each company and its staff might delegate one or more devices to employees for a certain period of time
  5. Each company should be able to see when a Device was checked out and returned
  6. Each device should have a log of what condition it was handed out and returned

Project Features:

I have Created a new virtual environment for this project and installed the required packages, which i have shared in requirements.txt file.
I have used Django Rest Framework for creating the API's.
I have used SQLITE3 database for this project.
I have used Django ORM for database operations.
I have used Django Admin for creating the admin panel.
I have used Django Serializer for creating the serializers.
I have used Django Rest Framework Spectacular for creating the API documentation.
I have used Django Rest Framework Simple JWT for creating the token based authentication.
I have used python coverage for creating the coverage report.
I have used Pytest for creating the tests.
I have used Pytest Factoryboy for creating the factories for Testing.
I have used Bootstrap Admin for creating the admin dashboard.
I have used Postman & swagger for testing the API's.

Steps to run the project:

  1. Clone the project from the git repository. Even you can download the zip file from the git repository. (For your ease: I have included .env file)
  2. Create a virtual environment and activate it.
  3. Install the required packages from requirements.txt file.
  4. Run the following commands:
    • py manage.py makemigrations
    • py manage.py migrate --run-syncdb
    • py manage.py loaddata datadump.json
    • py manage.py createsuperuser
    • py manage.py collectstatic
    • py manage.py runserver
  5. Open the browser and hit the following url for performing API testing in swagger:
  6. Now, you have to authenticate yourself before doing any operation. To do that, hit the token endpoint and pass the username and password in the body. You will get a refresh token & access token in the response. Copy the access token and paste it in the authorize section of swagger. Now, you can perform any operation.
  7. You can also see the admin dashboard using the following url:
  8. Also, you can login to the admin panel using the following / superuser credentials & perform any database operation using my cool admin dashboard panel:
  9. You can also run the tests using the following command:
    • pytest
  10. You can also see the coverage report using the following command and open the htmlcov folder & open the index.html file:
    • coverage html
  11. You can also see the API documentation using the following url:

Database Schema:

This implementation has 4 main models: Company, Device, Employee, and DeviceAssignment.

  1. Company stores information about the companies using the app.
  2. Device represents the corporate assets, with information such as their name, description, serial number, condition, and which company they belong to.
  3. Employee represents the company's staff, with a one-to-one relationship to a Django user and a many-to-many relationship with the Device model, through the DeviceAssignment model.
  4. DeviceAssignment represents the assignments of devices to employees, with a foreign key to both the Device and Employee models, as well as the assignment and return dates.

Project Commands:

For Future Use (Geeky Stuff):
  • For secret key generation:
python manage.py shell
from django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
exit()
  • For Dumping the data:
python3 manage.py dumpdata > datadump.json
  • For secret key storing:
pip install python-dotenv
  • For Rest Framework Support:
pip install djangorestframework
pip install markdown
pip install django-filter
  • For API Documentation:
pip install drf-spectacular
py manage.py spectacular --color --file schema.yml
  • For Testing:
pip install coverage
coverage run -m pytest
coverage html
pip install pytest
pip install pytest-django
pytest -h
pip install pytest-factoryboy
  • For superuser creation:
py manage.py makemigrations
py manage.py migrate
python manage.py createsuperuser
py manage.py runserver
  • For Token Based Authentication:
pip install djangorestframework_simplejwt
  • For Django Admin Dashboard:
pip install bootstrap-admin
  • For Database Data Storing:
py manage.py dumpdata > datadump.json
py manage.py loaddata datadump.json

About

To track corporate assets such as phones, tablets, laptops and other gears handed out to employees.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published