Skip to content

Commit 952c526

Browse files
author
sbmsr
committed
init commit
0 parents  commit 952c526

24 files changed

+894
-0
lines changed

.github/workflows/main.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: JobSimulator.dev Test Checker
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the "main" branch
6+
push:
7+
branches: ["main"]
8+
pull_request:
9+
branches: ["main"]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# This workflow contains a single job called "build"
17+
test:
18+
# The type of runner that the job will run on
19+
runs-on: ubuntu-latest
20+
21+
# Steps represent a sequence of tasks that will be executed as part of the job
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-python@v4
25+
with:
26+
python-version: 3.11
27+
- run: pip install -r requirements.txt
28+
- run: python manage.py test

.gitignore

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3-journal
62+
63+
# Flask stuff:
64+
instance/
65+
.webassets-cache
66+
67+
# Scrapy stuff:
68+
.scrapy
69+
70+
# Sphinx documentation
71+
docs/_build/
72+
73+
# PyBuilder
74+
.pybuilder/
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
# For a library or package, you might want to ignore these files since the code is
86+
# intended to run in multiple environments; otherwise, check them in:
87+
# .python-version
88+
89+
# pipenv
90+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
91+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
92+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
93+
# install all needed dependencies.
94+
#Pipfile.lock
95+
96+
# poetry
97+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
98+
# This is especially recommended for binary packages to ensure reproducibility, and is more
99+
# commonly ignored for libraries.
100+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
101+
#poetry.lock
102+
103+
# pdm
104+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
105+
#pdm.lock
106+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
107+
# in version control.
108+
# https://pdm.fming.dev/#use-with-ide
109+
.pdm.toml
110+
111+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
112+
__pypackages__/
113+
114+
# Celery stuff
115+
celerybeat-schedule
116+
celerybeat.pid
117+
118+
# SageMath parsed files
119+
*.sage.py
120+
121+
# Environments
122+
.env
123+
.venv
124+
env/
125+
venv/
126+
ENV/
127+
env.bak/
128+
venv.bak/
129+
130+
# Spyder project settings
131+
.spyderproject
132+
.spyproject
133+
134+
# Rope project settings
135+
.ropeproject
136+
137+
# mkdocs documentation
138+
/site
139+
140+
# mypy
141+
.mypy_cache/
142+
.dmypy.json
143+
dmypy.json
144+
145+
# Pyre type checker
146+
.pyre/
147+
148+
# pytype static type analyzer
149+
.pytype/
150+
151+
# Cython debug symbols
152+
cython_debug/
153+
154+
# PyCharm
155+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
156+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
157+
# and can be added to the global gitignore or merged into this file. For a more nuclear
158+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
159+
.idea/
160+

LICENSE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# License
2+
3+
This project is licensed under the [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-nc-sa/4.0/).
4+
5+
It basically means you can do whatever you want with it as long as it's for non-commercial use but you've got to attribute the original author ([sbmsr](http://github.com/sbmsr)) and share any derivative works under the same license.
6+
7+
If you're interested in using our projects for commercial purposes or otherwise licensing material, feel free to get in touch at [[email protected]](mailto:[email protected]).

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
![](./image.svg)
2+
3+
# django-rest-backend by Jobsimulator.dev
4+
5+
This is an Django-based Pokémon REST API based on PokeAPI. Your job is to fix 5 issues:
6+
7+
1. Update `/pokemon` endpoint to include a Pokémon's type.
8+
1. Implement Get Pokémon by ID
9+
1. Implement Get Pokémon by Name
10+
1. Implement Get Pokémon by Type
11+
1. Implement Get Pokémon by HP (with Query Params)
12+
1. Update all endpoints to return Japanese and Chinese characters
13+
14+
Please refer to the API Swagger documentation for clear specifications of the API's intended behavior. You can find the Swagger docs at http://localhost:3000/api-docs.
15+
16+
Once you create a pull request with your changes, our automated test runner will validate your code to check if it is correct. No need for manual review!
17+
18+
## Learning Objectives
19+
20+
You will learn and gain experience with:
21+
22+
- [Django Rest Framework](https://www.django-rest-framework.org/)
23+
- [Django Models](https://docs.djangoproject.com/en/4.1/topics/db/models/)
24+
- [Django Views](https://docs.djangoproject.com/en/4.1/topics/http/views/)
25+
- [Django Serializers](https://www.django-rest-framework.org/api-guide/serializers/)
26+
- [Filtering](https://www.django-rest-framework.org/api-guide/filtering/)
27+
- [HTTP Status Codes](https://www.django-rest-framework.org/api-guide/status-codes)
28+
- [RESTful API Design](https://restfulapi.net/)
29+
30+
## How to start working
31+
32+
1. Fork this repo and clone it locally.
33+
1. enter `src` directory and run `npm install` to install dependencies.
34+
1. run `npm start` to start the development server.
35+
1. Open src/app.js in your IDE to start exploring the codebase.
36+
1. Open http://localhost:3000/api-docs to view the Swagger docs. This is where you can find the API specifications.
37+
1. Fix all the issues (hints are provided as TODO comments in the code)
38+
1. Once all your solutions are complete, create a single Pull Request to this repository
39+
1. Check if your solutions passes our automated tests.
40+
41+
## Need help?
42+
43+
The best way to ask for help is to ask our Discord community.
44+
45+
[Click here to join the Jobsimulator.dev Discord](https://discord.gg/6VsSMZaM7q).
46+
47+
## Want more challenges?
48+
49+
Browse our [list of challenges](https://jobsimulator.gumroad.com/) and [join our Discord](https://discord.gg/6VsSMZaM7q) to get notified when new challenges are released.

db.sqlite3

252 KB
Binary file not shown.

fixture.json

+1
Large diffs are not rendered by default.

identifier.sqlite

Whitespace-only changes.

jobsimulator_pokemon_api/__init__.py

Whitespace-only changes.

jobsimulator_pokemon_api/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for jobsimulator_pokemon_api project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jobsimulator_pokemon_api.settings')
15+
16+
application = get_asgi_application()

jobsimulator_pokemon_api/settings.py

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
"""
2+
Django settings for jobsimulator_pokemon_api project.
3+
4+
Generated by 'django-admin startproject' using Django 4.1.3.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/4.1/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = 'django-insecure-a&1%jwaaxl*-&#w10-*3-uh&m-)0p&-@)v7l27kg^hk&rwg+i='
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
'rest_framework',
41+
'pokemon'
42+
]
43+
44+
MIDDLEWARE = [
45+
'django.middleware.security.SecurityMiddleware',
46+
'django.contrib.sessions.middleware.SessionMiddleware',
47+
'django.middleware.common.CommonMiddleware',
48+
'django.middleware.csrf.CsrfViewMiddleware',
49+
'django.contrib.auth.middleware.AuthenticationMiddleware',
50+
'django.contrib.messages.middleware.MessageMiddleware',
51+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
52+
]
53+
54+
ROOT_URLCONF = 'jobsimulator_pokemon_api.urls'
55+
56+
TEMPLATES = [
57+
{
58+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
59+
'DIRS': [],
60+
'APP_DIRS': True,
61+
'OPTIONS': {
62+
'context_processors': [
63+
'django.template.context_processors.debug',
64+
'django.template.context_processors.request',
65+
'django.contrib.auth.context_processors.auth',
66+
'django.contrib.messages.context_processors.messages',
67+
],
68+
},
69+
},
70+
]
71+
72+
WSGI_APPLICATION = 'jobsimulator_pokemon_api.wsgi.application'
73+
74+
75+
# Database
76+
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
77+
78+
DATABASES = {
79+
'default': {
80+
'ENGINE': 'django.db.backends.sqlite3',
81+
'NAME': BASE_DIR / 'db.sqlite3',
82+
}
83+
}
84+
85+
86+
# Password validation
87+
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
88+
89+
AUTH_PASSWORD_VALIDATORS = [
90+
{
91+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
92+
},
93+
{
94+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
95+
},
96+
{
97+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
98+
},
99+
{
100+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
101+
},
102+
]
103+
104+
105+
# Internationalization
106+
# https://docs.djangoproject.com/en/4.1/topics/i18n/
107+
108+
LANGUAGE_CODE = 'en-us'
109+
110+
TIME_ZONE = 'UTC'
111+
112+
USE_I18N = True
113+
114+
USE_TZ = True
115+
116+
117+
# Static files (CSS, JavaScript, Images)
118+
# https://docs.djangoproject.com/en/4.1/howto/static-files/
119+
120+
STATIC_URL = 'static/'
121+
122+
# Default primary key field type
123+
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
124+
125+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

0 commit comments

Comments
 (0)