Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7cdaa76
Started lab 6 pokedex rest framework
rayk472 Sep 2, 2022
2c743ae
Django rest framework
rayk472 Sep 3, 2022
7ad2dc1
Working on Pokedex app
rayk472 Sep 10, 2022
c728e5b
Working on Pokedex optional lab
rayk472 Sep 10, 2022
d7bb579
Working on settings for Pokedex
rayk472 Sep 10, 2022
083cefb
Mob coding Pokedex API
rayk472 Sep 13, 2022
a7c203b
Merge branch 'main' of https://github.com/PdxCodeGuild/class_HB2 into…
rayk472 Sep 13, 2022
9c9ae81
Merge branch 'main' of https://github.com/PdxCodeGuild/class_HB2 into…
rayk472 Sep 13, 2022
ad69c88
Working on stylizing Pokedex from mob code
rayk472 Sep 13, 2022
d28fefa
Fixed Json serializer file in Pokedex
rayk472 Sep 13, 2022
1fd21ef
Added Vue app to Pokedex
rayk472 Sep 27, 2022
811079d
Merge branch 'main' of https://github.com/PdxCodeGuild/class_HB2 into…
rayk472 Sep 27, 2022
1f677b1
Started Vue app in Pokedex
rayk472 Sep 27, 2022
2b82e21
Working on Axios API call
rayk472 Sep 28, 2022
513e7d5
Added Permissions to API call
rayk472 Sep 28, 2022
b773cb6
Adding user views to API
rayk472 Sep 29, 2022
dbd6349
Started over with fresh Pokedex project
rayk472 Sep 29, 2022
69ec383
Loaded Pokemon in database and worked on html
rayk472 Sep 30, 2022
943abd3
Working on profile page for Vue app
rayk472 Oct 4, 2022
608a17a
Working Axios loading Pokemon
rayk472 Oct 4, 2022
e67ef8a
Working on displaying random pokemon
rayk472 Oct 11, 2022
6a47aa4
Pokedex can load random Pokemon
rayk472 Oct 11, 2022
4bf1a16
Pokedex loads random Poke and image
rayk472 Oct 12, 2022
b253cee
Working Pokedex with search
rayk472 Oct 12, 2022
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
11 changes: 11 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.9"
20 changes: 20 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from rest_framework import serializers
from pokemon.models import Pokemon, PokemonType

class NestedTypeSerializer(serializers.ModelSerializer):
class Meta:
fields = ('name',)
model = PokemonType

class PokemonSerializer(serializers.ModelSerializer):
type_info = NestedTypeSerializer(many=True, source='types')
class Meta:
fields = ('number', 'name', 'height', 'weight', 'image_front', 'image_back', 'type_info', 'id')
model = Pokemon

class TypeSerializer(serializers.ModelSerializer):
class Meta:
fields = ('name',)
model = PokemonType
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
12 changes: 12 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.urls import path
from rest_framework.routers import DefaultRouter

from .views import PokemonViewSet, TypeViewSet

router = DefaultRouter()
router.register('pokemon', PokemonViewSet, basename='pokemon')
router.register('types', TypeViewSet, basename='types')

urlpatterns = router.urls + [

]
11 changes: 11 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from rest_framework import viewsets
from pokemon.models import Pokemon, PokemonType
from .serializers import PokemonSerializer, TypeSerializer

class PokemonViewSet(viewsets.ModelViewSet):
queryset = Pokemon.objects.all()
serializer_class = PokemonSerializer

class TypeViewSet(viewsets.ModelViewSet):
queryset = PokemonType.objects.all()
serializer_class = TypeSerializer
22 changes: 22 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pokedex.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Empty file.
16 changes: 16 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/pokedex/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for pokedex project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pokedex.settings')

application = get_asgi_application()
145 changes: 145 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/pokedex/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
"""
Django settings for pokedex project.

Generated by 'django-admin startproject' using Django 4.1.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-b@#5$phv@fg9blgg+7ig3g=%)z5_r@!sx66e+35%y#jp@j&^&='

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admindocs',
'rest_framework',
'api.apps.ApiConfig',
'users.apps.UsersConfig',
'pokemon.apps.PokemonConfig',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'pokedex.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'pokedex.wsgi.application'


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

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


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

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/

STATIC_URL = 'static/'
STATIC_DIR = [os.path.join(BASE_DIR, 'static')]

LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)

MEDIA_ROOT = [os.path.join(BASE_DIR, 'media')]
MEDIA_URL = '/media/'

REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.AllowAny',
]
}
26 changes: 26 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/pokedex/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""pokedex URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.views.generic import TemplateView

urlpatterns = [
path('admin/doc/', include('django.contrib.admindocs.urls')),
path('admin/', admin.site.urls),
path('', TemplateView.as_view(template_name='index.html'), name='index'),
path('u/', include('users.urls')),
path('api/', include('api.urls')),
]
16 changes: 16 additions & 0 deletions code/kelin/labs/django_labs/lab06_pokedex/pokedex/pokedex/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for pokedex project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pokedex.settings')

application = get_wsgi_application()
Loading