Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 97 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Welcome!

Hi! this your determinant test for the position of Django backend developer at **LibertyAssured**. If you have any issues, you can read this docs or also contact Lolu for further clarification.
Hi! this your determinant test for the position of Django backend developer at **LibertyAssured**. If you have any issues, you can read this docs or also contact Lolu for further clarification.

## Overview

## Overview

For this exercise you will be cover some basic concepts of web development and production ready deployment and you will hence be tested in the following basic concepts.
For this exercise you will be cover some basic concepts of web development and production ready deployment and you will hence be tested in the following basic concepts.

- Django and Django query-sets
- PostgreSQL Setup and connection to Django
- Cloud deployment
- PEP guidelines, conformity and quality of code
- PEP guidelines, conformity and quality of code
- General understanding of the python programming language.

## Test Rundown
Expand All @@ -21,76 +20,76 @@ You will be required to fork this repository into your personal account and then

After completing stage the process in in the rundown, please create branch for your self, please make sure to name the the branch with the following convention **\<yourname>/update**, and also all commits to your branch should carry a message in the following format **\<ACTIVITY>[Activity details]**.

- A sample branch name would be **paul/update**, and.,
- A sample branch name would be **paul/update**, and.,
- A sample commit message would be **FIX[ADDED CORS CONTROL]**

## Task Description

You are required to extend a skeleton application to such that it can recreate or conform to the responses which you would be seeing below.
**----------------**

- Request -> register (Create User account)

```yaml
{
"email":"teiker@libertymail.com",
"username":"way2teiker",
"password":"Solarizedgowns",
"email": "teiker@libertymail.com",
"username": "way2teiker",
"password": "Solarizedgowns",
}
```
- Response ->

- Response ->

```yaml
{
"message": "Created user successfully",
"username": "way2teiker",
"status-code": 200
"message": "Created user successfully",
"username": "way2teiker",
"status-code": 200,
}
```

```
**---------------------**

- Request -> get_all_coins (Get and display all coins)
- Response ->
- Response ->

```yaml
[{
"name": "BTC",
"USD-PRICE": "42,3529",
"volume": "19,331,340"
},
{
"name": "SAND",
"USD-PRICE": "100",
"volume": "19,331,340,302"
},
{
"name": "ETH",
"USD-PRICE": "4,356",
"volume": "199,331,340"
}
[
{ "name": "BTC", "USD-PRICE": "42,3529", "volume": "19,331,340" },
{ "name": "SAND", "USD-PRICE": "100", "volume": "19,331,340,302" },
{ "name": "ETH", "USD-PRICE": "4,356", "volume": "199,331,340" },
]
```
```

**---------------------**

- Request -> add_favourite (Add favourite coins to username)

```yaml
{
"username":"way2teiker",
"favourite":"USDT",
}
{ "username": "way2teiker", "favourite": "USDT" }
```
- Response ->

- Response ->

```yaml
{
"message": "Added USDT to Favourite successfully",
"username": "way2teiker",
"coin-name": "USDT",
"status-code": 200
"message": "Added USDT to Favourite successfully",
"username": "way2teiker",
"coin-name": "USDT",
"status-code": 200,
}
```
```

**---------------------**

- Request -> view_favourites (Add favourite coins to username)

```yaml
{
"username":"way2teiker"
}
{ "username": "way2teiker" }
```
- Response ->

- Response ->

```yaml
{"message":"Welcome back way2teiker thanks for using our platform",
"subscribed_favourites": [
Expand All @@ -109,19 +108,67 @@ You are required to extend a skeleton application to such that it can recreate o
"USD-PRICE": "4,356",
"volume": "199,331,340"
}
]
```
** **---------------------** **
]
```

\*\* **---------------------** \*\*

## Resources for task

Please register on https://docs.coinapi.io/?python#exchange-rates for free and get an api-key for your use.
Once this is done you can use their API docs for the propagation of your task.

**Finally**
You have been provided with a virtual machine IP address hosted on Digital Ocean please host your project appropriately using NGINX, GUNICORN and POSTGRESQL (as database). A password for the droplet will be provided.
You have been provided with a virtual machine IP address hosted on Digital Ocean please host your project appropriately using NGINX, GUNICORN and POSTGRESQL (as database). A password for the droplet will be provided.

- Please add your postman link to the above created endpoints for review.
- Also note that you can ignore the Docker and CI/CD instantiations on the application.

### Good luck, as we look forward to working with you at Liberty Assured in building amazing projects and relationships.
### Good luck, as we look forward to working with you at Liberty Assured in building amazing projects and relationships.

## Installation and Setup

- **Note:** Run the command with git bash on Windows OS

1. Clone the repository.
```bash
git clone https://github.com/dprograma/Backend-Test
```
2. Create a virtual environment
```bash
python3 -m venv venv
```
3. Activate the virtual environment
```bash
source venv/bin/activate # for Mac/Linux
venv\Scripts\activate # for Windows CMD
source venv/Scripts/activate # git bash on Windows
```
4. Install the required packages:
```bash
pip install -r requirements.txt
```
5. Change directory to django app directory
```bash
cd app
```
6. Make bash file for static validation executable
```
chmod +x static_validation.sh
```
7. Set Django Settings Module for Development
```bash
export DJANGO_SETTINGS_MODULE=app.dev
```
8. Run static validation (black, isort, migration, pylint, mypy, test)
```bash
./static_validation.sh
```
9. Populate coin data into database
```bash
python manage.py fetch_coin_data
```
10. Run the development server:
```bash
python manage.py runserver
```
12 changes: 12 additions & 0 deletions app/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[settings]
line_length = 100
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
skip_glob = **/migrations/*.py

[django]
known_django = django
known_third_party = rest_framework
47 changes: 47 additions & 0 deletions app/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[MASTER]

# Specify additional Python builtins
extension-pkg-whitelist = _tkinter

[MESSAGES CONTROL]

# Enable or disable specific message categories
disable =
missing-docstring,
invalid-name,
unused-import,
logging-fstring-interpolation,
too-few-public-methods,
too-many-ancestors,
no-member,
unused-argument,
duplicate-code,
no-value-for-parameter,
line-too-long


[BASIC]

# Specify the maximum line length
max-line-length = 120

[VARIABLES]

# Define a list of additional names considered predefined
additional-builtins = _

[FORMAT]


[TYPECHECK]

# Enable type checking using Mypy
# init-hook = 'import sys; sys.path.append("."); import mypy; mypy.patch_builtin_type_checkers()'
generated-members = signals
ignored-modules = core/migrations

[DESIGN]

# Specify the maximum number of instance attributes allowed
max-attributes = 12

2 changes: 1 addition & 1 deletion app/app/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.prod')

application = get_asgi_application()
47 changes: 26 additions & 21 deletions app/app/settings.py → app/app/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""

import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand All @@ -20,13 +20,7 @@
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-h-h69cr05lmc*w4vtkf+5qltg8#&#xf8fe(v9j9oxs-*-^#vjd'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

SECRET_KEY = 'NOSECRETKEY'

# Application definition

Expand All @@ -37,12 +31,15 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core'
'core',
'rest_framework',
'corsheaders',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
Expand Down Expand Up @@ -71,17 +68,6 @@
WSGI_APPLICATION = 'app.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators

Expand Down Expand Up @@ -123,4 +109,23 @@

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

AUTH_USER_MODEL = 'core.User'
AUTH_USER_MODEL = 'core.User'

REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
]
}

CORS_ALLOW_ALL_ORIGINS = True

CORS_ALLOW_METHODS = (
"DELETE",
"GET",
"OPTIONS",
"PATCH",
"POST",
"PUT",
)
22 changes: 22 additions & 0 deletions app/app/dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from .base import *

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-h-h69cr05lmc*w4vtkf+5qltg8#&#xf8fe(v9j9oxs-*-^#vjd'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ["*"]


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}


Loading