From 4bb40e44cf2674b8b7c442d8dbbdd068479ba159 Mon Sep 17 00:00:00 2001 From: Matir11 <51160306+Matir11@users.noreply.github.com> Date: Tue, 15 Mar 2022 23:37:20 -0400 Subject: [PATCH 1/8] Lab 5 --- Code/eric/html/labs/lab_5/index.html | 87 ++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Code/eric/html/labs/lab_5/index.html diff --git a/Code/eric/html/labs/lab_5/index.html b/Code/eric/html/labs/lab_5/index.html new file mode 100644 index 00000000..f9cee241 --- /dev/null +++ b/Code/eric/html/labs/lab_5/index.html @@ -0,0 +1,87 @@ + + + + + + + Super Caliente Burritos + + +
+ + + + +
+ + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + +
+ + +
+ + + + + \ No newline at end of file From ac8c00212ce1540b876dcac1dab45110b8b08727 Mon Sep 17 00:00:00 2001 From: Matir11 <51160306+Matir11@users.noreply.github.com> Date: Wed, 16 Mar 2022 22:06:07 -0400 Subject: [PATCH 2/8] updated is css --- Code/eric/html/labs/lab_5/index.html | 55 ++++++++++++++++++---------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/Code/eric/html/labs/lab_5/index.html b/Code/eric/html/labs/lab_5/index.html index f9cee241..b06fdb1c 100644 --- a/Code/eric/html/labs/lab_5/index.html +++ b/Code/eric/html/labs/lab_5/index.html @@ -5,22 +5,33 @@ Super Caliente Burritos + - -
+
+ +
+ + + +
+ class="input is-danger is-medium is-rounded" + type="password" + name="password" + placeholder="enter a password"> +

+
+

What kind of tortilla?

@@ -32,25 +43,28 @@ - +

- +
+

What kind of rice?

- +

- +
+

What kind of beans?

- +

- +
+

What kind of protein?

@@ -62,23 +76,26 @@ - +

- +
+

Would you like...

- +

- +
+
From f7bf3d06f28fc34ddbbbb7d5a1ba046fbb33f5fb Mon Sep 17 00:00:00 2001 From: Matir11 <51160306+Matir11@users.noreply.github.com> Date: Sat, 19 Mar 2022 00:11:31 -0400 Subject: [PATCH 3/8] Lab 6 --- Code/eric/html/labs/lab_6/app.py | 51 +++++++++++++++++++ .../eric/html/labs/lab_6/templates/index.html | 13 +++++ .../html/labs/lab_6/templates/results.html | 0 3 files changed, 64 insertions(+) create mode 100644 Code/eric/html/labs/lab_6/app.py create mode 100644 Code/eric/html/labs/lab_6/templates/index.html create mode 100644 Code/eric/html/labs/lab_6/templates/results.html diff --git a/Code/eric/html/labs/lab_6/app.py b/Code/eric/html/labs/lab_6/app.py new file mode 100644 index 00000000..7afbdc5e --- /dev/null +++ b/Code/eric/html/labs/lab_6/app.py @@ -0,0 +1,51 @@ +from crypt import methods +from unittest import result +from flask import Flask, render_template, request + +app = Flask(__name__) + +# route items to the index +@app.route('/') +def index(): + return render_template('index.html') + +#route the actual application +@app.route('/converter', methods = ['POST']) +def convertor(): + result = request.form + + user = result['measure_in'] + + conversion_in = { + 'ft' : .3048, + 'mi' : 1609.34, + 'm' : 1, + 'km' : 1000 +} + +conversion_out = { + 'ft' : 1/.3048, + 'mi' : 1/1609.34, + 'm' : 1, + 'km' : 1/1000 +} + +#build input +distance=input("what is the distance? ") +distance=int(distance) + +unit_in=input("what are the input units? choose ft, mi, km: ") +unit_out=input("what are the output units? choose ft, mi, km: ") + +#enter sausage maker +if unit_in in conversion_in and unit_out in conversion_out: + converted_to_meters = conversion_in[unit_in] + distance_in_meters = converted_to_meters * distance + meters_out = conversion_out[unit_out] + final_conversion = meters_out * distance_in_meters + print(f"{distance}{unit_in} is {round(final_conversion,4)}{unit_out}") + +else: + print("unit not recognized") + + return render_template('results.html', user=user) \ No newline at end of file diff --git a/Code/eric/html/labs/lab_6/templates/index.html b/Code/eric/html/labs/lab_6/templates/index.html new file mode 100644 index 00000000..ee705387 --- /dev/null +++ b/Code/eric/html/labs/lab_6/templates/index.html @@ -0,0 +1,13 @@ + + + + + + + Unit Converter + + +

Unit Converter

+
+ + \ No newline at end of file diff --git a/Code/eric/html/labs/lab_6/templates/results.html b/Code/eric/html/labs/lab_6/templates/results.html new file mode 100644 index 00000000..e69de29b From 3b9d1b4525330442ec11bec54a134e2d7a3cf8a8 Mon Sep 17 00:00:00 2001 From: Matir11 Date: Tue, 5 Apr 2022 20:10:07 -0700 Subject: [PATCH 4/8] First Django Lab --- .../lab1redo_proj/lab1redo_app/__init__.py | 0 .../lab1redo_proj/lab1redo_app/admin.py | 3 + .../lab1redo_proj/lab1redo_app/apps.py | 6 + .../lab1redo_app/migrations/__init__.py | 0 .../lab1redo_proj/lab1redo_app/models.py | 3 + .../templates/lab1redo_app/index.html | 18 +++ .../lab1redo_proj/lab1redo_app/tests.py | 3 + .../lab1redo_proj/lab1redo_app/urls.py | 15 +++ .../lab1redo_proj/lab1redo_app/views.py | 46 +++++++ .../lab1redo_proj/lab1redo_proj/__init__.py | 0 .../lab1redo_proj/lab1redo_proj/asgi.py | 16 +++ .../lab1redo_proj/lab1redo_proj/settings.py | 126 ++++++++++++++++++ .../lab1redo_proj/lab1redo_proj/urls.py | 21 +++ .../lab1redo_proj/lab1redo_proj/wsgi.py | 16 +++ .../django_projects/lab1redo_proj/manage.py | 22 +++ 15 files changed, 295 insertions(+) create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/__init__.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/admin.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/apps.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/migrations/__init__.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/models.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/templates/lab1redo_app/index.html create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/tests.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/urls.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/views.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_proj/__init__.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_proj/asgi.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_proj/settings.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_proj/urls.py create mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_proj/wsgi.py create mode 100755 Code/eric/django_projects/lab1redo_proj/manage.py diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/__init__.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/admin.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/apps.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/apps.py new file mode 100644 index 00000000..ac422649 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class Lab1RedoAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'lab1redo_app' diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/migrations/__init__.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/models.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/templates/lab1redo_app/index.html b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/templates/lab1redo_app/index.html new file mode 100644 index 00000000..a4bde0e6 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/templates/lab1redo_app/index.html @@ -0,0 +1,18 @@ + + + + + + + Rot 13 + + + +
+ + +
+ +

{{value_sting

+ + \ No newline at end of file diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/tests.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/urls.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/urls.py new file mode 100644 index 00000000..28f6100d --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/urls.py @@ -0,0 +1,15 @@ +from django.urls import path, include +from . import views + +app_name = 'rot' + +urlpatterns = [ + # 127.0.0.1:8000 + path('', views.index, name='index'), + + + path('/rot/', views.rot, name='rot') + + + +] \ No newline at end of file diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/views.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/views.py new file mode 100644 index 00000000..928f2758 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/views.py @@ -0,0 +1,46 @@ +from django.shortcuts import render + +# Create your views here. +def index(request): + return render(request, 'lab1redo_app/index.html') + +def rot(request): + letter_values = { + 'a' : 'n', + 'b' : 'o', + 'c' : 'p', + 'd' : 'q', + 'e' : 'r', + 'f' : 's', + 'g' : 't', + 'h' : 'u', + 'i' : 'v', + 'j' : 'w', + 'k' : 'x', + 'l' : 'y', + 'm' : 'z', + 'n' : 'a', + 'o' : 'b', + 'p' : 'c', + 'q' : 'd', + 'r' : 'e', + 's' : 'f', + 't' : 'g', + 'u' : 'h', + 'v' : 'i', + 'w' : 'j', + 'x' : 'k', + 'y' : 'l', + 'z' : 'm' + } + + user_string = request.GET.get('plain_text', '').lower() + value_string = " " + for letter in user_string: + letters = letter in letter_values.get() + if letters == True: + value_string += letter_values[letter] + + return render(request, 'index.html', {'Converted Text':value_string}) + + diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/__init__.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/asgi.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/asgi.py new file mode 100644 index 00000000..b7e1280a --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for lab1redo_proj project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lab1redo_proj.settings') + +application = get_asgi_application() diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/settings.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/settings.py new file mode 100644 index 00000000..c348ef71 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for lab1redo_proj project. + +Generated by 'django-admin startproject' using Django 4.0.3. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.0/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-pff+i!=*&u@_s()&o-%&^t3ap)&2-ex_#_s3w&dyu9ws@ev$w9' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + # project app + 'lab1redo.app', +] + +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 = 'lab1redo_proj.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 = 'lab1redo_proj.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'America/New_York' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.0/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/urls.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/urls.py new file mode 100644 index 00000000..3d63057d --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/urls.py @@ -0,0 +1,21 @@ +"""lab1redo_proj URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/wsgi.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/wsgi.py new file mode 100644 index 00000000..1a3af340 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for lab1redo_proj project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lab1redo_proj.settings') + +application = get_wsgi_application() diff --git a/Code/eric/django_projects/lab1redo_proj/manage.py b/Code/eric/django_projects/lab1redo_proj/manage.py new file mode 100755 index 00000000..e658b2e5 --- /dev/null +++ b/Code/eric/django_projects/lab1redo_proj/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lab1redo_proj.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() From 6d0c4b85ec64f949dd6347e65924c11d2f5d66d6 Mon Sep 17 00:00:00 2001 From: matir11 Date: Wed, 4 May 2022 23:11:46 -0400 Subject: [PATCH 5/8] django todo list --- Code/eric/django_projects/todo/manage.py | 22 ++++ .../django_projects/todo/todo_app/__init__.py | 0 .../django_projects/todo/todo_app/admin.py | 3 + .../django_projects/todo/todo_app/apps.py | 6 + .../django_projects/todo/todo_app/forms.py | 8 ++ .../todo/todo_app/migrations/__init__.py | 0 .../django_projects/todo/todo_app/models.py | 14 ++ .../todo/todo_app/templates/todo/index.html | 20 +++ .../todo_app/templates/todo/saved_todos.html | 15 +++ .../django_projects/todo/todo_app/tests.py | 3 + .../django_projects/todo/todo_app/urls.py | 7 + .../django_projects/todo/todo_app/views.py | 30 +++++ .../todo/todo_proj/__init__.py | 0 .../django_projects/todo/todo_proj/asgi.py | 16 +++ .../todo/todo_proj/settings.py | 124 ++++++++++++++++++ .../django_projects/todo/todo_proj/urls.py | 22 ++++ .../django_projects/todo/todo_proj/wsgi.py | 16 +++ 17 files changed, 306 insertions(+) create mode 100755 Code/eric/django_projects/todo/manage.py create mode 100644 Code/eric/django_projects/todo/todo_app/__init__.py create mode 100644 Code/eric/django_projects/todo/todo_app/admin.py create mode 100644 Code/eric/django_projects/todo/todo_app/apps.py create mode 100644 Code/eric/django_projects/todo/todo_app/forms.py create mode 100644 Code/eric/django_projects/todo/todo_app/migrations/__init__.py create mode 100644 Code/eric/django_projects/todo/todo_app/models.py create mode 100644 Code/eric/django_projects/todo/todo_app/templates/todo/index.html create mode 100644 Code/eric/django_projects/todo/todo_app/templates/todo/saved_todos.html create mode 100644 Code/eric/django_projects/todo/todo_app/tests.py create mode 100644 Code/eric/django_projects/todo/todo_app/urls.py create mode 100644 Code/eric/django_projects/todo/todo_app/views.py create mode 100644 Code/eric/django_projects/todo/todo_proj/__init__.py create mode 100644 Code/eric/django_projects/todo/todo_proj/asgi.py create mode 100644 Code/eric/django_projects/todo/todo_proj/settings.py create mode 100644 Code/eric/django_projects/todo/todo_proj/urls.py create mode 100644 Code/eric/django_projects/todo/todo_proj/wsgi.py diff --git a/Code/eric/django_projects/todo/manage.py b/Code/eric/django_projects/todo/manage.py new file mode 100755 index 00000000..00a51e0f --- /dev/null +++ b/Code/eric/django_projects/todo/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_app.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/Code/eric/django_projects/todo/todo_app/__init__.py b/Code/eric/django_projects/todo/todo_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/todo/todo_app/admin.py b/Code/eric/django_projects/todo/todo_app/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/eric/django_projects/todo/todo_app/apps.py b/Code/eric/django_projects/todo/todo_app/apps.py new file mode 100644 index 00000000..d8f1498d --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class TodoAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'todo_app' diff --git a/Code/eric/django_projects/todo/todo_app/forms.py b/Code/eric/django_projects/todo/todo_app/forms.py new file mode 100644 index 00000000..91073e84 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/forms.py @@ -0,0 +1,8 @@ +from django import forms +from .models import ToDo + + +class ToDoForm(forms.ModelForm): + class Meta: + model = ToDo + fields = ('text', 'priority') \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_app/migrations/__init__.py b/Code/eric/django_projects/todo/todo_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/todo/todo_app/models.py b/Code/eric/django_projects/todo/todo_app/models.py new file mode 100644 index 00000000..87cc26cc --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/models.py @@ -0,0 +1,14 @@ +from django.db import models +from django.contrib.auth.models import User +# Create your models here. +PRIO_CHOICES = ( + ('high', 'High'), + ('medium', 'Medium'), + ('low', 'Low'), +) +class ToDo(models.Model): + text = models.CharField(max_length=120, ) + priority = models.CharField(max_length=6, choices=PRIO_CHOICES, default='medium') + + + created_date = models.DateTimeField(auto_now=True) diff --git a/Code/eric/django_projects/todo/todo_app/templates/todo/index.html b/Code/eric/django_projects/todo/todo_app/templates/todo/index.html new file mode 100644 index 00000000..50f7dd7a --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/templates/todo/index.html @@ -0,0 +1,20 @@ + + + + + + + To Do List + + +
To Do List
+ Add To Do + {% for todo in todos %} +
+ + {{todo.text}} - {{todo.priority}} + +
+ {% endfor %} + + \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_app/templates/todo/saved_todos.html b/Code/eric/django_projects/todo/todo_app/templates/todo/saved_todos.html new file mode 100644 index 00000000..2112f679 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/templates/todo/saved_todos.html @@ -0,0 +1,15 @@ + + + + + + + Saved To Dos + + +
+ {% csrf_token %} + {{ form.as_p}} + + + \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_app/tests.py b/Code/eric/django_projects/todo/todo_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/eric/django_projects/todo/todo_app/urls.py b/Code/eric/django_projects/todo/todo_app/urls.py new file mode 100644 index 00000000..3e0428f1 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.index, name='index'), + path('saved_todos', views.new_todo, name='new_todo'), +] \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_app/views.py b/Code/eric/django_projects/todo/todo_app/views.py new file mode 100644 index 00000000..ad86aee7 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/views.py @@ -0,0 +1,30 @@ +from django.shortcuts import render +from django.http import HttpResponseRedirect +from django.contrib.auth.models import User +from django.urls import reverse +from .forms import * +# Create your views here. + +def index(request): + if request.method == "GET": + todos = ToDo.objects.all() + return render(request, 'index.html',{ + 'todos':todos, + 'form': ToDoForm,} + ) + + +# Create your views here. +def new_todo(request): + if request.method == "POST": + form = ToDoForm(request.POST) + if form.is_valid(): + todo = ToDo() + todo.priority = form.cleaned_data['priority'] + todo.text = form.cleaned_data['text'] + todo.save() + return HttpResponseRedirect(reverse('index')) + if request.method == "GET": + form = ToDoForm() + + return render(request,'saved_todos.html', {'form': form} ) \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_proj/__init__.py b/Code/eric/django_projects/todo/todo_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/todo/todo_proj/asgi.py b/Code/eric/django_projects/todo/todo_proj/asgi.py new file mode 100644 index 00000000..2e24ed38 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for todo_app project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_app.settings') + +application = get_asgi_application() diff --git a/Code/eric/django_projects/todo/todo_proj/settings.py b/Code/eric/django_projects/todo/todo_proj/settings.py new file mode 100644 index 00000000..80e84b35 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_proj/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for todo_proj project. + +Generated by 'django-admin startproject' using Django 4.0.4. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.0/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-939n1tx)0m7-8k1@#-7p_z4mc^9gn&d!k)#=(a4bl@-ivflv@$' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'todo_app' +] + +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 = 'todo_proj.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 = 'todo_proj.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'America/New_York' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.0/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/Code/eric/django_projects/todo/todo_proj/urls.py b/Code/eric/django_projects/todo/todo_proj/urls.py new file mode 100644 index 00000000..09b1b37b --- /dev/null +++ b/Code/eric/django_projects/todo/todo_proj/urls.py @@ -0,0 +1,22 @@ +"""todo_app URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import include, path + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('todo_app.urls')) +] diff --git a/Code/eric/django_projects/todo/todo_proj/wsgi.py b/Code/eric/django_projects/todo/todo_proj/wsgi.py new file mode 100644 index 00000000..2229e7b2 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for todo_app project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_app.settings') + +application = get_wsgi_application() From 2844004550d58573390758939714f6536a5c4249 Mon Sep 17 00:00:00 2001 From: matir11 Date: Fri, 6 May 2022 22:25:50 -0400 Subject: [PATCH 6/8] JS redo lab --- Code/eric/js/redo/app.js | 61 ++++++++++++++++++++++++++++++++++++ Code/eric/js/redo/index.html | 14 +++++++++ 2 files changed, 75 insertions(+) create mode 100644 Code/eric/js/redo/app.js create mode 100644 Code/eric/js/redo/index.html diff --git a/Code/eric/js/redo/app.js b/Code/eric/js/redo/app.js new file mode 100644 index 00000000..89a2bd8c --- /dev/null +++ b/Code/eric/js/redo/app.js @@ -0,0 +1,61 @@ +// JavaScript redo lab of ROT13 cypher + +// Accept input +let user_string = prompt("Please enter a message: ") + +// Make it all lower case +user_string = user_string.toLowerCase() + +// Dictionary +/* +let letter_values = { + y : 'a', + o : 'd', + d : 'o', + a : 'y' +} +*/ +let letter_values = { + 'a' : 'n', + 'b' : 'o', + 'c' : 'p', + 'd' : 'q', + 'e' : 'r', + 'f' : 's', + 'g' : 't', + 'h' : 'u', + 'i' : 'v', + 'j' : 'w', + 'k' : 'x', + 'l' : 'y', + 'm' : 'z', + 'n' : 'a', + 'o' : 'b', + 'p' : 'c', + 'q' : 'd', + 'r' : 'e', + 's' : 'f', + 't' : 'g', + 'u' : 'h', + 'v' : 'i', + 'w' : 'j', + 'x' : 'k', + 'y' : 'l', + 'z' : 'm' +} +// console.log(letter_values) +// set null variable +let coded_word = "" +// Meat Grinder +function rot13(input) { + for (letter of input){ + // console.log(letter, letter_values[letter]) + coded_word += letter_values[letter] + } + return coded_word +} + +let finished = rot13(user_string) +alert(finished) +// console.log(coded_word) +// console.log("string") \ No newline at end of file diff --git a/Code/eric/js/redo/index.html b/Code/eric/js/redo/index.html new file mode 100644 index 00000000..32a7f203 --- /dev/null +++ b/Code/eric/js/redo/index.html @@ -0,0 +1,14 @@ + + + + + + + ReDo + + + + + + + \ No newline at end of file From 3f38506d60e6ccd41fcaec95c6e31228e1175571 Mon Sep 17 00:00:00 2001 From: matir11 Date: Fri, 24 Jun 2022 18:01:42 -0400 Subject: [PATCH 7/8] added todo and vue_redo labs --- Code/eric/js/APIS/app.js | 62 +++++++++++++++++ Code/eric/js/APIS/index.html | 20 ++++++ Code/eric/js/todo_list/app.js | 50 ++++++++++++++ Code/eric/js/todo_list/index.html | 20 ++++++ Code/eric/js/vue_redo/index.html | 68 +++++++++++++++++++ Code/eric/js/vue_redo/test.html | 106 ++++++++++++++++++++++++++++++ Code/eric/js/vue_todo/index.html | 102 ++++++++++++++++++++++++++++ 7 files changed, 428 insertions(+) create mode 100644 Code/eric/js/APIS/app.js create mode 100644 Code/eric/js/APIS/index.html create mode 100644 Code/eric/js/todo_list/app.js create mode 100644 Code/eric/js/todo_list/index.html create mode 100644 Code/eric/js/vue_redo/index.html create mode 100644 Code/eric/js/vue_redo/test.html create mode 100644 Code/eric/js/vue_todo/index.html diff --git a/Code/eric/js/APIS/app.js b/Code/eric/js/APIS/app.js new file mode 100644 index 00000000..dcda3069 --- /dev/null +++ b/Code/eric/js/APIS/app.js @@ -0,0 +1,62 @@ +console.log("start of code") + +const shuffleBtn = document.querySelector("#shuffle-btn") +const dealBtn = document.querySelector("#deal-btn") +let deckID = null +let hands = { + dealer: [], + player: [] +} + +// getCards is a function. leave the () off so it is activated by the click +shuffleBtn.addEventListener("click", getCards) + +dealBtn.addEventListener("click", dealCards) + +// this returns a promise causing the app to run out of order and require the .then +// fetch("https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1") +// .then(function(data) { +// return data.json() +// } +// ).then(function(data){ +// console.log(data) +// }) + +// async forces the app to go line by line instead of spinning off other threads +async function getCards() { + // await tells the code to hold on until there is a return from the fetch + const response = await fetch("https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1") + const data = await response.json() + console.log(data) + deckID = data.deck_id +} + +async function dealCards(){ + // the `${}` acts like an f string in python + const url = `https://deckofcardsapi.com/api/deck/${deckID}/draw/?count=4` + const response = await fetch(url) + const data = await response.json() + + hands.dealer = data.cards.splice(0,2) + hands.player = data.cards + showcards() + showcards(true) + // console.log(data) +} + +function showcards(dealer = false){ + const hand = dealer ? hands.dealer : hands.player + const selector = dealer ? "#dealer" : "#player" + const handContainer = document.querySelector(selector) + handContainer.innerHTML = "" + for (card of hand){ + const cardImg = document.createElement('img') + cardImg.src = card.image + handContainer.append(cardImg) + } +} + + + + +console.log("end of code") \ No newline at end of file diff --git a/Code/eric/js/APIS/index.html b/Code/eric/js/APIS/index.html new file mode 100644 index 00000000..bbb6a709 --- /dev/null +++ b/Code/eric/js/APIS/index.html @@ -0,0 +1,20 @@ + + + + + + + Cards + + + +
+ + + +
+
+ +
+ + \ No newline at end of file diff --git a/Code/eric/js/todo_list/app.js b/Code/eric/js/todo_list/app.js new file mode 100644 index 00000000..f51a25d1 --- /dev/null +++ b/Code/eric/js/todo_list/app.js @@ -0,0 +1,50 @@ +// add items to a list +// be able to remove items +// mark the items as completed and have the text strikethrough + +// global variables +const inputTodo = document.querySelector('#input') +const inputAdd = document.querySelector('#add') +const inputList = document.querySelector('#list') + +inputAdd.addEventListener('click', addTask) + +// task function +function addTask(){ + const textTodo = inputTodo.value + const addedTask = document.createElement('li') + const buttonSpan = document.createElement('span') + buttonSpan.textContent = textTodo + addedTask.append(buttonSpan) + inputList.appendChild(addedTask) + inputTodo.value = '' + + // complete button with strikethrough + const completeButton = document.createElement('button') + completeButton.textContent = 'Complete' + addedTask.append(completeButton) + + // remove button that makes it disappear + const removeButton = document.createElement('button') + removeButton.textContent = 'Remove' + addedTask.append(removeButton) + removeButton.addEventListener('click', function(){ + inputList.removeChild(removeButton.parentElement) + }) + + completeButton.addEventListener('click', function(){ + const buttonParent = completeButton.parentElement + const buttonSpan = buttonParent.querySelector('span') + + // create a function to determine if the text is complete + if(buttonSpan.style.textDecoration === 'line-through'){ + buttonSpan.style.textDecoration = 'none' + } + + else{ + buttonSpan.style.textDecoration = 'line-through' + inputList.removeChild(buttonParent) + inputList.append(buttonParent) + } + }) +} \ No newline at end of file diff --git a/Code/eric/js/todo_list/index.html b/Code/eric/js/todo_list/index.html new file mode 100644 index 00000000..a338646e --- /dev/null +++ b/Code/eric/js/todo_list/index.html @@ -0,0 +1,20 @@ + + + + + + + To Do + + + + +

To Do List

+
+ + +
+
    + + + \ No newline at end of file diff --git a/Code/eric/js/vue_redo/index.html b/Code/eric/js/vue_redo/index.html new file mode 100644 index 00000000..505159f3 --- /dev/null +++ b/Code/eric/js/vue_redo/index.html @@ -0,0 +1,68 @@ + + + + + + + + Vue ReDo + + + + + +
    +

    Rock, Paper, Scissors

    +
    + + + +
    + +
    +

    Computer chose {{computerSelect}}. The winner is {{result}}

    +
    +
    + + + + + + \ No newline at end of file diff --git a/Code/eric/js/vue_redo/test.html b/Code/eric/js/vue_redo/test.html new file mode 100644 index 00000000..1131a2bc --- /dev/null +++ b/Code/eric/js/vue_redo/test.html @@ -0,0 +1,106 @@ + + \ No newline at end of file diff --git a/Code/eric/js/vue_todo/index.html b/Code/eric/js/vue_todo/index.html new file mode 100644 index 00000000..4a38cec7 --- /dev/null +++ b/Code/eric/js/vue_todo/index.html @@ -0,0 +1,102 @@ + + + + + + + Document + + + + + + + +
    +

    {{headerText}}

    + +
    +
    + + +
    + +
    +

    Incomplete

    +
    + + {{todo.id}} {{todo.text}} +
    + + +
    +
    +
    + +
    +

    Complete

    +
    + + + {{todo.id}} {{todo.text}} + +
    + + +
    +
    +
    + + +
    + +
    + + + + + + \ No newline at end of file From 80071e0fb61ce5d25abaecf91d759ce6626250c3 Mon Sep 17 00:00:00 2001 From: matir11 Date: Fri, 24 Jun 2022 18:02:54 -0400 Subject: [PATCH 8/8] added redo and todo labs, grocery still in progress --- .../grocery_app}/__init__.py | 0 .../grocery/grocery_app/admin.py | 6 + .../grocery_app}/apps.py | 4 +- .../grocery_app/migrations/0001_initial.py | 31 +++++ .../grocery_app}/migrations/__init__.py | 0 .../grocery/grocery_app/models.py | 19 +++ .../templates/grocery_app/index.html | 48 +++++++ .../grocery_app}/tests.py | 0 .../grocery/grocery_app/urls.py | 13 ++ .../grocery/grocery_app/views.py | 40 ++++++ .../grocery_proj}/__init__.py | 0 .../grocery/grocery_proj/asgi.py | 16 +++ .../grocery/grocery_proj/settings.py | 127 ++++++++++++++++++ .../grocery/grocery_proj/urls.py | 22 +++ .../grocery/grocery_proj/wsgi.py | 16 +++ Code/eric/django_projects/grocery/manage.py | 22 +++ .../templates/lab1redo_app/index.html | 18 --- .../lab1redo_proj/lab1redo_app/urls.py | 15 --- .../lab1redo_proj/lab1redo_app/views.py | 46 ------- .../{lab1redo_proj => password}/manage.py | 2 +- .../password/password_app/__init__.py | 0 .../password_app}/admin.py | 0 .../password/password_app/apps.py | 6 + .../password_app/migrations/__init__.py | 0 .../password_app}/models.py | 0 .../templates/password_app}/index.html | 15 +-- .../templates/password_app/password.html | 15 +++ .../password/password_app/tests.py | 3 + .../password/password_app/urls.py | 7 + .../password/password_app/views.py | 18 +++ .../password/password_proj/__init__.py | 0 .../password_proj}/asgi.py | 4 +- .../password_proj}/settings.py | 15 +-- .../password_proj}/urls.py | 5 +- .../password_proj}/wsgi.py | 4 +- Code/eric/django_projects/todo/manage.py | 2 +- .../django_projects/todo/todo_app/admin.py | 2 + .../django_projects/todo/todo_app/forms.py | 12 +- .../todo/todo_app/migrations/0001_initial.py | 23 ++++ .../django_projects/todo/todo_app/models.py | 18 +-- .../todo_app/templates/todo_app/delete.html | 18 +++ .../todo_app/templates/todo_app/index.html | 36 +++++ .../saved_todos.html => todo_app/update.html} | 13 +- .../django_projects/todo/todo_app/urls.py | 7 +- .../django_projects/todo/todo_app/views.py | 64 +++++---- .../django_projects/todo/todo_proj/asgi.py | 6 +- .../todo/todo_proj/settings.py | 27 ++-- .../django_projects/todo/todo_proj/urls.py | 6 +- .../django_projects/todo/todo_proj/wsgi.py | 6 +- 49 files changed, 601 insertions(+), 176 deletions(-) rename Code/eric/django_projects/{lab1redo_proj/lab1redo_app => grocery/grocery_app}/__init__.py (100%) create mode 100644 Code/eric/django_projects/grocery/grocery_app/admin.py rename Code/eric/django_projects/{lab1redo_proj/lab1redo_app => grocery/grocery_app}/apps.py (60%) create mode 100644 Code/eric/django_projects/grocery/grocery_app/migrations/0001_initial.py rename Code/eric/django_projects/{lab1redo_proj/lab1redo_app => grocery/grocery_app}/migrations/__init__.py (100%) create mode 100644 Code/eric/django_projects/grocery/grocery_app/models.py create mode 100644 Code/eric/django_projects/grocery/grocery_app/templates/grocery_app/index.html rename Code/eric/django_projects/{lab1redo_proj/lab1redo_app => grocery/grocery_app}/tests.py (100%) create mode 100644 Code/eric/django_projects/grocery/grocery_app/urls.py create mode 100644 Code/eric/django_projects/grocery/grocery_app/views.py rename Code/eric/django_projects/{lab1redo_proj/lab1redo_proj => grocery/grocery_proj}/__init__.py (100%) create mode 100644 Code/eric/django_projects/grocery/grocery_proj/asgi.py create mode 100644 Code/eric/django_projects/grocery/grocery_proj/settings.py create mode 100644 Code/eric/django_projects/grocery/grocery_proj/urls.py create mode 100644 Code/eric/django_projects/grocery/grocery_proj/wsgi.py create mode 100644 Code/eric/django_projects/grocery/manage.py delete mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/templates/lab1redo_app/index.html delete mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/urls.py delete mode 100644 Code/eric/django_projects/lab1redo_proj/lab1redo_app/views.py rename Code/eric/django_projects/{lab1redo_proj => password}/manage.py (90%) create mode 100644 Code/eric/django_projects/password/password_app/__init__.py rename Code/eric/django_projects/{lab1redo_proj/lab1redo_app => password/password_app}/admin.py (100%) create mode 100644 Code/eric/django_projects/password/password_app/apps.py create mode 100644 Code/eric/django_projects/password/password_app/migrations/__init__.py rename Code/eric/django_projects/{lab1redo_proj/lab1redo_app => password/password_app}/models.py (100%) rename Code/eric/django_projects/{todo/todo_app/templates/todo => password/password_app/templates/password_app}/index.html (50%) create mode 100644 Code/eric/django_projects/password/password_app/templates/password_app/password.html create mode 100644 Code/eric/django_projects/password/password_app/tests.py create mode 100644 Code/eric/django_projects/password/password_app/urls.py create mode 100644 Code/eric/django_projects/password/password_app/views.py create mode 100644 Code/eric/django_projects/password/password_proj/__init__.py rename Code/eric/django_projects/{lab1redo_proj/lab1redo_proj => password/password_proj}/asgi.py (74%) rename Code/eric/django_projects/{lab1redo_proj/lab1redo_proj => password/password_proj}/settings.py (89%) rename Code/eric/django_projects/{lab1redo_proj/lab1redo_proj => password/password_proj}/urls.py (85%) rename Code/eric/django_projects/{lab1redo_proj/lab1redo_proj => password/password_proj}/wsgi.py (74%) mode change 100755 => 100644 Code/eric/django_projects/todo/manage.py create mode 100644 Code/eric/django_projects/todo/todo_app/migrations/0001_initial.py create mode 100644 Code/eric/django_projects/todo/todo_app/templates/todo_app/delete.html create mode 100644 Code/eric/django_projects/todo/todo_app/templates/todo_app/index.html rename Code/eric/django_projects/todo/todo_app/templates/{todo/saved_todos.html => todo_app/update.html} (63%) diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/__init__.py b/Code/eric/django_projects/grocery/grocery_app/__init__.py similarity index 100% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_app/__init__.py rename to Code/eric/django_projects/grocery/grocery_app/__init__.py diff --git a/Code/eric/django_projects/grocery/grocery_app/admin.py b/Code/eric/django_projects/grocery/grocery_app/admin.py new file mode 100644 index 00000000..95b665dd --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_app/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from .models import * + +# Register your models here. +admin.site.register(Department) +admin.site.register(GroceryItem) diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/apps.py b/Code/eric/django_projects/grocery/grocery_app/apps.py similarity index 60% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_app/apps.py rename to Code/eric/django_projects/grocery/grocery_app/apps.py index ac422649..87b0bfcb 100644 --- a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/apps.py +++ b/Code/eric/django_projects/grocery/grocery_app/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -class Lab1RedoAppConfig(AppConfig): +class GroceryAppConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' - name = 'lab1redo_app' + name = 'grocery_app' diff --git a/Code/eric/django_projects/grocery/grocery_app/migrations/0001_initial.py b/Code/eric/django_projects/grocery/grocery_app/migrations/0001_initial.py new file mode 100644 index 00000000..cd5fbdc3 --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_app/migrations/0001_initial.py @@ -0,0 +1,31 @@ +# Generated by Django 3.2.12 on 2022-04-13 01:32 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Department', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=20)), + ], + ), + migrations.CreateModel( + name='GroceryItem', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('item', models.CharField(max_length=40)), + ('completed', models.BooleanField(default=False)), + ('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='items', to='grocery_app.department')), + ], + ), + ] diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/migrations/__init__.py b/Code/eric/django_projects/grocery/grocery_app/migrations/__init__.py similarity index 100% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_app/migrations/__init__.py rename to Code/eric/django_projects/grocery/grocery_app/migrations/__init__.py diff --git a/Code/eric/django_projects/grocery/grocery_app/models.py b/Code/eric/django_projects/grocery/grocery_app/models.py new file mode 100644 index 00000000..5ea247c2 --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_app/models.py @@ -0,0 +1,19 @@ +from django.db import models + +# Create your models here. +class Department(models.Model): + name = models.CharField(max_length=20) + + def __str__(self): + return f'{self.name}' + +class GroceryItem(models.Model): + item =models.CharField(max_length=40) + completed = models.BooleanField(default=False) + department = models.ForeignKey(Department, on_delete=models.CASCADE, related_name='items', null=True, blank=True) + + def __str__(self): + return f'{self.item} -- {self.completed} ' + + + \ No newline at end of file diff --git a/Code/eric/django_projects/grocery/grocery_app/templates/grocery_app/index.html b/Code/eric/django_projects/grocery/grocery_app/templates/grocery_app/index.html new file mode 100644 index 00000000..f19446ee --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_app/templates/grocery_app/index.html @@ -0,0 +1,48 @@ + + + + + + + Grocery + + +

    My Grocery

    + + {% csrf_token %} + + + + + {% for department in departments %} +
    +

    {{department.name}}

    + +
    + {% endfor %} + + + + + \ No newline at end of file diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/tests.py b/Code/eric/django_projects/grocery/grocery_app/tests.py similarity index 100% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_app/tests.py rename to Code/eric/django_projects/grocery/grocery_app/tests.py diff --git a/Code/eric/django_projects/grocery/grocery_app/urls.py b/Code/eric/django_projects/grocery/grocery_app/urls.py new file mode 100644 index 00000000..1cea3b37 --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_app/urls.py @@ -0,0 +1,13 @@ +from django.urls import path +from .import views + +app_name = 'grocery_list' + +urlpatterns = [ + + path('', views.index, name='index'), + path('add_item', views.add_item, name='add'), + path('buy//', views.buy_item, name='buy'), + path('delete//', views.delete_item, name='delete'), + +] diff --git a/Code/eric/django_projects/grocery/grocery_app/views.py b/Code/eric/django_projects/grocery/grocery_app/views.py new file mode 100644 index 00000000..10f2ed0e --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_app/views.py @@ -0,0 +1,40 @@ +from django.shortcuts import render +from .models import * +#from .import models # results in leading models -> models.GroceryItem +from django.http import HttpResponseRedirect +from django.urls import reverse + +# Create your views here. +def index(request): + grocery_list = GroceryItem.objects.all().order_by('department') + departments = Department.objects.all().order_by('name') + + return render(request, 'grocery_app/index.html',{ + 'grocery_list': grocery_list, + 'departments': departments + }) + +def add_item(request): + item_text = request.POST['item'] + department_id = request.POST['department'] + new_item = GroceryItem() + new_item.item = item_text + if department_id: + department = Department.objects.get(id=department_id) + new_item.department = department + new_item.save() + return HttpResponseRedirect(reverse('grocery_list:index')) + +def buy_item(request, item_id): + grocery_item = GroceryItem.objects.get(id=item_id) + grocery_item.completed = not grocery_item.completed + grocery_item.save() + return HttpResponseRedirect(reverse('grocery_list:index')) + +def delete_item(request, item_id): + grocery_item = GroceryItem.objects.get(id=item_id) + grocery_item.delete() + return HttpResponseRedirect(reverse('grocery_list:index')) + + + \ No newline at end of file diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/__init__.py b/Code/eric/django_projects/grocery/grocery_proj/__init__.py similarity index 100% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_proj/__init__.py rename to Code/eric/django_projects/grocery/grocery_proj/__init__.py diff --git a/Code/eric/django_projects/grocery/grocery_proj/asgi.py b/Code/eric/django_projects/grocery/grocery_proj/asgi.py new file mode 100644 index 00000000..0e4a45b7 --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for grocery_proj project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'grocery_proj.settings') + +application = get_asgi_application() diff --git a/Code/eric/django_projects/grocery/grocery_proj/settings.py b/Code/eric/django_projects/grocery/grocery_proj/settings.py new file mode 100644 index 00000000..4c5bf2fc --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_proj/settings.py @@ -0,0 +1,127 @@ +""" +Django settings for grocery_proj project. + +Generated by 'django-admin startproject' using Django 3.2.12. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-1el5co&ci&3w1iduh^v%oemq&opqom6!9bazki#0@sd!0*w562' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'grocery_app', +] + +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 = 'grocery_proj.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 = 'grocery_proj.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.2/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/3.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'America/New_York' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.2/howto/static-files/ + +STATIC_URL = '/static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/Code/eric/django_projects/grocery/grocery_proj/urls.py b/Code/eric/django_projects/grocery/grocery_proj/urls.py new file mode 100644 index 00000000..3b496c54 --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_proj/urls.py @@ -0,0 +1,22 @@ +"""grocery_proj URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('grocery_app.urls')) +] diff --git a/Code/eric/django_projects/grocery/grocery_proj/wsgi.py b/Code/eric/django_projects/grocery/grocery_proj/wsgi.py new file mode 100644 index 00000000..7b1ac5f5 --- /dev/null +++ b/Code/eric/django_projects/grocery/grocery_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for grocery_proj 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/3.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'grocery_proj.settings') + +application = get_wsgi_application() diff --git a/Code/eric/django_projects/grocery/manage.py b/Code/eric/django_projects/grocery/manage.py new file mode 100644 index 00000000..f97e4e6d --- /dev/null +++ b/Code/eric/django_projects/grocery/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'grocery_proj.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/templates/lab1redo_app/index.html b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/templates/lab1redo_app/index.html deleted file mode 100644 index a4bde0e6..00000000 --- a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/templates/lab1redo_app/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - Rot 13 - - - -
    - - -
    - -

    {{value_sting

    - - \ No newline at end of file diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/urls.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/urls.py deleted file mode 100644 index 28f6100d..00000000 --- a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/urls.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.urls import path, include -from . import views - -app_name = 'rot' - -urlpatterns = [ - # 127.0.0.1:8000 - path('', views.index, name='index'), - - - path('/rot/', views.rot, name='rot') - - - -] \ No newline at end of file diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/views.py b/Code/eric/django_projects/lab1redo_proj/lab1redo_app/views.py deleted file mode 100644 index 928f2758..00000000 --- a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/views.py +++ /dev/null @@ -1,46 +0,0 @@ -from django.shortcuts import render - -# Create your views here. -def index(request): - return render(request, 'lab1redo_app/index.html') - -def rot(request): - letter_values = { - 'a' : 'n', - 'b' : 'o', - 'c' : 'p', - 'd' : 'q', - 'e' : 'r', - 'f' : 's', - 'g' : 't', - 'h' : 'u', - 'i' : 'v', - 'j' : 'w', - 'k' : 'x', - 'l' : 'y', - 'm' : 'z', - 'n' : 'a', - 'o' : 'b', - 'p' : 'c', - 'q' : 'd', - 'r' : 'e', - 's' : 'f', - 't' : 'g', - 'u' : 'h', - 'v' : 'i', - 'w' : 'j', - 'x' : 'k', - 'y' : 'l', - 'z' : 'm' - } - - user_string = request.GET.get('plain_text', '').lower() - value_string = " " - for letter in user_string: - letters = letter in letter_values.get() - if letters == True: - value_string += letter_values[letter] - - return render(request, 'index.html', {'Converted Text':value_string}) - - diff --git a/Code/eric/django_projects/lab1redo_proj/manage.py b/Code/eric/django_projects/password/manage.py similarity index 90% rename from Code/eric/django_projects/lab1redo_proj/manage.py rename to Code/eric/django_projects/password/manage.py index e658b2e5..4405e439 100755 --- a/Code/eric/django_projects/lab1redo_proj/manage.py +++ b/Code/eric/django_projects/password/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lab1redo_proj.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'password_proj.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/Code/eric/django_projects/password/password_app/__init__.py b/Code/eric/django_projects/password/password_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/admin.py b/Code/eric/django_projects/password/password_app/admin.py similarity index 100% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_app/admin.py rename to Code/eric/django_projects/password/password_app/admin.py diff --git a/Code/eric/django_projects/password/password_app/apps.py b/Code/eric/django_projects/password/password_app/apps.py new file mode 100644 index 00000000..025792aa --- /dev/null +++ b/Code/eric/django_projects/password/password_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class PasswordAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'password_app' diff --git a/Code/eric/django_projects/password/password_app/migrations/__init__.py b/Code/eric/django_projects/password/password_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_app/models.py b/Code/eric/django_projects/password/password_app/models.py similarity index 100% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_app/models.py rename to Code/eric/django_projects/password/password_app/models.py diff --git a/Code/eric/django_projects/todo/todo_app/templates/todo/index.html b/Code/eric/django_projects/password/password_app/templates/password_app/index.html similarity index 50% rename from Code/eric/django_projects/todo/todo_app/templates/todo/index.html rename to Code/eric/django_projects/password/password_app/templates/password_app/index.html index 50f7dd7a..4ac56ccd 100644 --- a/Code/eric/django_projects/todo/todo_app/templates/todo/index.html +++ b/Code/eric/django_projects/password/password_app/templates/password_app/index.html @@ -4,17 +4,12 @@ - To Do List + Password Generator -
    To Do List
    - Add To Do - {% for todo in todos %} -
    - - {{todo.text}} - {{todo.priority}} - -
    - {% endfor %} +

    Password Generator

    +
    + +
    \ No newline at end of file diff --git a/Code/eric/django_projects/password/password_app/templates/password_app/password.html b/Code/eric/django_projects/password/password_app/templates/password_app/password.html new file mode 100644 index 00000000..21b09cdb --- /dev/null +++ b/Code/eric/django_projects/password/password_app/templates/password_app/password.html @@ -0,0 +1,15 @@ + + + + + + + Generated Password + + + +Your password is: +{{ password }} + + + \ No newline at end of file diff --git a/Code/eric/django_projects/password/password_app/tests.py b/Code/eric/django_projects/password/password_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/eric/django_projects/password/password_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/eric/django_projects/password/password_app/urls.py b/Code/eric/django_projects/password/password_app/urls.py new file mode 100644 index 00000000..e6c16bda --- /dev/null +++ b/Code/eric/django_projects/password/password_app/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.index, name='index'), + path('password/', views.password, name='password'), +] \ No newline at end of file diff --git a/Code/eric/django_projects/password/password_app/views.py b/Code/eric/django_projects/password/password_app/views.py new file mode 100644 index 00000000..bed810ac --- /dev/null +++ b/Code/eric/django_projects/password/password_app/views.py @@ -0,0 +1,18 @@ +from django.shortcuts import render + +import random +# Create your views here. +def index(request): + return render(request, 'password_app/index.html') + +def password(request): + genPassword = '' + length = 14 + length = int(length) + characters = list('abcdefghijklmnopqrstuvwxyz£$%^&*!{}()ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') + + i=0 + while i < length: + i=i+1 + genPassword = genPassword + random.choice(characters) + return render(request, 'password_app/password.html', {'password': genPassword}) diff --git a/Code/eric/django_projects/password/password_proj/__init__.py b/Code/eric/django_projects/password/password_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/asgi.py b/Code/eric/django_projects/password/password_proj/asgi.py similarity index 74% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_proj/asgi.py rename to Code/eric/django_projects/password/password_proj/asgi.py index b7e1280a..a6807b04 100644 --- a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/asgi.py +++ b/Code/eric/django_projects/password/password_proj/asgi.py @@ -1,5 +1,5 @@ """ -ASGI config for lab1redo_proj project. +ASGI config for password_proj project. It exposes the ASGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lab1redo_proj.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'password_proj.settings') application = get_asgi_application() diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/settings.py b/Code/eric/django_projects/password/password_proj/settings.py similarity index 89% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_proj/settings.py rename to Code/eric/django_projects/password/password_proj/settings.py index c348ef71..0083c86a 100644 --- a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/settings.py +++ b/Code/eric/django_projects/password/password_proj/settings.py @@ -1,7 +1,7 @@ """ -Django settings for lab1redo_proj project. +Django settings for password_proj project. -Generated by 'django-admin startproject' using Django 4.0.3. +Generated by 'django-admin startproject' using Django 4.0.4. For more information on this file, see https://docs.djangoproject.com/en/4.0/topics/settings/ @@ -20,7 +20,7 @@ # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-pff+i!=*&u@_s()&o-%&^t3ap)&2-ex_#_s3w&dyu9ws@ev$w9' +SECRET_KEY = 'django-insecure-#v+lmc98j7ah@%ufm4z_pm(e3r$(7x#t+9&p^cgw#xkq1667tn' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -38,8 +38,7 @@ 'django.contrib.messages', 'django.contrib.staticfiles', - # project app - 'lab1redo.app', + 'password_app', ] MIDDLEWARE = [ @@ -52,7 +51,7 @@ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -ROOT_URLCONF = 'lab1redo_proj.urls' +ROOT_URLCONF = 'password_proj.urls' TEMPLATES = [ { @@ -70,7 +69,7 @@ }, ] -WSGI_APPLICATION = 'lab1redo_proj.wsgi.application' +WSGI_APPLICATION = 'password_proj.wsgi.application' # Database @@ -108,7 +107,7 @@ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'America/New_York' +TIME_ZONE = 'UTC' USE_I18N = True diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/urls.py b/Code/eric/django_projects/password/password_proj/urls.py similarity index 85% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_proj/urls.py rename to Code/eric/django_projects/password/password_proj/urls.py index 3d63057d..e393fac5 100644 --- a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/urls.py +++ b/Code/eric/django_projects/password/password_proj/urls.py @@ -1,4 +1,4 @@ -"""lab1redo_proj URL Configuration +"""password_proj URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.0/topics/http/urls/ @@ -14,8 +14,9 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), + path('', include('password_app.urls')) ] diff --git a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/wsgi.py b/Code/eric/django_projects/password/password_proj/wsgi.py similarity index 74% rename from Code/eric/django_projects/lab1redo_proj/lab1redo_proj/wsgi.py rename to Code/eric/django_projects/password/password_proj/wsgi.py index 1a3af340..0447c024 100644 --- a/Code/eric/django_projects/lab1redo_proj/lab1redo_proj/wsgi.py +++ b/Code/eric/django_projects/password/password_proj/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for lab1redo_proj project. +WSGI config for password_proj project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lab1redo_proj.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'password_proj.settings') application = get_wsgi_application() diff --git a/Code/eric/django_projects/todo/manage.py b/Code/eric/django_projects/todo/manage.py old mode 100755 new mode 100644 index 00a51e0f..6be564d2 --- a/Code/eric/django_projects/todo/manage.py +++ b/Code/eric/django_projects/todo/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_app.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_proj.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/Code/eric/django_projects/todo/todo_app/admin.py b/Code/eric/django_projects/todo/todo_app/admin.py index 8c38f3f3..4c66e470 100644 --- a/Code/eric/django_projects/todo/todo_app/admin.py +++ b/Code/eric/django_projects/todo/todo_app/admin.py @@ -1,3 +1,5 @@ from django.contrib import admin +from .models import * # Register your models here. +admin.site.register(Task) diff --git a/Code/eric/django_projects/todo/todo_app/forms.py b/Code/eric/django_projects/todo/todo_app/forms.py index 91073e84..174083f6 100644 --- a/Code/eric/django_projects/todo/todo_app/forms.py +++ b/Code/eric/django_projects/todo/todo_app/forms.py @@ -1,8 +1,10 @@ from django import forms -from .models import ToDo +from django.forms import ModelForm +from .models import * - -class ToDoForm(forms.ModelForm): +class TaskForm(forms.ModelForm): class Meta: - model = ToDo - fields = ('text', 'priority') \ No newline at end of file + model = Task + fields = '__all__' + + diff --git a/Code/eric/django_projects/todo/todo_app/migrations/0001_initial.py b/Code/eric/django_projects/todo/todo_app/migrations/0001_initial.py new file mode 100644 index 00000000..c887fbb6 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.12 on 2022-04-05 02:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Task', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('complete', models.BooleanField(default=False)), + ('created', models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/Code/eric/django_projects/todo/todo_app/models.py b/Code/eric/django_projects/todo/todo_app/models.py index 87cc26cc..482842d0 100644 --- a/Code/eric/django_projects/todo/todo_app/models.py +++ b/Code/eric/django_projects/todo/todo_app/models.py @@ -1,14 +1,10 @@ from django.db import models -from django.contrib.auth.models import User + # Create your models here. -PRIO_CHOICES = ( - ('high', 'High'), - ('medium', 'Medium'), - ('low', 'Low'), -) -class ToDo(models.Model): - text = models.CharField(max_length=120, ) - priority = models.CharField(max_length=6, choices=PRIO_CHOICES, default='medium') - +class Task(models.Model): + title = models.CharField(max_length=200) + complete = models.BooleanField(default=False) + created = models.DateTimeField(auto_now_add=True) - created_date = models.DateTimeField(auto_now=True) + def __str__(self): + return self.title diff --git a/Code/eric/django_projects/todo/todo_app/templates/todo_app/delete.html b/Code/eric/django_projects/todo/todo_app/templates/todo_app/delete.html new file mode 100644 index 00000000..a55e235d --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/templates/todo_app/delete.html @@ -0,0 +1,18 @@ + + + + + + + Delete + + +

    Do you really want to delete {{item}}

    + Cancel + +
    + {% csrf_token %} + +
    + + \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_app/templates/todo_app/index.html b/Code/eric/django_projects/todo/todo_app/templates/todo_app/index.html new file mode 100644 index 00000000..16a2e937 --- /dev/null +++ b/Code/eric/django_projects/todo/todo_app/templates/todo_app/index.html @@ -0,0 +1,36 @@ + + + + + + + To DO + + +

    To Do

    + +
    + {% csrf_token %} + {{form.title}} +
    + + {% for task in tasks %} +
    + Update + Delete + + + {% if task.complete %} + {{task}} + {% else %} + {{task}} + + {% endif %} + +
    + + {% endfor %} + + + + \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_app/templates/todo/saved_todos.html b/Code/eric/django_projects/todo/todo_app/templates/todo_app/update.html similarity index 63% rename from Code/eric/django_projects/todo/todo_app/templates/todo/saved_todos.html rename to Code/eric/django_projects/todo/todo_app/templates/todo_app/update.html index 2112f679..c6c6fcf8 100644 --- a/Code/eric/django_projects/todo/todo_app/templates/todo/saved_todos.html +++ b/Code/eric/django_projects/todo/todo_app/templates/todo_app/update.html @@ -4,12 +4,17 @@ - Saved To Dos + Update -
    + {% csrf_token %} - {{ form.as_p}} - + + {{form}} + +
    + + + \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_app/urls.py b/Code/eric/django_projects/todo/todo_app/urls.py index 3e0428f1..476dd071 100644 --- a/Code/eric/django_projects/todo/todo_app/urls.py +++ b/Code/eric/django_projects/todo/todo_app/urls.py @@ -1,7 +1,8 @@ from django.urls import path -from . import views +from .import views urlpatterns = [ - path('', views.index, name='index'), - path('saved_todos', views.new_todo, name='new_todo'), + path('', views.index, name='index'), + path('update/', views.updateTask, name='update'), + path('delete/', views.deleteTask, name='delete'), ] \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_app/views.py b/Code/eric/django_projects/todo/todo_app/views.py index ad86aee7..d393334e 100644 --- a/Code/eric/django_projects/todo/todo_app/views.py +++ b/Code/eric/django_projects/todo/todo_app/views.py @@ -1,30 +1,44 @@ -from django.shortcuts import render -from django.http import HttpResponseRedirect -from django.contrib.auth.models import User -from django.urls import reverse -from .forms import * -# Create your views here. - -def index(request): - if request.method == "GET": - todos = ToDo.objects.all() - return render(request, 'index.html',{ - 'todos':todos, - 'form': ToDoForm,} - ) +from django.shortcuts import render, redirect +from todo_app.forms import TaskForm +from .models import * # Create your views here. -def new_todo(request): - if request.method == "POST": - form = ToDoForm(request.POST) +def index(request): + + tasks = Task.objects.all() + form = TaskForm() + + if request.method =='POST': + form = TaskForm(request.POST) if form.is_valid(): - todo = ToDo() - todo.priority = form.cleaned_data['priority'] - todo.text = form.cleaned_data['text'] - todo.save() - return HttpResponseRedirect(reverse('index')) - if request.method == "GET": - form = ToDoForm() + form.save() + return redirect('/') + + context = {'tasks': tasks, 'form':form} + + return render(request, 'todo_app/index.html', context) - return render(request,'saved_todos.html', {'form': form} ) \ No newline at end of file +def updateTask(request, pk): + task = Task.objects.get(id=pk) + form = TaskForm(instance=task) + + context = {'form': form} + + if request.method == 'POST': + form = TaskForm(request.POST, instance=task) + if form.is_valid(): + form.save() + return redirect('/') + return render(request, 'todo_app/update.html', context ) + +def deleteTask(request, pk): + item = Task.objects.get(id=pk) + + if request.method == 'POST': + item.delete() + return redirect('/') + + context = {'item': item} + + return render(request, 'todo_app/delete.html', context) \ No newline at end of file diff --git a/Code/eric/django_projects/todo/todo_proj/asgi.py b/Code/eric/django_projects/todo/todo_proj/asgi.py index 2e24ed38..0a358a99 100644 --- a/Code/eric/django_projects/todo/todo_proj/asgi.py +++ b/Code/eric/django_projects/todo/todo_proj/asgi.py @@ -1,16 +1,16 @@ """ -ASGI config for todo_app project. +ASGI config for todo_proj project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ +https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ """ import os from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_app.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_proj.settings') application = get_asgi_application() diff --git a/Code/eric/django_projects/todo/todo_proj/settings.py b/Code/eric/django_projects/todo/todo_proj/settings.py index 80e84b35..26174604 100644 --- a/Code/eric/django_projects/todo/todo_proj/settings.py +++ b/Code/eric/django_projects/todo/todo_proj/settings.py @@ -1,13 +1,13 @@ """ Django settings for todo_proj project. -Generated by 'django-admin startproject' using Django 4.0.4. +Generated by 'django-admin startproject' using Django 3.2.12. For more information on this file, see -https://docs.djangoproject.com/en/4.0/topics/settings/ +https://docs.djangoproject.com/en/3.2/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/4.0/ref/settings/ +https://docs.djangoproject.com/en/3.2/ref/settings/ """ from pathlib import Path @@ -17,10 +17,10 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-939n1tx)0m7-8k1@#-7p_z4mc^9gn&d!k)#=(a4bl@-ivflv@$' +SECRET_KEY = 'django-insecure-58)w7vmldg%y6l1-ewg)!fnj8wss!gsus@)aro93ue__4zw=b+' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -37,7 +37,8 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'todo_app' + + 'todo_app', ] MIDDLEWARE = [ @@ -72,7 +73,7 @@ # Database -# https://docs.djangoproject.com/en/4.0/ref/settings/#databases +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { @@ -83,7 +84,7 @@ # Password validation -# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -102,7 +103,7 @@ # Internationalization -# https://docs.djangoproject.com/en/4.0/topics/i18n/ +# https://docs.djangoproject.com/en/3.2/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -110,15 +111,17 @@ USE_I18N = True +USE_L10N = True + USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/4.0/howto/static-files/ +# https://docs.djangoproject.com/en/3.2/howto/static-files/ -STATIC_URL = 'static/' +STATIC_URL = '/static/' # Default primary key field type -# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/Code/eric/django_projects/todo/todo_proj/urls.py b/Code/eric/django_projects/todo/todo_proj/urls.py index 09b1b37b..6cff3a66 100644 --- a/Code/eric/django_projects/todo/todo_proj/urls.py +++ b/Code/eric/django_projects/todo/todo_proj/urls.py @@ -1,7 +1,7 @@ -"""todo_app URL Configuration +"""todo_proj URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/4.0/topics/http/urls/ + https://docs.djangoproject.com/en/3.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views @@ -14,7 +14,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import include, path +from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), diff --git a/Code/eric/django_projects/todo/todo_proj/wsgi.py b/Code/eric/django_projects/todo/todo_proj/wsgi.py index 2229e7b2..d87e4976 100644 --- a/Code/eric/django_projects/todo/todo_proj/wsgi.py +++ b/Code/eric/django_projects/todo/todo_proj/wsgi.py @@ -1,16 +1,16 @@ """ -WSGI config for todo_app project. +WSGI config for todo_proj project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_app.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_proj.settings') application = get_wsgi_application()