From 6cfa799919e1406486ae204f4a6214b71815ed54 Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Wed, 15 Nov 2017 13:43:12 -0600 Subject: [PATCH 01/11] Users - ORM --- .../users/main/apps/__init__.py | 0 .../users/main/apps/user_app/__init__.py | 0 .../users/main/apps/user_app/admin.py | 3 + .../users/main/apps/user_app/apps.py | 7 + .../apps/user_app/migrations/0001_initial.py | 28 ++++ .../main/apps/user_app/migrations/__init__.py | 0 .../users/main/apps/user_app/models.py | 15 +++ .../user_app/static/user_app/css/style.css | 0 .../user_app/templates/user_app/index.html | 0 .../users/main/apps/user_app/tests.py | 3 + .../users/main/apps/user_app/urls.py | 6 + .../users/main/apps/user_app/views.py | 6 + .../django_projects/users/main/db.sqlite3 | Bin 0 -> 135168 bytes .../users/main/main/__init__.py | 0 .../users/main/main/settings.py | 121 ++++++++++++++++++ .../django_projects/users/main/main/urls.py | 21 +++ .../django_projects/users/main/main/wsgi.py | 16 +++ .../django_projects/users/main/manage.py | 22 ++++ 18 files changed, 248 insertions(+) create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/admin.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/apps.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/migrations/0001_initial.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/migrations/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/models.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/static/user_app/css/style.css create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/templates/user_app/index.html create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/tests.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/urls.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/apps/user_app/views.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/db.sqlite3 create mode 100644 justin_quiros/python_stack/django_projects/users/main/main/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/main/settings.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/main/urls.py create mode 100644 justin_quiros/python_stack/django_projects/users/main/main/wsgi.py create mode 100755 justin_quiros/python_stack/django_projects/users/main/manage.py diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/__init__.py b/justin_quiros/python_stack/django_projects/users/main/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/__init__.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/admin.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/apps.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/apps.py new file mode 100644 index 0000000..660e43e --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class UserAppConfig(AppConfig): + name = 'user_app' diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/migrations/0001_initial.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/migrations/0001_initial.py new file mode 100644 index 0000000..222f3a6 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-15 19:12 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=255)), + ('last_name', models.CharField(max_length=255)), + ('email_address', models.CharField(max_length=255)), + ('age', models.IntegerField()), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/migrations/__init__.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/models.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/models.py new file mode 100644 index 0000000..20fbefd --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/models.py @@ -0,0 +1,15 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. +class User(models.Model): + first_name = models.CharField(max_length=255) + last_name = models.CharField(max_length=255) + email_address = models.CharField(max_length=255) + age = models.IntegerField() + created_at = models.DateTimeField(auto_now_add = True) + updated_at = models.DateTimeField(auto_now_add = True) + + def __unicode__(self): + return "id: " + str(self.id) + ", first_name: " + self.first_name + ", last_name: " + self.last_name \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/static/user_app/css/style.css b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/static/user_app/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/templates/user_app/index.html b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/templates/user_app/index.html new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/tests.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/urls.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/urls.py new file mode 100644 index 0000000..42b9825 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import url +from . import views # This line is new! + +urlpatterns = [ + url(r'^$', views.index), +] \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/users/main/apps/user_app/views.py b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/views.py new file mode 100644 index 0000000..b46365b --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/apps/user_app/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render, redirect + +# Create your views here. +def index(request): + + return render(request, 'user_app/index.html') \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/users/main/db.sqlite3 b/justin_quiros/python_stack/django_projects/users/main/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..ce4b4c267776c5cdb847002cb27f62f95c39deeb GIT binary patch literal 135168 zcmeI5du$s=e#dwDTD{1XB{Q4ERzyjs*sLsz%Oyq8z9eQGCehiJ6I({&qQzz215K}#i}X-5{o{a3?||aaqF1y?fj&@Nfwn>a2wF6M9dOs82ed^~6xVA}^Z~Re zuD}&VXJ&V~4=yF0pk8g?mw;9~Gr#%GZ$7`7*`0@|>#tv~b@bF$tKHB#DTN#7c%HkE zN^u+~lb;##V}G6}HxWBPe)F#TLANq@_Q{WH7oi(ZKrcf-7)mGT5Y#> zwhc9-7nP!x+wvzQFJ3E`*2}5YwU^3ore^)gy?nE&t84wqv#HawtN^uEnN4@O zKB1ltmw|mk)SXVbrca+bW*T^YF9SWTt55B*0~u)R*v~*yJ#+SzaY3pU`CVZz+iZC? zvsqEH`HhU@^FB+*2YbFx*6djXl2`G8%_r@^&pILs(sK)ZchRYjOC%>3w&V?YleGdT zUJRh?q^fo^n_5GkP4AwJ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FSgn>{Uz;g z&A4rDIGaD0TRxl3WpagrPqm$rUr}BU4RMnawfHkF{d%L;xy96KHKuaimytlo z5o=fS*<5f+Q7$a6^F!QICuS%Fz16PjpK0A{8m;E-+ZU>>7DfAnH!q=^Up~8%DHd`* MtyYSh$riK!3v-xh6#xJL literal 0 HcmV?d00001 diff --git a/justin_quiros/python_stack/django_projects/users/main/main/__init__.py b/justin_quiros/python_stack/django_projects/users/main/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/users/main/main/settings.py b/justin_quiros/python_stack/django_projects/users/main/main/settings.py new file mode 100644 index 0000000..67af856 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/main/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for main project. + +Generated by 'django-admin startproject' using Django 1.10. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'gdk30mdbjc%-*5sj!@nn1o7e8#u8te4*lspv5534)gn7%!%sao' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.user_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'main.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'main.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/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/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/justin_quiros/python_stack/django_projects/users/main/main/urls.py b/justin_quiros/python_stack/django_projects/users/main/main/urls.py new file mode 100644 index 0000000..27fc861 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/main/urls.py @@ -0,0 +1,21 @@ +"""main URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.user_app.urls')), +] diff --git a/justin_quiros/python_stack/django_projects/users/main/main/wsgi.py b/justin_quiros/python_stack/django_projects/users/main/main/wsgi.py new file mode 100644 index 0000000..4d1e3f4 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/main/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for main 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/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + +application = get_wsgi_application() diff --git a/justin_quiros/python_stack/django_projects/users/main/manage.py b/justin_quiros/python_stack/django_projects/users/main/manage.py new file mode 100755 index 0000000..ad5d3e7 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/users/main/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) From 9a3063073635c2fcd8aab8743c623164cd718d6e Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Wed, 15 Nov 2017 15:10:04 -0600 Subject: [PATCH 02/11] Dojo Ninjas --- .../dojo_ninjas/main/apps/__init__.py | 0 .../main/apps/dojo_app/__init__.py | 0 .../dojo_ninjas/main/apps/dojo_app/admin.py | 3 + .../dojo_ninjas/main/apps/dojo_app/apps.py | 7 + .../apps/dojo_app/migrations/0001_initial.py | 35 +++++ .../dojo_app/migrations/0002_dojo_desc.py | 20 +++ .../main/apps/dojo_app/migrations/__init__.py | 0 .../dojo_ninjas/main/apps/dojo_app/models.py | 22 ++++ .../dojo_app/static/dojo_app/css/style.css | 0 .../dojo_app/templates/dojo_app/index.html | 0 .../dojo_ninjas/main/apps/dojo_app/tests.py | 3 + .../dojo_ninjas/main/apps/dojo_app/urls.py | 6 + .../dojo_ninjas/main/apps/dojo_app/views.py | 9 ++ .../dojo_ninjas/main/db.sqlite3 | Bin 0 -> 147456 bytes .../dojo_ninjas/main/main/__init__.py | 0 .../dojo_ninjas/main/main/settings.py | 121 ++++++++++++++++++ .../dojo_ninjas/main/main/urls.py | 21 +++ .../dojo_ninjas/main/main/wsgi.py | 16 +++ .../dojo_ninjas/main/manage.py | 22 ++++ 19 files changed, 285 insertions(+) create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/admin.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/apps.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/0001_initial.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/0002_dojo_desc.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/models.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/static/dojo_app/css/style.css create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/templates/dojo_app/index.html create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/tests.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/urls.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/views.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/db.sqlite3 create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/settings.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/urls.py create mode 100644 justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/wsgi.py create mode 100755 justin_quiros/python_stack/django_projects/dojo_ninjas/main/manage.py diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/__init__.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/__init__.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/admin.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/apps.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/apps.py new file mode 100644 index 0000000..bdc48d8 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class DojoAppConfig(AppConfig): + name = 'dojo_app' diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/0001_initial.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/0001_initial.py new file mode 100644 index 0000000..f03fa99 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/0001_initial.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-15 20:13 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Dojo', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('city', models.CharField(max_length=255)), + ('state', models.CharField(max_length=2)), + ], + ), + migrations.CreateModel( + name='Ninja', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=255)), + ('last_name', models.CharField(max_length=255)), + ('dojo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ninjas', to='dojo_app.Dojo')), + ], + ), + ] diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/0002_dojo_desc.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/0002_dojo_desc.py new file mode 100644 index 0000000..25bb40d --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/0002_dojo_desc.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-15 21:07 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dojo_app', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='dojo', + name='desc', + field=models.TextField(null=True), + ), + ] diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/__init__.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/models.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/models.py new file mode 100644 index 0000000..eb2e4e8 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/models.py @@ -0,0 +1,22 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. +class Dojo(models.Model): + name = models.CharField(max_length=255) + city = models.CharField(max_length=255) + state = models.CharField(max_length=2) + desc = models.TextField(null = True) + def __unicode__(self): + return "id: " + str(self.id) + ", name: " + self.name + ", city: " + self.city + ", state:" + self.state + ", desc: " + str(self.desc) + + +class Ninja(models.Model): + first_name = models.CharField(max_length=255) + last_name = models.CharField(max_length=255) + + dojo = models.ForeignKey(Dojo, related_name = "ninjas") + + def __unicode__(self): + return "id: " + str(self.id) + ", first_name: " + self.first_name + ", last_name: " + self.last_name + ", dojo: " + str(self.dojo) \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/static/dojo_app/css/style.css b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/static/dojo_app/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/templates/dojo_app/index.html b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/templates/dojo_app/index.html new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/tests.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/urls.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/urls.py new file mode 100644 index 0000000..42b9825 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import url +from . import views # This line is new! + +urlpatterns = [ + url(r'^$', views.index), +] \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/views.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/views.py new file mode 100644 index 0000000..4a876c4 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/apps/dojo_app/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import render + +# Create your views here. +from django.shortcuts import render, redirect + +# Create your views here. +def index(request): + + return render(request, 'dojo_app/index.html') \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/db.sqlite3 b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..e6c93ccfb8dc940fe2ab928dd494761a72978587 GIT binary patch literal 147456 zcmeI5du$`eeaCmj$5Il>(c|RR`A*h~vU11hWRapMN_LzxEz@V^PCDlvag?OktjLwT zcN8g;)cG#0;ZRq&3EKSAA`kQtAVARq1(LKtQ?#goqy~aIEgIBq&;V`PxM+|*(*gm~ z7I6RQ%e{jHOF$#e%iaJl4PDu+*0!~Vk`V?3Q4}6i z6hRP{>EDC&uaEwTRy;`m+b@=O&}&(EX!O+(l@iGtO!g#sBR<^!{r(5~f2XfElI;B} zX)Zh*x*U8p@ZW)t^!#B@zxWB!UB*H7-<15OI3mgCXT;{DQ7P%SwcWTX@Hsav(` z?oM4z=}Vao*c0xIu;035gDUoanCrlqE z{C&_DbE&jen)eoR;s76Pz3x8nnsOIrh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H?xfB*=*eFQ=QQIw)Q?B`)0 z3&XuUjPOumVJOVQ5D$Yq4Dhfg7!Z3yIRF3lH6cm{0T2KI5C8!X009sH0T2KI5CDO< zih%3<|65fg$^iio009sH0T2KI5C8!X009sH0T6hL31I&J76V6dAOHd&00JNY0w4ea zAOHd&00JQJHV}xBKNkYzDS!3m00ck)1V8`;KmY_l00cnb9Yo;0 zp|EiN%;3y&wPaMbo?t)ychx8x^d}#c4`}7GerL71TWM$pjT-v%%lRuhO}#^Z60%z6 zKlL{$g@w%6py1M9)1Oz?tF@c0|LYUsu#i60CUjNT8jZ4U{d*=)k)@~~Zae$>@xNU2 B@bv%y literal 0 HcmV?d00001 diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/__init__.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/settings.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/settings.py new file mode 100644 index 0000000..2a60c98 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for main project. + +Generated by 'django-admin startproject' using Django 1.10. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'g+w46!s7h*@w^#qit672)&rabk@_g+2wx_5w6j@(ki@99&9vr!' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.dojo_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'main.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'main.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/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/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/urls.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/urls.py new file mode 100644 index 0000000..9b03604 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/urls.py @@ -0,0 +1,21 @@ +"""main URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.dojo_app.urls')), +] diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/wsgi.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/wsgi.py new file mode 100644 index 0000000..4d1e3f4 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/main/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for main 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/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + +application = get_wsgi_application() diff --git a/justin_quiros/python_stack/django_projects/dojo_ninjas/main/manage.py b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/manage.py new file mode 100755 index 0000000..ad5d3e7 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/dojo_ninjas/main/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) From 9a468fb3bf80854756d4d2935d616832815d43b2 Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Wed, 15 Nov 2017 17:08:24 -0600 Subject: [PATCH 03/11] Books/Authors --- .../books_authors/main/apps/__init__.py | 0 .../main/apps/book_app/__init__.py | 0 .../books_authors/main/apps/book_app/admin.py | 3 + .../books_authors/main/apps/book_app/apps.py | 7 + .../apps/book_app/migrations/0001_initial.py | 42 ++++++ .../book_app/migrations/0002_author_notes.py | 20 +++ .../main/apps/book_app/migrations/__init__.py | 0 .../main/apps/book_app/models.py | 24 ++++ .../books_authors/main/apps/book_app/tests.py | 3 + .../books_authors/main/apps/book_app/urls.py | 6 + .../books_authors/main/apps/book_app/views.py | 9 ++ .../books_authors/main/db.sqlite3 | Bin 0 -> 159744 bytes .../books_authors/main/main/__init__.py | 0 .../books_authors/main/main/settings.py | 121 ++++++++++++++++++ .../books_authors/main/main/urls.py | 21 +++ .../books_authors/main/main/wsgi.py | 16 +++ .../books_authors/main/manage.py | 22 ++++ 17 files changed, 294 insertions(+) create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/admin.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/apps.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/0001_initial.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/0002_author_notes.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/models.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/tests.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/urls.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/views.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/db.sqlite3 create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/main/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/main/settings.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/main/urls.py create mode 100644 justin_quiros/python_stack/django_projects/books_authors/main/main/wsgi.py create mode 100755 justin_quiros/python_stack/django_projects/books_authors/main/manage.py diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/__init__.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/__init__.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/admin.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/apps.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/apps.py new file mode 100644 index 0000000..06273c9 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class BookAppConfig(AppConfig): + name = 'book_app' diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/0001_initial.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/0001_initial.py new file mode 100644 index 0000000..c9cac84 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/0001_initial.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-15 21:39 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Author', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=255)), + ('last_name', models.CharField(max_length=255)), + ('email', models.CharField(max_length=255)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + migrations.CreateModel( + name='Book', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('desc', models.TextField(null=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + migrations.AddField( + model_name='author', + name='books', + field=models.ManyToManyField(related_name='authors', to='book_app.Book'), + ), + ] diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/0002_author_notes.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/0002_author_notes.py new file mode 100644 index 0000000..de56495 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/0002_author_notes.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-15 21:47 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('book_app', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='author', + name='notes', + field=models.TextField(null=True), + ), + ] diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/__init__.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/models.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/models.py new file mode 100644 index 0000000..8c5bde6 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/models.py @@ -0,0 +1,24 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. +class Book(models.Model): + name = models.CharField(max_length=255) + desc = models.TextField(null = True) + created_at = models.DateTimeField(auto_now_add = True) + updated_at = models.DateTimeField(max_length=255) + def __unicode__(self): + return "id: " + str(self.id) + ", name: " + self.name + ", authors: " + str(self.authors) + ", desc: " + str(self.desc) + ", created_at:" + str(self.created_at) + ", updated_at: " + str(self.updated_at) + +class Author(models.Model): + first_name = models.CharField(max_length=255) + last_name = models.CharField(max_length=255) + email = models.CharField(max_length=255) + created_at = models.DateTimeField(auto_now_add = True) + updated_at = models.DateTimeField(auto_now = True) + notes = models.TextField(null = True) + books = models.ManyToManyField(Book, related_name = "authors") + + def __unicode__(self): + return "id: " + str(self.id) + ", first_name: " + self.first_name + ", last_name: " + self.last_name + ", email: " + self.email + ", books: " + str(self.books) + ", notes: " + str(self.notes) + ", created_at:" + str(self.created_at) + ", updated_at: " + str(self.updated_at) \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/tests.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/urls.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/urls.py new file mode 100644 index 0000000..42b9825 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import url +from . import views # This line is new! + +urlpatterns = [ + url(r'^$', views.index), +] \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/views.py b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/views.py new file mode 100644 index 0000000..de08e44 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/apps/book_app/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import render + +# Create your views here. +from django.shortcuts import render, redirect + +# Create your views here. +def index(request): + + return render(request, 'book_app/index.html') \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/db.sqlite3 b/justin_quiros/python_stack/django_projects/books_authors/main/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..0a78abe187b75220c5a619f3f233da725df5cf75 GIT binary patch literal 159744 zcmeI5du$uYeaCmnC6|;)jx1TG6`xL&d_J3zC3Cr4K6JU>@qF@~eYSk(2ND+vwkvTZ z)1pWnNnOrqf`oE)+ zBFP_}*#~#ITvCpDx$7xk3SM#M_nY7R<})+9JHH*RuRe9L+SXI+jpmltPRZOD$Mf97 zsT9X?=jgwa^xp{m$6INE{^~A*#ibA28i1@`J?0=+{T@9sS5iG?I?~ zm6#1rgf0s&1pg=a`oJFqM)_ah-F56`|3#5^_(?JO&;s8%UaeR3XSJR7O?9WGH`R@1 zV`saiX7rL=(sJuw!Q|O1%jIj!sq-t3F261{=M{I$&804{^o!?Gr{;_b)M{le-Qfh7E-Xxl$r}`d=I?@~sFrfFl3B~FsXO)R(_Vij zEPt-AoPX;2U^KqA_V)2~%8l&aaWVNsiSH~s{+d9y_2yQ!)v7k?Ewv~YOZIoLD0`ph1>D+g^GdpT&DH#+;$n3&us@w?(M z-)wy~vsRI_%4){x^FB|<2KRiQt~s+Pq+Y{!?LHj`Ue*E;lMl}Godu^oE|r{ASeI6% zHDeSw`NW5=BUSBEF25Wp>+rQky{*^VYWw!KZgzP&L9tRd-s0D>qV4EZ<0#uV1@-eubL6w7hbS zx@w&~d`eweKDT^jdFAZ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QD0#pAGpsCRAOHd&00JNY0w4eaAOHd&00JNY0xu$ga7^HMUJ%G< zxd{Co438M;KqyLoM+NdP+!)UX*>5Ti2E$<{4hBLYCJs_ZXm%hN3bJG%9AMHwK;Q)~ z8XY0OMc4ly;K&cicgXk1-;=*2pClh6AFzL3#8$u*2!H?xfB*=900@8p2!H?xfB*=9 zz)%9Bz_ay#jC_tR<%Qs=nGTGE1wP6PQSwz900;^Z`a43`|Dqud2520Bis{<}SO6dp z6pUmbXh;Jz03bx!`u|gO{r_=}{E++?`493{@(<)s$sduA+do6yf)E5i00ck)1V8`; zKmY_l00ck)1VG@&Odu4bA%PhA0v8rWjqfAIF-pG0#exxf3{@Hi7 z6@cvk2nN~u|1)&`{|UDK|4;ID^5--P@D=hW^lt#HpC5B0U>*cO00ck)1V8`;KmY_l z00ck)1VCUf0&E#iLjYf-OMN2*5Ev1HQ9eq(&Bf?ufN$FofIygK8v%fzz`nZH|9JoZ zUXURN0T2KI5C8!X009sH0T2KI5CDN!J^|PJ|6loyK?^_t1V8`;KmY_l00ck)1V8`; zKmY`M31I#2iv^h=00JNY0w4eaAOHd&00JNY0w8dp2(bPCp~UMs@mN zQCp(q<;%ecmzSP zv(dVstsC}kwJPhiP0gqA%94~>EGRjtRO~ZrO0uQmHJ;K;GP9SeoB9Q9OW(t4Zb`{6 Y%DH?gQ*v9)E@kB@~ literal 0 HcmV?d00001 diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/main/__init__.py b/justin_quiros/python_stack/django_projects/books_authors/main/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/main/settings.py b/justin_quiros/python_stack/django_projects/books_authors/main/main/settings.py new file mode 100644 index 0000000..04b22ff --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/main/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for main project. + +Generated by 'django-admin startproject' using Django 1.10. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '#8qd4e@b*_66av=0nq%yl5@p#*%&8v^)*kh)m9!-)98bj8$!bu' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.book_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'main.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'main.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/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/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/main/urls.py b/justin_quiros/python_stack/django_projects/books_authors/main/main/urls.py new file mode 100644 index 0000000..0f070b7 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/main/urls.py @@ -0,0 +1,21 @@ +"""main URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.book_app.urls')), +] diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/main/wsgi.py b/justin_quiros/python_stack/django_projects/books_authors/main/main/wsgi.py new file mode 100644 index 0000000..4d1e3f4 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/main/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for main 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/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + +application = get_wsgi_application() diff --git a/justin_quiros/python_stack/django_projects/books_authors/main/manage.py b/justin_quiros/python_stack/django_projects/books_authors/main/manage.py new file mode 100755 index 0000000..ad5d3e7 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/books_authors/main/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) From 4a9abd01ae6366cfdbff00d576604b551074ffac Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Thu, 16 Nov 2017 07:52:17 -0600 Subject: [PATCH 04/11] Likes/Books --- .../likes_books/main/apps/__init__.py | 0 .../main/apps/book_app/__init__.py | 0 .../likes_books/main/apps/book_app/admin.py | 3 + .../likes_books/main/apps/book_app/apps.py | 7 + .../apps/book_app/migrations/0001_initial.py | 48 +++++++ .../main/apps/book_app/migrations/__init__.py | 0 .../likes_books/main/apps/book_app/models.py | 18 +++ .../likes_books/main/apps/book_app/tests.py | 3 + .../likes_books/main/apps/book_app/urls.py | 6 + .../likes_books/main/apps/book_app/views.py | 9 ++ .../likes_books/main/db.sqlite3 | Bin 0 -> 151552 bytes .../likes_books/main/main/__init__.py | 0 .../likes_books/main/main/settings.py | 121 ++++++++++++++++++ .../likes_books/main/main/urls.py | 21 +++ .../likes_books/main/main/wsgi.py | 16 +++ .../likes_books/main/manage.py | 22 ++++ 16 files changed, 274 insertions(+) create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/admin.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/apps.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/migrations/0001_initial.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/migrations/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/models.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/tests.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/urls.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/views.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/db.sqlite3 create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/main/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/main/settings.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/main/urls.py create mode 100644 justin_quiros/python_stack/django_projects/likes_books/main/main/wsgi.py create mode 100755 justin_quiros/python_stack/django_projects/likes_books/main/manage.py diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/__init__.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/__init__.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/admin.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/apps.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/apps.py new file mode 100644 index 0000000..06273c9 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class BookAppConfig(AppConfig): + name = 'book_app' diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/migrations/0001_initial.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/migrations/0001_initial.py new file mode 100644 index 0000000..bea1bf9 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/migrations/0001_initial.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-16 13:31 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Book', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('desc', models.CharField(max_length=255)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=255)), + ('last_name', models.CharField(max_length=255)), + ('email', models.EmailField(max_length=254, unique=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + migrations.AddField( + model_name='book', + name='liked_by', + field=models.ManyToManyField(related_name='liked_books', to='book_app.User'), + ), + migrations.AddField( + model_name='book', + name='uploader', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='uploaded_books', to='book_app.User'), + ), + ] diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/migrations/__init__.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/models.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/models.py new file mode 100644 index 0000000..f1e7ee6 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/models.py @@ -0,0 +1,18 @@ +from __future__ import unicode_literals + +from django.db import models + +class User(models.Model): + first_name = models.CharField(max_length=255) + last_name = models.CharField(max_length=255) + email = models.EmailField(unique=True) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + +class Book(models.Model): + name = models.CharField(max_length=255) + desc = models.CharField(max_length=255) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + uploader = models.ForeignKey(User, related_name="uploaded_books") + liked_by = models.ManyToManyField(User, related_name="liked_books") \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/tests.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/urls.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/urls.py new file mode 100644 index 0000000..42b9825 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import url +from . import views # This line is new! + +urlpatterns = [ + url(r'^$', views.index), +] \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/views.py b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/views.py new file mode 100644 index 0000000..de08e44 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/apps/book_app/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import render + +# Create your views here. +from django.shortcuts import render, redirect + +# Create your views here. +def index(request): + + return render(request, 'book_app/index.html') \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/db.sqlite3 b/justin_quiros/python_stack/django_projects/likes_books/main/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..59fa800050c76838e2ca5557380755d67372bf42 GIT binary patch literal 151552 zcmeI5eT*aLUB^9s8}F^{*}J{Hxx8%F>&@oQ-P=8n$FG-$#JTvAYwq@vdr@)}G@7+% zH*@EgJ==Rtpe6NQl_Ej^0VygVRR}5-5J;^=DX1Qk#!#7p^u z=Xqwv^Ww30vqTBEe673LndkR=e$VguJTEiPi^tbqyrlQF)MlsKQu`@6FcaXoz*DJI zAP~rr|I6gR^?8PzgsltmmvfwtJIw{wPQDYN%EAw+&I7^^le5#`nSNyYYe%MHnW?|z zbJ5wzmGC>E{|Nn9@OOjL+)s1PG{)KeK*I;z94|h($_D1{oOF+>Z>C7N--0)%1 z-v_N+%1UY@?@i?R9zIy{#{0l>%3N5T<;9x>gX-^ssi;))av@vK)|H*Me#h(2tm)5< z^@}gw7>~x+*4{pzNjZ@{a*P+BuW*B!?XLlJTkE#;UQh3|drDa@$s1BhVvdf8kNMym zQ5xECI5?t2i_=cmDANay8V)`_$w61`8ZmoxUk+L}_HxiL&kFnU3@>g~xLtmdZC?1zzv8`&zrN^k3W7j3Tcl30C69XMEl8=qsd2Z^)&BYGbwSC&%-& zm6VAV_w6^~S?@How%XFtncasIyjZPr_s;j#jizR|aMoz;w0q+v3DfuM)u%7joL!&S z1cgYdV@f9+x3q3*{mS*!`i)DMQZHP+c)5D@X6pIc%~bWq^(zC{H2({xH{D68#5`*PMcpEB-V zB$Z9QOOhF{X*n`cLu;ve)6Pk$V5dalQ%C#i=H{rAM55OF`dw{QM02d%>ga8aAR5Vj zMw*U_wFNG~I-%a3CV9kDNI?;O@_a+j%m*Cfu1H}_?;e}t#Y%;{_oQ9EMs2a%fKjrr{MPG;m- zRD5=EV$mAZ98Wy4-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py b/justin_quiros/python_stack/django_projects/likes_books/main/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/main/settings.py b/justin_quiros/python_stack/django_projects/likes_books/main/main/settings.py new file mode 100644 index 0000000..d636d6c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/main/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for main project. + +Generated by 'django-admin startproject' using Django 1.10. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'a8f(v@p36*ohs&6w)2$in+4j%1i-hr+^7w@a-&3r!2$i8s3m_u' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.book_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'main.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'main.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/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/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/main/urls.py b/justin_quiros/python_stack/django_projects/likes_books/main/main/urls.py new file mode 100644 index 0000000..0f070b7 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/main/urls.py @@ -0,0 +1,21 @@ +"""main URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.book_app.urls')), +] diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/main/wsgi.py b/justin_quiros/python_stack/django_projects/likes_books/main/main/wsgi.py new file mode 100644 index 0000000..4d1e3f4 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/main/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for main 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/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + +application = get_wsgi_application() diff --git a/justin_quiros/python_stack/django_projects/likes_books/main/manage.py b/justin_quiros/python_stack/django_projects/likes_books/main/manage.py new file mode 100755 index 0000000..ad5d3e7 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/likes_books/main/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) From bec14e8f82ddcd148ca1b73029db3d27ff372f1f Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Thu, 16 Nov 2017 20:13:48 -0600 Subject: [PATCH 05/11] Semi-Restful --- .../django_app/main/db.sqlite3 | Bin 131072 -> 131072 bytes .../semi_rest/main/apps/__init__.py | 0 .../semi_rest/main/apps/rest_app/__init__.py | 0 .../semi_rest/main/apps/rest_app/admin.py | 3 + .../semi_rest/main/apps/rest_app/apps.py | 7 + .../apps/rest_app/migrations/0001_initial.py | 27 ++++ .../main/apps/rest_app/migrations/__init__.py | 0 .../semi_rest/main/apps/rest_app/models.py | 12 ++ .../rest_app/static/rest_app/css/style.css | 9 ++ .../rest_app/templates/rest_app/edit.html | 28 ++++ .../rest_app/templates/rest_app/index.html | 43 +++++++ .../apps/rest_app/templates/rest_app/new.html | 29 +++++ .../rest_app/templates/rest_app/user.html | 18 +++ .../semi_rest/main/apps/rest_app/tests.py | 3 + .../semi_rest/main/apps/rest_app/urls.py | 13 ++ .../semi_rest/main/apps/rest_app/views.py | 54 ++++++++ .../django_projects/semi_rest/main/db.sqlite3 | Bin 0 -> 139264 bytes .../semi_rest/main/main/__init__.py | 0 .../semi_rest/main/main/settings.py | 121 ++++++++++++++++++ .../semi_rest/main/main/urls.py | 21 +++ .../semi_rest/main/main/wsgi.py | 16 +++ .../django_projects/semi_rest/main/manage.py | 22 ++++ 22 files changed, 426 insertions(+) create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/admin.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/apps.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/migrations/0001_initial.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/migrations/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/models.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/static/rest_app/css/style.css create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/edit.html create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/index.html create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/new.html create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/user.html create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/tests.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/urls.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/views.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/db.sqlite3 create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/main/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/main/settings.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/main/urls.py create mode 100644 justin_quiros/python_stack/django_projects/semi_rest/main/main/wsgi.py create mode 100755 justin_quiros/python_stack/django_projects/semi_rest/main/manage.py diff --git a/justin_quiros/python_stack/django_projects/django_app/main/db.sqlite3 b/justin_quiros/python_stack/django_projects/django_app/main/db.sqlite3 index 62401a1e0515c1e37784c472b86381c2a60220c4..aa8b67ff3b8513fda582f5e706d06088a9ab11b8 100644 GIT binary patch delta 250 zcmZo@;Am*zm>|ulK2gS*QGH{=l70>*z9$U)MSM>-D=OUJ(`e*oV)boQbm4T_1iGiNEp}C=@VIwyq zSo`D$>lJ`XvN)Ldw=?i>=fAUAFkv;nstU6&BO#NSn(wUNerG+Sh67OZVFvz3{D*;> vxAWV|F*`CE85o-D8XD?i+RP-&?8pg|HZoT*w6HQYvobc+v#>BUFfsrDVo^%z delta 114 zcmZo@;Am*zm>|ulHc`fzQEg+wl72Qu{vrncqRom18T=fL+>ETgjjE25AFNlHJZpXy z2P6L-1|Z_vESPYCzxmGk?RVBQYB&J(JYwK~1Qfi%FDJ|F$Z2F?Xs&B$sB2`dU}#}w QYG!3@sApkeXkcUj0OVRBMF0Q* diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/__init__.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/__init__.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/admin.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/apps.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/apps.py new file mode 100644 index 0000000..a56dd04 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class RestAppConfig(AppConfig): + name = 'rest_app' diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/migrations/0001_initial.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/migrations/0001_initial.py new file mode 100644 index 0000000..58e2301 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-16 18:16 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=255)), + ('last_name', models.CharField(max_length=255)), + ('email', models.EmailField(max_length=254, unique=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + ] diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/migrations/__init__.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/models.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/models.py new file mode 100644 index 0000000..e0e9eee --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/models.py @@ -0,0 +1,12 @@ +from __future__ import unicode_literals + +from django.db import models + +class User(models.Model): + first_name = models.CharField(max_length=255) + last_name = models.CharField(max_length=255) + email = models.EmailField(unique=True) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + def __unicode__(self): + return "id: " + str(self.id) + ", first_name: " + self.first_name + ", last_name " + self.last_name + ", email " + self.email \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/static/rest_app/css/style.css b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/static/rest_app/css/style.css new file mode 100644 index 0000000..2dd646d --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/static/rest_app/css/style.css @@ -0,0 +1,9 @@ +*{ + margin: 0px; + padding: 0px; +} + +.box{ + height: 500px; + width: 500px; +} \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/edit.html b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/edit.html new file mode 100644 index 0000000..ec839ce --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/edit.html @@ -0,0 +1,28 @@ + + + + {% load static %} + + Users Index + + + + +

Edit User {{id}}

+ +
+ {% csrf_token %} + + + + + + + + +
+ +
+

Show | Go Back

+ + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/index.html b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/index.html new file mode 100644 index 0000000..4aadc8e --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/index.html @@ -0,0 +1,43 @@ + + + + {% load static %} + + Users Index + + + +

Users

+
+ + + + + + + + + + + + {% for user in users %} + + + + + + + + {% endfor %} + +
idFull NameEmailCreated AtActions
{{user.id}}{{user.first_name}} {{user.last_name}}{{user.email}}{{user.created_at}} + Show + Edit + Delete +
+
+
+ Add a new user + + + diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/new.html b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/new.html new file mode 100644 index 0000000..fd19ca4 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/new.html @@ -0,0 +1,29 @@ + + + + {% load static %} + + Users Index + + + + +

Add a new user

+ +
+ {% csrf_token %} + + + + + + + + +
+ +
+
+

Go Back

+ + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/user.html b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/user.html new file mode 100644 index 0000000..4df6280 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/templates/rest_app/user.html @@ -0,0 +1,18 @@ + + + + {% load static %} + + Users Index + + + + +

User {{user.id}}

+

Full Name: {{user.first_name}} {{user.last_name}}

+

Email: {{user.email}}

+

Created at: {{user.created_at}}

+
+

Edit | Delete

+ + diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/tests.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/urls.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/urls.py new file mode 100644 index 0000000..53f3735 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/urls.py @@ -0,0 +1,13 @@ +from django.conf.urls import url +from . import views # This line is new! + +urlpatterns = [ + url(r'^$', views.index), + url(r'users$', views.index), + url(r'users/(?P\d+)$', views.show), + url(r'users/new', views.new), + url(r'create', views.create), + url(r'update/(?P\d+)', views.update), + url(r'users/(?P\d+)/edit', views.edit), + url(r'users/(?P\d+)/destroy', views.destroy) +] \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/views.py b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/views.py new file mode 100644 index 0000000..7c2a447 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/apps/rest_app/views.py @@ -0,0 +1,54 @@ +from django.shortcuts import render, redirect + +# Create your views here. +from django.shortcuts import render, redirect +from .models import User +from time import localtime, strftime + +# Create your views here. +def index(request): + context = { + "users": User.objects.all() + } + return render(request, 'rest_app/index.html', context) + +def show(request, user_id): + context = { + "user": (User.objects.get(id=user_id)) + } + + return render(request, 'rest_app/user.html', context) + +def new(request): + return render(request, 'rest_app/new.html') + +def edit(request, user_id): + context = { + "id": (User.objects.get(id=user_id).id), + "first_name": (User.objects.get(id=user_id).first_name), + "last_name": (User.objects.get(id=user_id).last_name), + "email": (User.objects.get(id=user_id).email) + } + return render(request, 'rest_app/edit.html', context) + +def create(request): + User.objects.create(first_name=request.POST['first_name'], last_name=request.POST['last_name'], email=request.POST['email']) + return redirect('/') + +def destroy(request, user_id): + User.objects.get(id=user_id).delete() + return redirect('/') + +def update(request, user_id): + + x = User.objects.get(id=user_id) + x.first_name = request.POST['first_name'] + x.last_name = request.POST['last_name'] + x.email = request.POST['email'] + x.save() + + return redirect('/') + + + + diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/db.sqlite3 b/justin_quiros/python_stack/django_projects/semi_rest/main/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..01567438f8811bf6edcf06a710b2dcb0a8cc45b8 GIT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fB*=9z@sAIIsY#{DxJ^+0w4eaAOHd&00JNY0w4eaAOHd&@OTlx z{{Q3U4_E^NAOHd&00JNY0w4eaAOHd&00JKc0nh&bN1+}%K>!3m00ck)1V8`;KmY_l q00ck)1RetdnEyWpPJjs@00JNY0w4eaAOHd&00JNY0wC}a6Zjub0$&6G literal 0 HcmV?d00001 diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/main/__init__.py b/justin_quiros/python_stack/django_projects/semi_rest/main/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/main/settings.py b/justin_quiros/python_stack/django_projects/semi_rest/main/main/settings.py new file mode 100644 index 0000000..8f240dd --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/main/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for main project. + +Generated by 'django-admin startproject' using Django 1.10. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '+su$+$)6d_whsvxlr!xjwi7z3c#niqetupwsjffyks+ftli$*5' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.rest_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'main.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'main.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/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/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/main/urls.py b/justin_quiros/python_stack/django_projects/semi_rest/main/main/urls.py new file mode 100644 index 0000000..2b90edf --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/main/urls.py @@ -0,0 +1,21 @@ +"""main URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.rest_app.urls')), +] diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/main/wsgi.py b/justin_quiros/python_stack/django_projects/semi_rest/main/main/wsgi.py new file mode 100644 index 0000000..4d1e3f4 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/main/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for main 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/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + +application = get_wsgi_application() diff --git a/justin_quiros/python_stack/django_projects/semi_rest/main/manage.py b/justin_quiros/python_stack/django_projects/semi_rest/main/manage.py new file mode 100755 index 0000000..ad5d3e7 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/semi_rest/main/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) From 31c364d22aabb1c9979c066627f940d3d1133ad2 Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Thu, 16 Nov 2017 21:27:50 -0600 Subject: [PATCH 06/11] Course/Review --- .../courses/courses/apps/__init__.py | 0 .../courses/apps/course_review/__init__.py | 0 .../courses/apps/course_review/admin.py | 3 + .../courses/apps/course_review/apps.py | 7 + .../course_review/migrations/0001_initial.py | 26 ++++ .../apps/course_review/migrations/__init__.py | 0 .../courses/apps/course_review/models.py | 11 ++ .../templates/course_review/destroy.html | 17 +++ .../templates/course_review/index.html | 45 +++++++ .../courses/apps/course_review/tests.py | 3 + .../courses/apps/course_review/urls.py | 9 ++ .../courses/apps/course_review/views.py | 28 ++++ .../courses/courses/courses/__init__.py | 0 .../courses/courses/courses/settings.py | 121 ++++++++++++++++++ .../courses/courses/courses/urls.py | 21 +++ .../courses/courses/courses/wsgi.py | 16 +++ .../courses/courses/db.sqlite3 | Bin 0 -> 135168 bytes .../django_projects/courses/courses/manage.py | 22 ++++ 18 files changed, 329 insertions(+) create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/admin.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/apps.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/migrations/0001_initial.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/migrations/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/models.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/destroy.html create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/index.html create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/tests.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/urls.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/views.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/courses/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/courses/settings.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/courses/urls.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/courses/wsgi.py create mode 100644 justin_quiros/python_stack/django_projects/courses/courses/db.sqlite3 create mode 100755 justin_quiros/python_stack/django_projects/courses/courses/manage.py diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/__init__.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/__init__.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/admin.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/apps.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/apps.py new file mode 100644 index 0000000..a51a109 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class CourseReviewConfig(AppConfig): + name = 'course_review' diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/migrations/0001_initial.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/migrations/0001_initial.py new file mode 100644 index 0000000..14c5240 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-17 02:44 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Course', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('desc', models.CharField(max_length=255)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + ] diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/migrations/__init__.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/models.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/models.py new file mode 100644 index 0000000..c4e6f23 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/models.py @@ -0,0 +1,11 @@ +from __future__ import unicode_literals + +from django.db import models + +class Course(models.Model): + name = models.CharField(max_length=255) + desc = models.CharField(max_length=255) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + def __unicode__(self): + return "id: " + str(self.id) + ", name: " + self.name + ", desc: " + self.desc \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/destroy.html b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/destroy.html new file mode 100644 index 0000000..b5c49b9 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/destroy.html @@ -0,0 +1,17 @@ + + + + {% load static %} + + Courses + + + + +

Delete a course

+

Are you sure you want to delete the following course?

+

Name: {{name}}

+

Description: {{desc}}

+ remove + + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/index.html b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/index.html new file mode 100644 index 0000000..25e28fb --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/index.html @@ -0,0 +1,45 @@ + + + + {% load static %} + + Courses + + + + +

Add a new course

+ +
+ {% csrf_token %} + + +
+ +
+ +
+
+

Courses

+ + + + + + + + + + + {% for course in courses %} + + + + + + + {% endfor %} + +
Course NameDescriptionDate AddedActions
{{course.name}}{{course.desc}}{{course.created_at}}remove
+ + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/tests.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/urls.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/urls.py new file mode 100644 index 0000000..e7461ef --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls import url +from . import views # This line is new! + +urlpatterns = [ + url(r'^$', views.index), + url(r'courses/create', views.create), + url(r'courses/destroy/(?P\d+)', views.destroy), + url(r'courses/delete/(?P\d+)', views.delete) +] \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/views.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/views.py new file mode 100644 index 0000000..76954e5 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/views.py @@ -0,0 +1,28 @@ +from django.shortcuts import render, redirect + +# Create your views here. +from django.shortcuts import render, redirect +from .models import Course + +# Create your views here. +def index(request): + context = { + "courses": Course.objects.all() + } + return render(request, 'course_review/index.html', context) + +def destroy(request, course_id): + context = { + "id": (Course.objects.get(id=course_id).id), + "name": (Course.objects.get(id=course_id).name), + "desc": (Course.objects.get(id=course_id).desc) + } + return render(request, 'course_review/destroy.html', context) + +def delete(request, id): + Course.objects.get(id=id).delete() + return redirect('/') + +def create(request): + Course.objects.create(name=request.POST['name'], desc=request.POST['desc']) + return redirect('/') \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/courses/courses/courses/__init__.py b/justin_quiros/python_stack/django_projects/courses/courses/courses/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/courses/courses/courses/settings.py b/justin_quiros/python_stack/django_projects/courses/courses/courses/settings.py new file mode 100644 index 0000000..3b1e7b7 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/courses/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for courses project. + +Generated by 'django-admin startproject' using Django 1.10. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '60!$l^7vf+qkqzo(_8v*2z)fl=pewhyf$u7g(5*1d#kz_e_4*2' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.course_review', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'courses.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'courses.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/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/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/justin_quiros/python_stack/django_projects/courses/courses/courses/urls.py b/justin_quiros/python_stack/django_projects/courses/courses/courses/urls.py new file mode 100644 index 0000000..1fb3d86 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/courses/urls.py @@ -0,0 +1,21 @@ +"""courses URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.course_review.urls')), +] diff --git a/justin_quiros/python_stack/django_projects/courses/courses/courses/wsgi.py b/justin_quiros/python_stack/django_projects/courses/courses/courses/wsgi.py new file mode 100644 index 0000000..9da3dff --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/courses/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for courses 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/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "courses.settings") + +application = get_wsgi_application() diff --git a/justin_quiros/python_stack/django_projects/courses/courses/db.sqlite3 b/justin_quiros/python_stack/django_projects/courses/courses/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..d585944a82a0a1b54738e4c3d5d59e40aada55ae GIT binary patch literal 135168 zcmeI5TWlLwddFvY8{No}B`f2s?RZ43VzaU=4lkl;Z#H2Z#u04Gjx3{bw#9Trj^wd< zkvWtdqq|s8F5EtBUJ4|;55)p)7g(SV-LwUY0?k7kplyHx1@_Vw=)aT>TgD*0k2Jo+PYKe?^L%HSn9C zy=AIty_hX(xsBe0sk5u)(pp(wUU{wjmYnQO?&eF%msa|dlk$lqD?l}>$yA3sXxT6w zY=gd3NGn=3*IUTJJ#29D4Yq;Rl$kI;DM;4{1})eGTTm_LviWo+T~W6i#;sm^CT)AJ zt}MTKbugMhU3=SjQuZQyVM3737x_-vwbuf=rMK#aX&TLjsV-#;*>$C$Fhl#2Cj#*G z33YXN4D1u4?sUtweER$W%fK_c8R%9fV9)o-T0M(E@+*E|^GQ4CWgQU(>7_ZoGw;^NBa%}J8_K#;VXeT8 z7X#?Jsj8F9W0#vs9bRcR+Ipj{w(oA~mdi^Cf|Z!@wLmj^owi&;jGiTWt)Rj;GVrli7e7<~5E?r%_w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Zkem^-((iRF~Tfh5)6i+E`PjAzHduj+X5Tg`?c?@ddkN>rEz}a;=D&5EHV?bcO5^t%##M5t>fX(p(8zmKCD& ze{TFq>AJ831V8`;KmY_l00ck)1V8`;KmY_l;BgS}oc|Xehkob;0T2KI5C8!X009sH z0T2KI5C8!X`1}cY=Kr6+F|YsxKmY_l00ck)1V8`;KmY_l00cnbu@J!g|FK|&QV;+E Y5C8!X009sH0T2KI5C8!Xc%lgWKh?vA=Kufz literal 0 HcmV?d00001 diff --git a/justin_quiros/python_stack/django_projects/courses/courses/manage.py b/justin_quiros/python_stack/django_projects/courses/courses/manage.py new file mode 100755 index 0000000..7594c9c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/courses/courses/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "courses.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) From c9bb572c2585f7cfceecf99b73fc599e9a3c0692 Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Fri, 17 Nov 2017 13:24:16 -0600 Subject: [PATCH 07/11] Course validation --- .../courses/apps/course_review/models.py | 32 +++++++++++++++++++ .../templates/course_review/index.html | 4 ++- .../courses/apps/course_review/views.py | 9 +++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/models.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/models.py index c4e6f23..e0a4ddd 100644 --- a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/models.py +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/models.py @@ -2,10 +2,42 @@ from django.db import models +class CourseManager(models.Manager): + + def course_validation(self, form_data): + errors = {} + + + if len(form_data['name']) == 0: + errors['name'] = "Course name is required." + + if len(form_data['name']) < 5: + errors['name'] = "Course name must be atleast 5 characters." + + if len(form_data['desc']) < 15: + errors['desc'] = "Course description must be atleast 15 characters." + + + # if len(form_data['name']) == 0: + # errors.append('Course name is required.') + + # if len(form_data['name']) < 5: + # errors.append('Course name must be atleast 5 characters.') + + # if len(form_data['desc']) < 15: + # errors.append('Course description must be atleast 15 characters.') + + return errors + + + class Course(models.Model): name = models.CharField(max_length=255) desc = models.CharField(max_length=255) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) + + objects = CourseManager() + def __unicode__(self): return "id: " + str(self.id) + ", name: " + self.name + ", desc: " + self.desc \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/index.html b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/index.html index 25e28fb..70e048f 100644 --- a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/index.html +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/templates/course_review/index.html @@ -9,7 +9,9 @@

Add a new course

- + {% for message in messages %} + {{message}} + {% endfor %}
{% csrf_token %} diff --git a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/views.py b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/views.py index 76954e5..64c9441 100644 --- a/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/views.py +++ b/justin_quiros/python_stack/django_projects/courses/courses/apps/course_review/views.py @@ -2,6 +2,7 @@ # Create your views here. from django.shortcuts import render, redirect +from django.contrib import messages from .models import Course # Create your views here. @@ -24,5 +25,11 @@ def delete(request, id): return redirect('/') def create(request): - Course.objects.create(name=request.POST['name'], desc=request.POST['desc']) + errors = Course.objects.course_validation(request.POST) + if len(errors): + for tag, error in errors.iteritems(): + messages.error(request, error, extra_tags = tag) + return redirect('/') + else: + Course.objects.create(name=request.POST['name'], desc=request.POST['desc']) return redirect('/') \ No newline at end of file From a34fc2618d378d7376a162f02ef167a9bdc6f373 Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Fri, 17 Nov 2017 16:09:05 -0600 Subject: [PATCH 08/11] Login_Reg --- .../login_reg/apps/__init__.py | 0 .../login_reg/apps/login_app/__init__.py | 0 .../login_reg/apps/login_app/admin.py | 3 + .../login_reg/apps/login_app/apps.py | 7 + .../apps/login_app/migrations/0001_initial.py | 28 ++++ .../apps/login_app/migrations/__init__.py | 0 .../login_reg/apps/login_app/models.py | 71 ++++++++++ .../login_app/static/login_app/css/style.css | 21 +++ .../login_app/templates/login_app/index.html | 54 ++++++++ .../templates/login_app/success.html | 15 +++ .../login_reg/apps/login_app/tests.py | 3 + .../login_reg/apps/login_app/urls.py | 10 ++ .../login_reg/apps/login_app/views.py | 44 +++++++ .../django_projects/login_reg/db.sqlite3 | Bin 0 -> 135168 bytes .../login_reg/login_reg/__init__.py | 0 .../login_reg/login_reg/settings.py | 121 ++++++++++++++++++ .../login_reg/login_reg/urls.py | 21 +++ .../login_reg/login_reg/wsgi.py | 16 +++ .../django_projects/login_reg/manage.py | 22 ++++ 19 files changed, 436 insertions(+) create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/admin.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/apps.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/migrations/0001_initial.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/migrations/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/models.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/static/login_app/css/style.css create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/templates/login_app/index.html create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/templates/login_app/success.html create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/tests.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/urls.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/apps/login_app/views.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/db.sqlite3 create mode 100644 justin_quiros/python_stack/django_projects/login_reg/login_reg/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/login_reg/settings.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/login_reg/urls.py create mode 100644 justin_quiros/python_stack/django_projects/login_reg/login_reg/wsgi.py create mode 100755 justin_quiros/python_stack/django_projects/login_reg/manage.py diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/__init__.py b/justin_quiros/python_stack/django_projects/login_reg/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/__init__.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/admin.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/apps.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/apps.py new file mode 100644 index 0000000..39e95c6 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class LoginAppConfig(AppConfig): + name = 'login_app' diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/migrations/0001_initial.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/migrations/0001_initial.py new file mode 100644 index 0000000..fc8f6ff --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-17 19:42 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=255)), + ('last_name', models.CharField(max_length=255)), + ('email', models.CharField(max_length=255)), + ('password', models.CharField(max_length=255)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + ] diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/migrations/__init__.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/models.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/models.py new file mode 100644 index 0000000..4a82f5c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/models.py @@ -0,0 +1,71 @@ +from __future__ import unicode_literals + +from django.db import models +import bcrypt +import re +EMAIL_REGEX = re.compile(r'^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$') + +class UserManager(models.Manager): + + def register_validation(self, form_data): + errors = [] + + if len(form_data['first_name']) == 0: + errors.append( "First name is required.") + if len(form_data['last_name']) == 0: + errors.append("Last name is required") + if len(form_data['email']) == 0 or not EMAIL_REGEX.match(form_data['email']): + errors.append("Email is invalid.") + if len(form_data['password']) < 8: + errors.append("Email must be atleast 8 characters.") + if form_data['password'] != form_data['conf_password']: + errors.append("Passwords did not match.") + + duplicate = User.objects.filter(email = form_data['email']) + if len(duplicate) == 1: + errors.append("This email is already registered.") + + return errors + + + def register(self, form_data): + pw = str(form_data['password']) + hashed_pw = bcrypt.hashpw(pw, bcrypt.gensalt()) + + user = User.objects.create( + first_name = form_data['first_name'], + last_name = form_data['last_name'], + email = form_data['email'], + password = hashed_pw + ) + return user + + def login_validation(self, form_data): + errors = [] + user = User.objects.filter(email=form_data['email']).first() + print user + if user: + pw = str(form_data['password']) + user_password = str(user.password) + if not bcrypt.checkpw(pw.encode(), user_password.encode()): + errors.append("Invalid password.") + else: + errors.append("Invalid email.") + return errors + + def login(self, form_data): + user = User.objects.filter(email=form_data['email']).first() + return user + + +class User(models.Model): + first_name = models.CharField(max_length=255) + last_name = models.CharField(max_length=255) + email = models.CharField(max_length=255) + password = models.CharField(max_length=255) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + objects = UserManager() + + def __unicode__(self): + return "id: " + str(self.id) + ", first_name: " + self.first_name + ", last_name: " + self.last_name + ", email:" + self.email + ", password:" + self.password diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/static/login_app/css/style.css b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/static/login_app/css/style.css new file mode 100644 index 0000000..6babea9 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/static/login_app/css/style.css @@ -0,0 +1,21 @@ +*{ + margin: 0px; + padding: 0px; +} + +input{ + float: right; +} + +h1{ + margin-left: 10px; + margin-bottom: 20px; +} + +form{ + width: 215px; + margin-bottom: 50px; + margin-left: 10PX; + border: solid 2px black; + padding: 10px 5px 25px 5px; +} \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/templates/login_app/index.html b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/templates/login_app/index.html new file mode 100644 index 0000000..372c89f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/templates/login_app/index.html @@ -0,0 +1,54 @@ + + + + {% load static %} + + Login and Registration + + + + +

Registration

+ {% for error in errors %} + {{error}} + {% endfor %} + + {% csrf_token %} + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+

Login

+
+ {% csrf_token %} + + +
+
+ + +
+
+ +
+ + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/templates/login_app/success.html b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/templates/login_app/success.html new file mode 100644 index 0000000..9002f73 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/templates/login_app/success.html @@ -0,0 +1,15 @@ + + + + {% load static %} + + Login and Registration + + + + +

Success! Welcome, {{request.session.name}}.

+

Succesfully {{request.session.status}}

+ Logout + + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/tests.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/urls.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/urls.py new file mode 100644 index 0000000..c998298 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/urls.py @@ -0,0 +1,10 @@ +from django.conf.urls import url +from . import views # This line is new! + +urlpatterns = [ + url(r'^$', views.index), + url(r'^courses/register', views.register), + url(r'^courses/login', views.login), + url(r'^logout', views.logout), + url(r'^success', views.success), +] \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/views.py b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/views.py new file mode 100644 index 0000000..360b066 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/login_reg/apps/login_app/views.py @@ -0,0 +1,44 @@ +from django.shortcuts import render, redirect +from django.contrib import messages +from .models import User +# Create your views here. +def index(request): + request.session['status'] = "" + if 'errors' not in request.session: + request.session['errors'] = [] + context = { + "errors": request.session['errors'] + } + return render(request, 'login_app/index.html', context) + +def register(request): + if request.method == "POST": + errors = User.objects.register_validation(request.POST) + if len(errors) != 0: + request.session['errors'] = errors + print errors + return redirect('/') + else: + user = User.objects.register(request.POST) + request.session['user_id'] = user.id + request.session['status'] = "registered." + request.session['name'] = user.first_name + return redirect('/success') + +def login(request): + errors = User.objects.login_validation(request.POST) + if len(errors) != 0: + request.session['errors'] = errors + return redirect('/') + else: + user = User.objects.login(request.POST) + request.session['name'] = user.first_name + request.session['status'] = "logged in." + return render(request, 'login_app/success.html') + +def success(request): + return render(request, 'login_app/success.html') + +def logout(request): + request.session.clear() + return redirect('/') \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/login_reg/db.sqlite3 b/justin_quiros/python_stack/django_projects/login_reg/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..c7c5932a57bc2ca0f9a1e0c1845b54c7bd8e6546 GIT binary patch literal 135168 zcmeI5TWlNIdB-{8WppD)maOGEUau&5wQJUv#NqHNXS1ed+SXd6R4`UKmMjbUupd_J4a z_JF*{$-D9T82R961jzr4>2tS_4{Xyff89xixgS%RbKH+TBLm+Xcy-|S`ulqQeSgCS zT_es#$Jg!uZU4ERKj|4@KEs&H=%)9X#@Crq*8A2JQ@^Mbv+{vdt8R(4id+_R6P>hF!a3B-Nh_#~fu-%>!-JaF- z{L*T7G?uzfw(*M3jO^86)_W(;)RTt28qi(2Tu>?%rBtklF(E2!@KIhhv?F=g0$+zv zQ-{gG4k7AJqg>6W=gw#bUOmphme$pw_RJF**wAs3ftq^N*{LDcn~O6?>~Xd= zWnQXO#e6BJ6eoOHsVY~Mf^1G#Dq^KZ+(#SBgm0r%%9~SZtlHX}`h|d@-lyHYNGY32 znH1AqvSG-v5^_OO@s+s_e;~Nwmh|c1bD91W`xz{rrH- zn;c_o>L65km?w{TB5@RvC(k$Zlm39C-4!W}furF*)*FvAkKZ!%DxrWk@&psFg8-E{hr&s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yJh#)q*R zFjjX=o?<7pv0G_A3t_Ae3hTEY6siOgwgP_KA0Zi9<4_tgN;J{}FqU zRhQk9Mqe>XRC|mOywJMb*p_;#-qTj46SkG~1x|A&y;Qn$*sPV&69cBMLL^$-e#`2m zzy8q))|(NSy0#f*QItrQH^scPA?L+tWFsqNg$;FA+(Oi0=}!y6ZaOt@T4bR0ZQ4Ok z3KfVi^W=ok{5b0s1m-AiUOP6EvQXx1b*P2Jshn!q*VPl6)z-=Wy6si-Nh94XDO*sA zbQ~2MCx+S+UeT+g_we@QX1*4PVv=KIy%nnZT=ClO3uW=Pue4&YxgHBVTtD z%q~+8Y&?GB6?HfNUB>L$rrGTlylUywrueBGTH4r_GgWolw<;f0)$M=M^z`Vmyi4v| zjk{m4t3x0&lTuQ%qaDG({ZBVWFvp$M1xsJ^J&49Q?Co%*|4~k`|Hy$v);Q2 zroL(%tx*e8FUC09cI3-aW}V8(pru z9WOtz!3|wcVz62h+93zNX*=I`z{thB)ThOxYXR2l_cNcqs&)|dNlP79Y39~Ye{1Jx zO*~cCuzKujxv`K2XYt(CF4FOc)Vl4~`Hcki;!r@6HBDdQQK^$#lG;> z;Bn2T)i{xF4f`Hnnr79R-dJn%X*Q1MVy0)^URq~)R>O#So@YIZv`KUfBBptk-eRBq zk=Z5EX@>>A^;QoF0k$cHK<7SB{ULXJh zAOHd&00JNY0w4eaAn-gAczx7qWBfczzKcgD--f0CN&K8t^l33ZJ?8bZnwGv}V2qyFNA$qem>FFcxzUVc+XFIf%0;wCaDHLUDD$|%K5CK}v5)aL)+v2ovd0V@cT zK>!3m00ck)1V8`;KmY_l00ck)1atxy?1{c$fR9e`!Knc63kGKcu~|Me9gc*<@!0 Date: Sat, 18 Nov 2017 19:41:42 -0600 Subject: [PATCH 09/11] Reviewer --- .../django_projects/reviewer/apps/__init__.py | 0 .../reviewer/apps/review_app/__init__.py | 0 .../reviewer/apps/review_app/admin.py | 3 + .../reviewer/apps/review_app/apps.py | 7 + .../review_app/migrations/0001_initial.py | 28 ++++ .../migrations/0002_author_book_review.py | 42 ++++++ .../apps/review_app/migrations/__init__.py | 0 .../reviewer/apps/review_app/models.py | 141 ++++++++++++++++++ .../static/review_app/css/style.css | 3 + .../review_app/templates/review_app/add.html | 47 ++++++ .../templates/review_app/books.html | 38 +++++ .../templates/review_app/index.html | 59 ++++++++ .../templates/review_app/review.html | 49 ++++++ .../review_app/templates/review_app/user.html | 22 +++ .../reviewer/apps/review_app/tests.py | 3 + .../reviewer/apps/review_app/urls.py | 16 ++ .../reviewer/apps/review_app/views.py | 107 +++++++++++++ .../django_projects/reviewer/db.sqlite3 | Bin 0 -> 159744 bytes .../django_projects/reviewer/manage.py | 22 +++ .../reviewer/reviewer/__init__.py | 0 .../reviewer/reviewer/settings.py | 121 +++++++++++++++ .../django_projects/reviewer/reviewer/urls.py | 21 +++ .../django_projects/reviewer/reviewer/wsgi.py | 16 ++ 23 files changed, 745 insertions(+) create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/admin.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/apps.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/0001_initial.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/0002_author_book_review.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/models.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/static/review_app/css/style.css create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/add.html create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/books.html create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/index.html create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/review.html create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/user.html create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/tests.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/urls.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/apps/review_app/views.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/db.sqlite3 create mode 100755 justin_quiros/python_stack/django_projects/reviewer/manage.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/reviewer/__init__.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/reviewer/settings.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/reviewer/urls.py create mode 100644 justin_quiros/python_stack/django_projects/reviewer/reviewer/wsgi.py diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/__init__.py b/justin_quiros/python_stack/django_projects/reviewer/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/__init__.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/admin.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/apps.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/apps.py new file mode 100644 index 0000000..3332ce0 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class ReviewAppConfig(AppConfig): + name = 'review_app' diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/0001_initial.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/0001_initial.py new file mode 100644 index 0000000..000924a --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-18 16:36 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('alias', models.CharField(max_length=255)), + ('email', models.CharField(max_length=255)), + ('password', models.CharField(max_length=255)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + ] diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/0002_author_book_review.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/0002_author_book_review.py new file mode 100644 index 0000000..ff13d3f --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/0002_author_book_review.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-11-18 20:35 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('review_app', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Author', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + ), + migrations.CreateModel( + name='Book', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=255)), + ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='books', to='review_app.Author')), + ], + ), + migrations.CreateModel( + name='Review', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('review', models.TextField()), + ('rating', models.IntegerField()), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='review_app.Book')), + ('reviewer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews_left', to='review_app.User')), + ], + ), + ] diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/__init__.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/models.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/models.py new file mode 100644 index 0000000..5aa0b51 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/models.py @@ -0,0 +1,141 @@ +from __future__ import unicode_literals + +from django.db import models +import bcrypt +import re +EMAIL_REGEX = re.compile(r'^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$') + +class UserManager(models.Manager): + + def register_validation(self, form_data): + errors = [] + + if len(form_data['name']) == 0: + errors.append( "Name is required.") + if len(form_data['alias']) == 0: + errors.append("Alias is required") + if len(form_data['email']) == 0 or not EMAIL_REGEX.match(form_data['email']): + errors.append("Email is invalid.") + if len(form_data['password']) < 8: + errors.append("Email must be atleast 8 characters.") + if form_data['password'] != form_data['conf_password']: + errors.append("Passwords did not match.") + + duplicate = User.objects.filter(email = form_data['email']) + if len(duplicate) == 1: + errors.append("This email is already registered.") + + return errors + + + + def register(self, form_data): + pw = str(form_data['password']) + hashed_pw = bcrypt.hashpw(pw, bcrypt.gensalt()) + + user = User.objects.create( + name = form_data['name'], + alias = form_data['alias'], + email = form_data['email'], + password = hashed_pw + ) + return user + + def login_validation(self, form_data): + errors = [] + user = User.objects.filter(email=form_data['email']).first() + print user + if user: + pw = str(form_data['password']) + user_password = str(user.password) + if not bcrypt.checkpw(pw.encode(), user_password.encode()): + errors.append("Invalid password.") + else: + errors.append("Invalid email.") + return errors + + + def login(self, form_data): + user = User.objects.filter(email=form_data['email']).first() + return user + + + + + + +class User(models.Model): + name = models.CharField(max_length=255) + alias = models.CharField(max_length=255) + email = models.CharField(max_length=255) + password = models.CharField(max_length=255) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + objects = UserManager() + +class Author(models.Model): + name = models.CharField(max_length=255) + +class Book(models.Model): + title = models.CharField(max_length=255) + author = models.ForeignKey(Author, related_name="books") + + + +class ReviewManager(models.Manager): + def review_validation(self, form_data): + errors = [] + + if len(form_data['title']) < 1 or len(form_data['review']) < 1: + errors.append('Title/Review fields are required') + if not "author" in form_data and len(form_data['new_author']) < 3: + rrors.append('Author names must be atleast 3 letters.') + + if "author" in form_data and len(form_data['new_author']) > 0 and len(form_data['new_author']) < 3: + errors.append('Author names must be atleast 3 letters.') + if not int(form_data['rating']) > 0 or not int(form_data['rating']) <= 5: + errors.append('invalid rating') + return errors + + def create_review(self, form_data, user_id): + + # retrive or create author + the_author = None + if len(form_data['new_author']) < 1: + the_author = Author.objects.get(id=int(form_data['author'])) + else: + the_author = Author.objects.create(name=form_data['new_author']) + + # retirive or create book + the_book = None + if not Book.objects.filter(title=form_data['title']): + the_book = Book.objects.create( + title=form_data['title'], author=the_author + ) + else: + the_book = Book.objects.get(title=form_data['title']) + + # returns a Review object + return self.create( + review = form_data['review'], + rating = form_data['rating'], + book = the_book, + reviewer = User.objects.get(id=user_id) + ) + + def recent_and_not(self): + + # returns a tuple with the zeroeth index containing query for 3 most recent reviews, and the first index + # containing the rest + + return (self.all().order_by('-created_at')[:3], self.all().order_by('-created_at')[3:]) + +class Review(models.Model): + review = models.TextField() + rating = models.IntegerField() + book = models.ForeignKey(Book, related_name="reviews") + reviewer = models.ForeignKey(User, related_name="reviews_left") + created_at = models.DateTimeField(auto_now_add=True) + objects = ReviewManager() + def __str__(self): + return "Book: {}".format(self.book.title) \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/static/review_app/css/style.css b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/static/review_app/css/style.css new file mode 100644 index 0000000..1fe37db --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/static/review_app/css/style.css @@ -0,0 +1,3 @@ +.side{ + overflow: scroll; +} \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/add.html b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/add.html new file mode 100644 index 0000000..d77c92d --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/add.html @@ -0,0 +1,47 @@ + + + + {% load static %} + + Add Book and Review + + + + +

Add a New Book and a Review

+
+ {% for error in errors %} + {{error}} + {% endfor %} +

Register

+
+ {% csrf_token %} + + +
+
+ + Choose from the list: + +
+ Or add a new author: + + + + + + +
+
+ + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/books.html b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/books.html new file mode 100644 index 0000000..905f70d --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/books.html @@ -0,0 +1,38 @@ + + + + {% load static %} + + Books Home + + + + +

Welcome, {{request.session.name}}

+
+ Add Book and Review +
+ Logout + +
+

Recent Book Reviews:

+ {% for review in recent %} +
+

{{ review.book.title }}

+

Rating: {{ review.rating }}

+

{{ review.reviewer.name}} says: {{ review.review }}

+

Posted on: {{ review.created_at }}

+
+ {% endfor %} +
+

Other Books with Reviews:

+ {% for review in more %} + + {% endfor %} +
+
+ + + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/index.html b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/index.html new file mode 100644 index 0000000..e475463 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/index.html @@ -0,0 +1,59 @@ + + + + {% load static %} + + Welcome + + + + +

Welcome!

+
+ {% for error in errors %} + {{error}} + {% endfor %} +

Register

+
+ {% csrf_token %} + + +
+
+ + +
+
+ + +
+
+ + +

*Password should be at least 8 characters

+
+ + +
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/review.html b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/review.html new file mode 100644 index 0000000..832d355 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/review.html @@ -0,0 +1,49 @@ + + + + {% load static %} + + Add Book and Review + + + + +
+

Home | Logout

+

{{book.title}}

+

{{book.author.name}}

+
+

Reviews:

+
+ {% for review in book.reviews.all %} +

Rating: {{review.rating}}

+

{{review.reviewer.name}} says: {{review.review}}

+

Posted on: {{review.created_at}}

+ {% if request.session.user_id == review.reviewer_id %} + Delete this Review + {% endif %} +
+ {% endfor %} + +
+
+ {% csrf_token %} +
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/user.html b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/user.html new file mode 100644 index 0000000..b4f4fcf --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/user.html @@ -0,0 +1,22 @@ + + + + {% load static %} + + User Reviews + + + + +

Home | Add book and review | Logout

+

User Alias: {{user.alias}}

+

Name: {{user.name}}

+

Email: {{user.email}}

+

Total Reviews: {{user.reviews_left.all.count}}

+
+

Posted Reviews on the Folowing Books

+ {% for book in unique_book_reviews %} +

{{book.title}}

+ {% endfor %} + + diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/tests.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/urls.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/urls.py new file mode 100644 index 0000000..281f21d --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/urls.py @@ -0,0 +1,16 @@ +from django.conf.urls import url +from . import views # This line is new! + +urlpatterns = [ + url(r'^$', views.index), + url(r'^login$', views.login), + url(r'^register$', views.register), + url(r'^books$', views.books), + url(r'^create', views.create), + url(r'books/(?P\d+)$', views.review), + url(r'^books/add$', views.add), + url(r'^books/(?P\d+)/add', views.add_review), + url(r'^user/(?P\d+)', views.user), + url(r'^delete/(?P\d+)', views.delete), + url(r'^logout$', views.logout), +] \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/views.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/views.py new file mode 100644 index 0000000..e1bbb18 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/views.py @@ -0,0 +1,107 @@ +from django.shortcuts import render, redirect +from django.contrib import messages +from .models import * +# Create your views here. +def index(request): + request.session['status'] = "" + if 'errors' not in request.session: + request.session['errors'] = [] + context = { + "errors": request.session['errors'] + } + return render(request, 'review_app/index.html', context) + +def register(request): + if request.method == "POST": + errors = User.objects.register_validation(request.POST) + if len(errors) != 0: + request.session['errors'] = errors + print errors + return redirect('/') + else: + user = User.objects.register(request.POST) + request.session['user_id'] = user.id + request.session['status'] = "registered." + request.session['name'] = user.name + return redirect('/books') + +def login(request): + errors = User.objects.login_validation(request.POST) + if len(errors) != 0: + request.session['errors'] = errors + return redirect('/') + else: + user = User.objects.login(request.POST) + request.session['name'] = user.name + request.session['user_id'] = user.id + request.session['status'] = "logged in." + return redirect('/books') + +def books(request): + context = { + 'recent': Review.objects.recent_and_not()[0], + 'more': Review.objects.recent_and_not()[1] + } + return render(request, 'review_app/books.html', context) + +def add(request): + context = { + "authors": Author.objects.all() + } + return render(request, 'review_app/add.html', context) + +def add_review(request, book_id): + book = Book.objects.get(id=book_id) + new_review = { + "title": book.title, + "author": book.author.id, + "rating": request.POST['rating'], + "review": request.POST['review'], + "new_author": '' + } + + errors = Review.objects.review_validation(new_review) + if errors: + for e in errors: + messages.error(request, e) + else: + Review.objects.create_review(new_review, request.session['user_id']) + return redirect('/books/{}'.format(book_id)) + +def create(request): + error = Review.objects.review_validation(request.POST) + if error: + for e in error: + messages.error(request, e) + else: + book_id = Review.objects.create_review(request.POST, request.session['user_id']).book.id + return redirect('/books/{}'.format(book_id)) + +def review(request, book_id): + context = { + "book": Book.objects.get(id=book_id) + } + return render(request, 'review_app/review.html', context) + +def user(request, user_id): + + user = User.objects.get(id=user_id) + print user + unique_ids = user.reviews_left.all().values("book").distinct() + unique_books = [] + for book in unique_ids: + unique_books.append(Book.objects.get(id=book['book'])) + context = { + 'user': user, + 'unique_book_reviews': unique_books + } + return render(request, 'review_app/user.html', context) + +def delete(request, review_id): + book_id = Review.objects.get(id=review_id).book_id + Review.objects.get(id=review_id).delete() + return redirect('/books/{}'.format(book_id)) + +def logout(request): + request.session.clear() + return redirect('/') \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/db.sqlite3 b/justin_quiros/python_stack/django_projects/reviewer/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..621df35b74105c3cd485a4b685271d30c2be6d0a GIT binary patch literal 159744 zcmeI5e{37qeZcR?BTxMKY{?4k*s@NN6`NH=-4Fhho5r-wII=CtKjg$Ry0J&`B%Mu> zG)c)nuymtbWZl~SQ((gi3`2nw=r-(+6;H5=Ns=-Tx+)^=F7cI$u? z*xq}0=>z&MqeU%zW3hu*ZaJ8Ki<1X>f-scdP5VIE44MXAt=l)hGm&!g1|7$ zbNK(m`2W`DBtGC;8T>D6JKpN>IVQIEB@YosuMwGj=(X@b;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aMi2!+- hA0|nVB-ZPHjxGRj=IehPoR^~u0B*Vf;O=_=|NnM269)hQ literal 0 HcmV?d00001 diff --git a/justin_quiros/python_stack/django_projects/reviewer/manage.py b/justin_quiros/python_stack/django_projects/reviewer/manage.py new file mode 100755 index 0000000..db4b49b --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "reviewer.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/justin_quiros/python_stack/django_projects/reviewer/reviewer/__init__.py b/justin_quiros/python_stack/django_projects/reviewer/reviewer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/justin_quiros/python_stack/django_projects/reviewer/reviewer/settings.py b/justin_quiros/python_stack/django_projects/reviewer/reviewer/settings.py new file mode 100644 index 0000000..190bffa --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/reviewer/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for reviewer project. + +Generated by 'django-admin startproject' using Django 1.11.6. + +For more information on this file, see +https://docs.djangoproject.com/en/1.11/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.11/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'b=0yiw6s_2f@f9cr7p7@6xi2+5(0!-6fqc=01+a6eser7ks)+d' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.review_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'reviewer.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'reviewer.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.11/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/justin_quiros/python_stack/django_projects/reviewer/reviewer/urls.py b/justin_quiros/python_stack/django_projects/reviewer/reviewer/urls.py new file mode 100644 index 0000000..7f72ffa --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/reviewer/urls.py @@ -0,0 +1,21 @@ +"""reviewer URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.11/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.review_app.urls')), +] diff --git a/justin_quiros/python_stack/django_projects/reviewer/reviewer/wsgi.py b/justin_quiros/python_stack/django_projects/reviewer/reviewer/wsgi.py new file mode 100644 index 0000000..0c3b548 --- /dev/null +++ b/justin_quiros/python_stack/django_projects/reviewer/reviewer/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for reviewer 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/1.11/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "reviewer.settings") + +application = get_wsgi_application() From c49bb383e1253bb699a2376da69fe26f6709b7a9 Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Mon, 20 Nov 2017 08:26:38 -0600 Subject: [PATCH 10/11] Word Generator fix --- .../main/apps/word_gen/views.py | 2 +- .../word_generator/main/db.sqlite3 | Bin 131072 -> 131072 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/justin_quiros/python_stack/django_projects/word_generator/main/apps/word_gen/views.py b/justin_quiros/python_stack/django_projects/word_generator/main/apps/word_gen/views.py index 04f9771..1953a2e 100644 --- a/justin_quiros/python_stack/django_projects/word_generator/main/apps/word_gen/views.py +++ b/justin_quiros/python_stack/django_projects/word_generator/main/apps/word_gen/views.py @@ -4,7 +4,7 @@ def index(request): - if request.session['attempt'] == None: + if request.session.get('attempt') == None: request.session['attempt'] = 1 else: request.session['attempt'] += 1 diff --git a/justin_quiros/python_stack/django_projects/word_generator/main/db.sqlite3 b/justin_quiros/python_stack/django_projects/word_generator/main/db.sqlite3 index 2bcd036bca2168b4809aa11e0699e587c1c91b0c..50728534711735b80b30d8295617ab241be3073a 100644 GIT binary patch delta 358 zcmZo@;Am*zm>|vQF;T{u(PLx6l70>*zBLT|VSH;gD=IADt8Y|iV)bo|bu`VYDl;`P zOUp6OFfq?bG*3+}$j&k>GBGzdHps8c%#U&jEcbW!t@ICx%J!@BH1uZ)f1&&VOgKV8UvCRTXAmMnb+|YQD36`|vQFj2;t(P3l4l72Qu{xAmqu+54J-u#^F8r2zDeH&vPCqG!PFu87i z8wVr*9R?uc+ANrGfxr3A`t5htGio>hH9cbBe*_e~!7nGv?8s?kU}&yuXsBysu3%(n PWnuwDdd8-vrWS?(F#sYW From 8290ff1df333610c9b1e6b0be0873770239c1795 Mon Sep 17 00:00:00 2001 From: Justin Quiros Date: Tue, 21 Nov 2017 07:32:08 -0600 Subject: [PATCH 11/11] Updates --- .../reviewer/apps/review_app/models.py | 7 ++++++- .../templates/review_app/books.html | 1 - .../reviewer/apps/review_app/urls.py | 3 ++- .../reviewer/apps/review_app/views.py | 17 ++++++++++------- .../django_projects/reviewer/db.sqlite3 | Bin 159744 -> 159744 bytes .../word_app/static/word_app/css/style.css | 3 ++- .../word_app/templates/word_app/index.html | 2 +- .../session_words/main/apps/word_app/views.py | 1 - 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/models.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/models.py index 5aa0b51..f2cbe23 100644 --- a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/models.py +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/models.py @@ -73,6 +73,7 @@ class User(models.Model): updated_at = models.DateTimeField(auto_now=True) objects = UserManager() + class Author(models.Model): name = models.CharField(max_length=255) @@ -82,6 +83,10 @@ class Book(models.Model): + + + + class ReviewManager(models.Manager): def review_validation(self, form_data): errors = [] @@ -89,7 +94,7 @@ def review_validation(self, form_data): if len(form_data['title']) < 1 or len(form_data['review']) < 1: errors.append('Title/Review fields are required') if not "author" in form_data and len(form_data['new_author']) < 3: - rrors.append('Author names must be atleast 3 letters.') + errors.append('Author names must be atleast 3 letters.') if "author" in form_data and len(form_data['new_author']) > 0 and len(form_data['new_author']) < 3: errors.append('Author names must be atleast 3 letters.') diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/books.html b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/books.html index 905f70d..9578582 100644 --- a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/books.html +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/templates/review_app/books.html @@ -33,6 +33,5 @@

{{ review.book.title }}

{% endfor %} - \ No newline at end of file diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/urls.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/urls.py index 281f21d..5cd0bac 100644 --- a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/urls.py +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/urls.py @@ -13,4 +13,5 @@ url(r'^user/(?P\d+)', views.user), url(r'^delete/(?P\d+)', views.delete), url(r'^logout$', views.logout), -] \ No newline at end of file +] + diff --git a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/views.py b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/views.py index e1bbb18..4a135f3 100644 --- a/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/views.py +++ b/justin_quiros/python_stack/django_projects/reviewer/apps/review_app/views.py @@ -27,7 +27,7 @@ def register(request): def login(request): errors = User.objects.login_validation(request.POST) - if len(errors) != 0: + if len(errors) != 0: request.session['errors'] = errors return redirect('/') else: @@ -46,7 +46,8 @@ def books(request): def add(request): context = { - "authors": Author.objects.all() + "authors": Author.objects.all(), + "errors": request.session['errors'] } return render(request, 'review_app/add.html', context) @@ -69,10 +70,11 @@ def add_review(request, book_id): return redirect('/books/{}'.format(book_id)) def create(request): - error = Review.objects.review_validation(request.POST) - if error: - for e in error: - messages.error(request, e) + errors = Review.objects.review_validation(request.POST) + + if len(errors) != 0: + request.session['errors'] = errors + return redirect('/books/add') else: book_id = Review.objects.create_review(request.POST, request.session['user_id']).book.id return redirect('/books/{}'.format(book_id)) @@ -86,11 +88,12 @@ def review(request, book_id): def user(request, user_id): user = User.objects.get(id=user_id) - print user unique_ids = user.reviews_left.all().values("book").distinct() unique_books = [] + for book in unique_ids: unique_books.append(Book.objects.get(id=book['book'])) + context = { 'user': user, 'unique_book_reviews': unique_books diff --git a/justin_quiros/python_stack/django_projects/reviewer/db.sqlite3 b/justin_quiros/python_stack/django_projects/reviewer/db.sqlite3 index 621df35b74105c3cd485a4b685271d30c2be6d0a..167a4c08313f9c3b39c5a50dd500c52c65fbd5b3 100644 GIT binary patch delta 2184 zcmbtVTZ|KB6z)vhEp@v+3oN_Y09wt8S7ztlPIZN$%PuY3?iSkZPDy~?ww>N)y4`l# zCZ?>H2k}M0WMjYwiBTRf1Xi+`V2l`}iDDuocnJzB#Hfk#puA{;GlMKkSLMNn|77x? z|NP%~zH|OFdoEe`T(Z8f8oB)98V_>$*zRw!?%tJl<0Hsasw$?GT`^hS6_=!(ZGWWy zFw%A$H|_3hv+XrN+J4qP&~c<=wQcX*y^gA_Ib(0L8dj}(V8+bz+r&ghTT|-Vs2MCF z75d0{A3^p7bLFh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8D;~7>t^D=V9H0x-$d18|%GClear Session - {% for i in request.session.word %} + {% for i in request.session.word %}

{{i.word}} {{i.display}}

{% endfor %} diff --git a/justin_quiros/python_stack/django_projects/session_words/main/apps/word_app/views.py b/justin_quiros/python_stack/django_projects/session_words/main/apps/word_app/views.py index befca28..f3ce375 100644 --- a/justin_quiros/python_stack/django_projects/session_words/main/apps/word_app/views.py +++ b/justin_quiros/python_stack/django_projects/session_words/main/apps/word_app/views.py @@ -28,7 +28,6 @@ def process(request): return redirect('/display') - def display(request): return redirect('/')