From 1400f45734a08c2a1b44e2f16119e4903f77c9a3 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Fri, 11 Mar 2022 22:40:23 -0600 Subject: [PATCH 01/33] Responsive Design Notes --- .../responsive_design/index.html | 80 ++++++++++++++ .../responsive_design/style.css | 101 ++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 Code/will/html_css/notes_and_practice/responsive_design/index.html create mode 100644 Code/will/html_css/notes_and_practice/responsive_design/style.css diff --git a/Code/will/html_css/notes_and_practice/responsive_design/index.html b/Code/will/html_css/notes_and_practice/responsive_design/index.html new file mode 100644 index 00000000..242f1709 --- /dev/null +++ b/Code/will/html_css/notes_and_practice/responsive_design/index.html @@ -0,0 +1,80 @@ + + + + + + + + Responsive Design + + +
+

Class Kiwi

+ +
+
+ +
+
+
+

Title 1

+

+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nihil earum + rerum porro ducimus, rem dolorum, nisi qui possimus, assumenda + quisquam ipsum aliquam nostrum velit exercitationem harum similique. + Dolorem, nostrum sequi. +

+
+
+

Title 2

+

+ Architecto corrupti, veritatis ullam facilis odit nihil, deleniti + soluta accusantium, corporis iste dolore! A itaque deleniti + dignissimos cum, consequuntur natus aliquam nemo ex aut non obcaecati + ipsum perferendis reiciendis exercitationem. +

+
+
+

Title 3

+

+ Pariatur voluptas ratione illo asperiores ad, non fugiat. Harum, saepe + veniam. Facere provident reiciendis odit aliquam repudiandae eligendi. + Ipsa suscipit delectus deleniti officiis quod deserunt asperiores + blanditiis amet corrupti quaerat! +

+
+
+

Title 4

+

+ Culpa quisquam, eos sapiente, aliquid fuga dolorem repudiandae totam, + in molestias iste itaque ipsa! Quod adipisci possimus, natus sunt rem + voluptate odio obcaecati sit nihil suscipit nam harum. Nostrum, rerum. +

+
+
+

Title 5

+

+ Qui odio aspernatur vero voluptatum, similique minus blanditiis et + cupiditate autem quia atque expedita, ducimus sequi, non vel totam ab. + Libero cumque eos assumenda dolorem officia, expedita sint dolorum + itaque! +

+
+
+

Title 6

+

+ Deserunt perspiciatis excepturi ipsum consequatur aperiam quod veniam + distinctio doloribus. Velit, dignissimos sapiente error qui fugit, + ipsam ipsa cupiditate, illum eos expedita odio nesciunt omnis tenetur. + Officiis molestias aliquam quos! +

+
+
+ + + \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/responsive_design/style.css b/Code/will/html_css/notes_and_practice/responsive_design/style.css new file mode 100644 index 00000000..043e7f2f --- /dev/null +++ b/Code/will/html_css/notes_and_practice/responsive_design/style.css @@ -0,0 +1,101 @@ +body { + font-size: 24px; + display: flex; + flex-direction: column; + justify-content: center; +} + +body > * { + margin: 4px; +} + +h1 { + text-align: center; +} + +.links { + display: flex; + flex-direction: column; +} + +.links > a { + border: 1px solid black; + background-color: aqua; + margin: 0.5em 0.25em; + box-shadow: inset 0 0 8px 2px rgba(0, 0, 0, 0.89); + padding: 0.25em 0; + text-align: center; + text-decoration: none; +} + +img { + max-width: 100%; + display: flex; +} + +main { + display: flex; + flex-direction: column; + align-items: center; +} +section { + border: 1px solid black; + margin-bottom: 0.5em; + max-width: 54ch; +} + +section > p { + text-align: center; +} + +section > h1 { + text-decoration: underline; +} + +/* Tablet Styles */ +@media screen and (min-width: 768px) { + .links { + display: flex; + flex-direction: row; + justify-content: space-evenly; + } + + .links > a { + padding: 0.5em; + } + + img { + width: 650px; + } + + .hero { + display: flex; + justify-content: center; + } +} + +/* Desktop Styles */ +@media screen and (min-width: 1440px) { + header { + display: flex; + align-items: center; + justify-content: space-around; + } + + img { + max-width: 900px; + } + + main { + flex-flow: row wrap; + justify-content: center; + } + + .links { + display: block; + } + + .links > a { + padding: 0.2em; + } +} From ed059312a343fdb8cc4d1f9fb02a75b5de9dc8cf Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Tue, 15 Mar 2022 23:01:02 -0500 Subject: [PATCH 02/33] Submitting Burrito Order Form Lab --- .../Labs/Burrito_Order_Form/index.html | 92 +++++++++++++++++++ .../Labs/Burrito_Order_Form/style.css | 70 ++++++++++++++ .../notes_and_practice/html_forms/index.html | 53 +++++++++++ .../notes_and_practice/html_forms/style.css | 3 + 4 files changed, 218 insertions(+) create mode 100644 Code/will/html_css/Labs/Burrito_Order_Form/index.html create mode 100644 Code/will/html_css/Labs/Burrito_Order_Form/style.css create mode 100644 Code/will/html_css/notes_and_practice/html_forms/index.html create mode 100644 Code/will/html_css/notes_and_practice/html_forms/style.css diff --git a/Code/will/html_css/Labs/Burrito_Order_Form/index.html b/Code/will/html_css/Labs/Burrito_Order_Form/index.html new file mode 100644 index 00000000..4b9b5a83 --- /dev/null +++ b/Code/will/html_css/Labs/Burrito_Order_Form/index.html @@ -0,0 +1,92 @@ + + + + + + + + + Loco Burrito + + +
Loco Burrito
+
+ + Picture of burrito +
+

Customize Your Burrito

+ + +
+ +

Tortilla:

+ + + + + + + + + +
+ +

Meat:

+ + + + + + + + + + + +
+ +

Rice:

+ + + + + +
+ +

Beans:

+ + + + + +
+ +

Additional Options:

+ + + + + + + + + + + +
+
+ + + +
+
+ + +
+
+

Loco Burrito © 2022

+
+
+ + + \ No newline at end of file diff --git a/Code/will/html_css/Labs/Burrito_Order_Form/style.css b/Code/will/html_css/Labs/Burrito_Order_Form/style.css new file mode 100644 index 00000000..374f3e19 --- /dev/null +++ b/Code/will/html_css/Labs/Burrito_Order_Form/style.css @@ -0,0 +1,70 @@ +body { + margin: 0; + text-align: center; + font-size: 18px; + background-color: rgb(223, 221, 221); +} + +img { + display: block; + float: left; + width: 20%; + margin-top: 1px; +} + +h2 { + text-decoration: underline; + font-weight: bold; +} + +header { + display: flex; + justify-content: center; + font-size: 80px; + background-color: rgba(255, 0, 0, 0.918); + font-family: "Amatic SC"; + font-weight: bolder; + margin: 0; + color: rgb(196, 151, 4); + text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, + 1px 1px 0 #000; + box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.397); +} + +input { + display: inline-flex; + justify-content: center; + margin-right: 30px; +} + +main { + display: block; + float: right; + width: 75%; +} + +.first { + margin-left: 10px; +} + +p { + display: inline-flex; + justify-content: center; + margin-left: 10px; + font-weight: bold; + font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; +} + +input { + display: inline-flex; + justify-content: center; +} + +footer { + position: absolute; + bottom: 0; + background-color: black; + color: white; + text-align: center; + width: 100vw; +} diff --git a/Code/will/html_css/notes_and_practice/html_forms/index.html b/Code/will/html_css/notes_and_practice/html_forms/index.html new file mode 100644 index 00000000..40ae671d --- /dev/null +++ b/Code/will/html_css/notes_and_practice/html_forms/index.html @@ -0,0 +1,53 @@ + + + + + + + + HTML Forms + + +
+ + + + +
+ + + +
+ + + +
+ + + + + + + + + + +
+ + + +
+ + + + + + + +
+ + \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/html_forms/style.css b/Code/will/html_css/notes_and_practice/html_forms/style.css new file mode 100644 index 00000000..458132e8 --- /dev/null +++ b/Code/will/html_css/notes_and_practice/html_forms/style.css @@ -0,0 +1,3 @@ +body { + background-color: grey; +} From 30d6bc9d322a43aaded15f4ca5e51f40031d3da3 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Wed, 16 Mar 2022 22:20:10 -0500 Subject: [PATCH 03/33] Submitting Company Page Lab --- .../html_css/Labs/Company_Page/index.html | 115 ++++++++++++++++++ .../will/html_css/Labs/Company_Page/style.css | 10 ++ .../frameworks/materialize.html | 33 +++++ 3 files changed, 158 insertions(+) create mode 100644 Code/will/html_css/Labs/Company_Page/index.html create mode 100644 Code/will/html_css/Labs/Company_Page/style.css create mode 100644 Code/will/html_css/notes_and_practice/frameworks/materialize.html diff --git a/Code/will/html_css/Labs/Company_Page/index.html b/Code/will/html_css/Labs/Company_Page/index.html new file mode 100644 index 00000000..cecfdd38 --- /dev/null +++ b/Code/will/html_css/Labs/Company_Page/index.html @@ -0,0 +1,115 @@ + + + + + + + + + We Make Games + + +
+ +
+ +
+
+
+
+
+ + New Game Announcement +
+
+
+

Hype information about new game coming out soon!

+
+
+ +
+
+
+ +
+
+
+
+ Hotfix 19.2 +

Here are the patch notes for Hotfix 19.2 for Big Game.

+
+ +
+
+
+
+
+ Community Spotlight +

Shining the spotlight on a cool creator.

+
+ +
+
+
+ +
+
+
+
+ Holiday Sale +

Sale that includes that really cool item from the shop you have been wanting for months!

+
+ +
+
+
+ +
+ + + + \ No newline at end of file diff --git a/Code/will/html_css/Labs/Company_Page/style.css b/Code/will/html_css/Labs/Company_Page/style.css new file mode 100644 index 00000000..d2729286 --- /dev/null +++ b/Code/will/html_css/Labs/Company_Page/style.css @@ -0,0 +1,10 @@ +body { + display: flex; + min-height: 100vh; + flex-direction: column; + background-color: #37474f; +} + +main { + flex: 1 0 auto; +} diff --git a/Code/will/html_css/notes_and_practice/frameworks/materialize.html b/Code/will/html_css/notes_and_practice/frameworks/materialize.html new file mode 100644 index 00000000..380848ac --- /dev/null +++ b/Code/will/html_css/notes_and_practice/frameworks/materialize.html @@ -0,0 +1,33 @@ + + + + + + + + + Materialize Example + + + + + + Link to Somewhere +

Hello There

+

General Kenobi

+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore enim asperiores autem eligendi tenetur ipsam reiciendis cupiditate placeat, sunt aliquid recusandae ipsum blanditiis laborum, dolorum iusto tempora, laudantium quaerat sint. +

+ + \ No newline at end of file From e1024d9f9e88780dc664e31ec5573ae356cb8071 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Thu, 17 Mar 2022 23:03:26 -0500 Subject: [PATCH 04/33] Flask Notes --- .../html_css/notes_and_practice/flask/app.py | 25 ++++++++++++++++ .../notes_and_practice/flask/static/style.css | 4 +++ .../flask/templates/about.html | 16 ++++++++++ .../flask/templates/check_grade.html | 30 +++++++++++++++++++ .../flask/templates/contact.html | 16 ++++++++++ .../flask/templates/index.html | 21 +++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 Code/will/html_css/notes_and_practice/flask/app.py create mode 100644 Code/will/html_css/notes_and_practice/flask/static/style.css create mode 100644 Code/will/html_css/notes_and_practice/flask/templates/about.html create mode 100644 Code/will/html_css/notes_and_practice/flask/templates/check_grade.html create mode 100644 Code/will/html_css/notes_and_practice/flask/templates/contact.html create mode 100644 Code/will/html_css/notes_and_practice/flask/templates/index.html diff --git a/Code/will/html_css/notes_and_practice/flask/app.py b/Code/will/html_css/notes_and_practice/flask/app.py new file mode 100644 index 00000000..1c0d9be6 --- /dev/null +++ b/Code/will/html_css/notes_and_practice/flask/app.py @@ -0,0 +1,25 @@ +from flask import Flask, render_template, request +app = Flask(__name__) + +# localhost:5000/ +@app.route('/') +def index(): + name = "Bill" + return render_template('index.html', name=name) + +@app.route('/about') +def about(): + return render_template('about.html') + +@app.route('/contact') +def contact(): + return render_template('contact.html') + +@app.route('/check-grade/') +def check_grade(grade): + return render_template('check_grade.html', grade=grade) + +@app.route('/llama', methods=['post']) +def display_name(): + name = request.form['username'] + return render_template('contact.html', name=name) \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/flask/static/style.css b/Code/will/html_css/notes_and_practice/flask/static/style.css new file mode 100644 index 00000000..d29c110a --- /dev/null +++ b/Code/will/html_css/notes_and_practice/flask/static/style.css @@ -0,0 +1,4 @@ +body { + text-align: center; + background-color: gray; +} diff --git a/Code/will/html_css/notes_and_practice/flask/templates/about.html b/Code/will/html_css/notes_and_practice/flask/templates/about.html new file mode 100644 index 00000000..3184da1f --- /dev/null +++ b/Code/will/html_css/notes_and_practice/flask/templates/about.html @@ -0,0 +1,16 @@ + + + + + + + + About + + + Home + Contact Us +

This is the about page.

+ + + \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/flask/templates/check_grade.html b/Code/will/html_css/notes_and_practice/flask/templates/check_grade.html new file mode 100644 index 00000000..14a3140c --- /dev/null +++ b/Code/will/html_css/notes_and_practice/flask/templates/check_grade.html @@ -0,0 +1,30 @@ + + + + + + + + Grade Check + + +

Grade Checker

+ + {% if grade >= 90 %} +

You got an A!

+ + {% elif grade >= 80 %} +

You got a B!

+ + {% elif grade >= 70 %} +

You got a C.

+ + {% elif grade >= 60 %} +

You got a D.

+ + {% else %} +
You got an F.
+ + {% endif %} + + \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/flask/templates/contact.html b/Code/will/html_css/notes_and_practice/flask/templates/contact.html new file mode 100644 index 00000000..eb46a055 --- /dev/null +++ b/Code/will/html_css/notes_and_practice/flask/templates/contact.html @@ -0,0 +1,16 @@ + + + + + + + + Contact Us + + + Home + About +

This is our contact page.

+

Welcome {{ name }}

+ + \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/flask/templates/index.html b/Code/will/html_css/notes_and_practice/flask/templates/index.html new file mode 100644 index 00000000..3cf2242b --- /dev/null +++ b/Code/will/html_css/notes_and_practice/flask/templates/index.html @@ -0,0 +1,21 @@ + + + + + + + + Flask + + + About + Contact Us +

Welcome to my Flask app!

+

Hello {{ name }}

+ +
+ + +
+ + \ No newline at end of file From 9422fd2dbc50a6f8dfa763bbb7ff0979904068a4 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Fri, 18 Mar 2022 21:25:44 -0500 Subject: [PATCH 05/33] Submitting Flask Redo Lab --- Code/will/html_css/Labs/Flask_Redo/app.py | 23 ++++++++++ .../html_css/Labs/Flask_Redo/static/style.css | 9 ++++ .../Labs/Flask_Redo/templates/index.html | 27 +++++++++++ .../Labs/Flask_Redo/templates/results.html | 17 +++++++ .../rock_paper_scissors/app.py | 45 +++++++++++++++++++ .../rock_paper_scissors/templates/index.html | 25 +++++++++++ .../templates/results.html | 18 ++++++++ 7 files changed, 164 insertions(+) create mode 100644 Code/will/html_css/Labs/Flask_Redo/app.py create mode 100644 Code/will/html_css/Labs/Flask_Redo/static/style.css create mode 100644 Code/will/html_css/Labs/Flask_Redo/templates/index.html create mode 100644 Code/will/html_css/Labs/Flask_Redo/templates/results.html create mode 100644 Code/will/html_css/notes_and_practice/rock_paper_scissors/app.py create mode 100644 Code/will/html_css/notes_and_practice/rock_paper_scissors/templates/index.html create mode 100644 Code/will/html_css/notes_and_practice/rock_paper_scissors/templates/results.html diff --git a/Code/will/html_css/Labs/Flask_Redo/app.py b/Code/will/html_css/Labs/Flask_Redo/app.py new file mode 100644 index 00000000..463f31b2 --- /dev/null +++ b/Code/will/html_css/Labs/Flask_Redo/app.py @@ -0,0 +1,23 @@ +from flask import Flask, render_template, request +app = Flask(__name__) + +# localhost:5000/ +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/results', methods=['post']) +def results(): + conversion = request.form + + units_to_convert = conversion['convert'] + distance_to_convert = conversion['amount'] + meters_to_units = conversion['converted'] + distance_to_convert = int(distance_to_convert) + + distances = {'feet': 0.3048, 'miles': 1609.34, 'meters': 1.0, 'kilometers': 1000, 'yards': 0.9144, 'inches': 0.0254} + units_to_meters = distance_to_convert * distances.get(units_to_convert) # convert the meters into the desired second unit and print results + converted_units = units_to_meters / distances.get(meters_to_units) + converted_units = round(converted_units, 3) + + return render_template('results.html', converted_units=converted_units, meters_to_units=meters_to_units, units_to_convert=units_to_convert, distance_to_convert=distance_to_convert) \ No newline at end of file diff --git a/Code/will/html_css/Labs/Flask_Redo/static/style.css b/Code/will/html_css/Labs/Flask_Redo/static/style.css new file mode 100644 index 00000000..e1a53266 --- /dev/null +++ b/Code/will/html_css/Labs/Flask_Redo/static/style.css @@ -0,0 +1,9 @@ +body { + text-align: center; + background-color: grey; +} + +label { + font-size: 22px; + margin-left: 16px; +} diff --git a/Code/will/html_css/Labs/Flask_Redo/templates/index.html b/Code/will/html_css/Labs/Flask_Redo/templates/index.html new file mode 100644 index 00000000..111bd77d --- /dev/null +++ b/Code/will/html_css/Labs/Flask_Redo/templates/index.html @@ -0,0 +1,27 @@ + + + + + + + + Unit Converter + + +

Unit Converting

+

This converter can convert feet, miles, meters, kilometers, yards, and inches.

+ +
+ + + + + + + + + + +
+ + \ No newline at end of file diff --git a/Code/will/html_css/Labs/Flask_Redo/templates/results.html b/Code/will/html_css/Labs/Flask_Redo/templates/results.html new file mode 100644 index 00000000..9d17400f --- /dev/null +++ b/Code/will/html_css/Labs/Flask_Redo/templates/results.html @@ -0,0 +1,17 @@ + + + + + + + + Unit Conversion Results + + +

Results:

+ +

{{distance_to_convert}} {{units_to_convert}} is equal to {{converted_units}} {{meters_to_units}}

+ + Convert more? + + \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/rock_paper_scissors/app.py b/Code/will/html_css/notes_and_practice/rock_paper_scissors/app.py new file mode 100644 index 00000000..92be2357 --- /dev/null +++ b/Code/will/html_css/notes_and_practice/rock_paper_scissors/app.py @@ -0,0 +1,45 @@ +from flask import Flask, render_template, request +import random + +app = Flask(__name__) + +# localhost:5000/ +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/results', methods=['post']) +def results(): + outcome = request.form + + user = outcome['rps'] + comp = random.choice(['rock', 'paper', 'scissors']) + + if user == comp: + message = 'It is a tie!' + + elif user == 'rock': + if comp == 'scissors': + message = 'You win!' + + else: + message = 'Computer wins' + elif user == 'paper': + if comp == 'rock': + message = 'You win!' + + else: + message = 'Computer wins' + + elif user == 'scissors': + if comp == 'paper': + message = 'You win!' + + else: + message = 'Computer wins' + + return render_template('results.html', user=user, comp=comp, message=message) + +#@app.route('/contact') +#def contact(): +# return render_template('contact.html') \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/rock_paper_scissors/templates/index.html b/Code/will/html_css/notes_and_practice/rock_paper_scissors/templates/index.html new file mode 100644 index 00000000..aea6f473 --- /dev/null +++ b/Code/will/html_css/notes_and_practice/rock_paper_scissors/templates/index.html @@ -0,0 +1,25 @@ + + + + + + + Rock, Paper, Scissors + + +

Welcome to Rock, Paper, Scissors!

+ +
+ + + + + + + + + + +
+ + \ No newline at end of file diff --git a/Code/will/html_css/notes_and_practice/rock_paper_scissors/templates/results.html b/Code/will/html_css/notes_and_practice/rock_paper_scissors/templates/results.html new file mode 100644 index 00000000..a7bc257a --- /dev/null +++ b/Code/will/html_css/notes_and_practice/rock_paper_scissors/templates/results.html @@ -0,0 +1,18 @@ + + + + + + + {{message}} + + +

Results:

+ +

You chose {{user}}

+

The computer chose {{comp}}

+

{{message}}

+ + Play again? + + \ No newline at end of file From 648b0b2bf41af4353e99db393be04801cab09c59 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Tue, 22 Mar 2022 22:54:46 -0500 Subject: [PATCH 06/33] Django Project 1 notes --- .../django/project_1/hello_app/__init__.py | 0 Code/will/django/project_1/hello_app/admin.py | 3 + Code/will/django/project_1/hello_app/apps.py | 6 + .../hello_app/migrations/__init__.py | 0 .../will/django/project_1/hello_app/models.py | 3 + .../hello_app/templates/hello_app/index.html | 12 ++ Code/will/django/project_1/hello_app/tests.py | 3 + Code/will/django/project_1/hello_app/urls.py | 17 +++ Code/will/django/project_1/hello_app/views.py | 16 +++ .../project_1/kiwi_first_proj/__init__.py | 0 .../django/project_1/kiwi_first_proj/asgi.py | 16 +++ .../project_1/kiwi_first_proj/settings.py | 126 ++++++++++++++++++ .../django/project_1/kiwi_first_proj/urls.py | 22 +++ .../django/project_1/kiwi_first_proj/wsgi.py | 16 +++ Code/will/django/project_1/manage.py | 22 +++ 15 files changed, 262 insertions(+) create mode 100644 Code/will/django/project_1/hello_app/__init__.py create mode 100644 Code/will/django/project_1/hello_app/admin.py create mode 100644 Code/will/django/project_1/hello_app/apps.py create mode 100644 Code/will/django/project_1/hello_app/migrations/__init__.py create mode 100644 Code/will/django/project_1/hello_app/models.py create mode 100644 Code/will/django/project_1/hello_app/templates/hello_app/index.html create mode 100644 Code/will/django/project_1/hello_app/tests.py create mode 100644 Code/will/django/project_1/hello_app/urls.py create mode 100644 Code/will/django/project_1/hello_app/views.py create mode 100644 Code/will/django/project_1/kiwi_first_proj/__init__.py create mode 100644 Code/will/django/project_1/kiwi_first_proj/asgi.py create mode 100644 Code/will/django/project_1/kiwi_first_proj/settings.py create mode 100644 Code/will/django/project_1/kiwi_first_proj/urls.py create mode 100644 Code/will/django/project_1/kiwi_first_proj/wsgi.py create mode 100644 Code/will/django/project_1/manage.py diff --git a/Code/will/django/project_1/hello_app/__init__.py b/Code/will/django/project_1/hello_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django/project_1/hello_app/admin.py b/Code/will/django/project_1/hello_app/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/will/django/project_1/hello_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/will/django/project_1/hello_app/apps.py b/Code/will/django/project_1/hello_app/apps.py new file mode 100644 index 00000000..37e3c0e4 --- /dev/null +++ b/Code/will/django/project_1/hello_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class HelloAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'hello_app' diff --git a/Code/will/django/project_1/hello_app/migrations/__init__.py b/Code/will/django/project_1/hello_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django/project_1/hello_app/models.py b/Code/will/django/project_1/hello_app/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/Code/will/django/project_1/hello_app/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/Code/will/django/project_1/hello_app/templates/hello_app/index.html b/Code/will/django/project_1/hello_app/templates/hello_app/index.html new file mode 100644 index 00000000..6c93d969 --- /dev/null +++ b/Code/will/django/project_1/hello_app/templates/hello_app/index.html @@ -0,0 +1,12 @@ + + + + + + + Document + + +

Hello {{name}}

+ + \ No newline at end of file diff --git a/Code/will/django/project_1/hello_app/tests.py b/Code/will/django/project_1/hello_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django/project_1/hello_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django/project_1/hello_app/urls.py b/Code/will/django/project_1/hello_app/urls.py new file mode 100644 index 00000000..16157d01 --- /dev/null +++ b/Code/will/django/project_1/hello_app/urls.py @@ -0,0 +1,17 @@ +from django.urls import path +from . import views + +urlpatterns = [ + #8000/ + path('', views.hello, name='hello'), + + #8000/bruce + path('bruce', views.bruce, name='bruce'), + + #8000/batman + path('batman', views.batman, name='batman'), + + #8000/string + path('', views.say_hello, name='say_hello') + +] \ No newline at end of file diff --git a/Code/will/django/project_1/hello_app/views.py b/Code/will/django/project_1/hello_app/views.py new file mode 100644 index 00000000..b82a9220 --- /dev/null +++ b/Code/will/django/project_1/hello_app/views.py @@ -0,0 +1,16 @@ +from django.http import HttpResponse +from django.shortcuts import render + +# Create your views here. +def hello(request): + return HttpResponse('

Hello World') + +def bruce(request): + return HttpResponse('Hello Bruce') + +def batman(request): + return HttpResponse("Sup Bruce, we know you're Batman") + +def say_hello(request, name): +# return HttpResponse(f'Hello {name}') + return render(request, 'hello_app/index.html', {'name':name}) diff --git a/Code/will/django/project_1/kiwi_first_proj/__init__.py b/Code/will/django/project_1/kiwi_first_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django/project_1/kiwi_first_proj/asgi.py b/Code/will/django/project_1/kiwi_first_proj/asgi.py new file mode 100644 index 00000000..8d6f1c66 --- /dev/null +++ b/Code/will/django/project_1/kiwi_first_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for kiwi_first_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', 'kiwi_first_proj.settings') + +application = get_asgi_application() diff --git a/Code/will/django/project_1/kiwi_first_proj/settings.py b/Code/will/django/project_1/kiwi_first_proj/settings.py new file mode 100644 index 00000000..3638b602 --- /dev/null +++ b/Code/will/django/project_1/kiwi_first_proj/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for kiwi_first_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-!65_r6k$u2s_mn7%qm^0&wv#%k5zr_ncti&lcxz!^r7%zvl2au' + +# 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 apps + 'hello_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 = 'kiwi_first_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 = 'kiwi_first_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/Detroit' + +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/will/django/project_1/kiwi_first_proj/urls.py b/Code/will/django/project_1/kiwi_first_proj/urls.py new file mode 100644 index 00000000..794a5ed1 --- /dev/null +++ b/Code/will/django/project_1/kiwi_first_proj/urls.py @@ -0,0 +1,22 @@ +"""kiwi_first_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, include + +urlpatterns = [ + path('hello/', include('hello_app.urls')), + path('admin/', admin.site.urls) +] diff --git a/Code/will/django/project_1/kiwi_first_proj/wsgi.py b/Code/will/django/project_1/kiwi_first_proj/wsgi.py new file mode 100644 index 00000000..97eac6ce --- /dev/null +++ b/Code/will/django/project_1/kiwi_first_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for kiwi_first_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', 'kiwi_first_proj.settings') + +application = get_wsgi_application() diff --git a/Code/will/django/project_1/manage.py b/Code/will/django/project_1/manage.py new file mode 100644 index 00000000..e77fbc01 --- /dev/null +++ b/Code/will/django/project_1/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', 'kiwi_first_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 16ad04ba5bf79727095ad436bbc42aeac14dee15 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Thu, 24 Mar 2022 23:28:38 -0500 Subject: [PATCH 07/33] Submit Django_Redo Lab and Django practice notes --- .../django_redo/django_redo}/__init__.py | 0 .../django_redo/django_redo/asgi.py | 16 +++ .../django_redo/django_redo/settings.py | 126 ++++++++++++++++++ .../django_redo/django_redo/urls.py | 22 +++ .../django_redo/django_redo/wsgi.py | 16 +++ Code/will/django_labs/django_redo/manage.py | 22 +++ .../django_redo/redoapp}/__init__.py | 0 .../django_redo/redoapp}/admin.py | 0 .../django_labs/django_redo/redoapp/apps.py | 6 + .../redoapp/migrations}/__init__.py | 0 .../django_redo/redoapp}/models.py | 0 .../redoapp/templates/redoapp/result.html | 15 +++ .../redoapp/templates/redoapp/unitcon.html | 27 ++++ .../django_redo/redoapp}/tests.py | 0 .../django_labs/django_redo/redoapp/urls.py | 10 ++ .../django_labs/django_redo/redoapp/views.py | 33 +++++ .../project_1/hello_app/__init__.py | 0 .../django_labs/project_1/hello_app/admin.py | 3 + .../project_1/hello_app/apps.py | 0 .../hello_app/migrations/__init__.py | 0 .../django_labs/project_1/hello_app/models.py | 3 + .../hello_app/templates/hello_app/index.html | 0 .../django_labs/project_1/hello_app/tests.py | 3 + .../project_1/hello_app/urls.py | 0 .../project_1/hello_app/views.py | 0 .../project_1/kiwi_first_proj/__init__.py | 0 .../project_1/kiwi_first_proj/asgi.py | 0 .../project_1/kiwi_first_proj/settings.py | 0 .../project_1/kiwi_first_proj/urls.py | 0 .../project_1/kiwi_first_proj/wsgi.py | 0 .../project_1/manage.py | 0 31 files changed, 302 insertions(+) rename Code/will/{django/project_1/hello_app => django_labs/django_redo/django_redo}/__init__.py (100%) create mode 100644 Code/will/django_labs/django_redo/django_redo/asgi.py create mode 100644 Code/will/django_labs/django_redo/django_redo/settings.py create mode 100644 Code/will/django_labs/django_redo/django_redo/urls.py create mode 100644 Code/will/django_labs/django_redo/django_redo/wsgi.py create mode 100644 Code/will/django_labs/django_redo/manage.py rename Code/will/{django/project_1/hello_app/migrations => django_labs/django_redo/redoapp}/__init__.py (100%) rename Code/will/{django/project_1/hello_app => django_labs/django_redo/redoapp}/admin.py (100%) create mode 100644 Code/will/django_labs/django_redo/redoapp/apps.py rename Code/will/{django/project_1/kiwi_first_proj => django_labs/django_redo/redoapp/migrations}/__init__.py (100%) rename Code/will/{django/project_1/hello_app => django_labs/django_redo/redoapp}/models.py (100%) create mode 100644 Code/will/django_labs/django_redo/redoapp/templates/redoapp/result.html create mode 100644 Code/will/django_labs/django_redo/redoapp/templates/redoapp/unitcon.html rename Code/will/{django/project_1/hello_app => django_labs/django_redo/redoapp}/tests.py (100%) create mode 100644 Code/will/django_labs/django_redo/redoapp/urls.py create mode 100644 Code/will/django_labs/django_redo/redoapp/views.py create mode 100644 Code/will/django_labs/project_1/hello_app/__init__.py create mode 100644 Code/will/django_labs/project_1/hello_app/admin.py rename Code/will/{django => django_labs}/project_1/hello_app/apps.py (100%) create mode 100644 Code/will/django_labs/project_1/hello_app/migrations/__init__.py create mode 100644 Code/will/django_labs/project_1/hello_app/models.py rename Code/will/{django => django_labs}/project_1/hello_app/templates/hello_app/index.html (100%) create mode 100644 Code/will/django_labs/project_1/hello_app/tests.py rename Code/will/{django => django_labs}/project_1/hello_app/urls.py (100%) rename Code/will/{django => django_labs}/project_1/hello_app/views.py (100%) create mode 100644 Code/will/django_labs/project_1/kiwi_first_proj/__init__.py rename Code/will/{django => django_labs}/project_1/kiwi_first_proj/asgi.py (100%) rename Code/will/{django => django_labs}/project_1/kiwi_first_proj/settings.py (100%) rename Code/will/{django => django_labs}/project_1/kiwi_first_proj/urls.py (100%) rename Code/will/{django => django_labs}/project_1/kiwi_first_proj/wsgi.py (100%) rename Code/will/{django => django_labs}/project_1/manage.py (100%) diff --git a/Code/will/django/project_1/hello_app/__init__.py b/Code/will/django_labs/django_redo/django_redo/__init__.py similarity index 100% rename from Code/will/django/project_1/hello_app/__init__.py rename to Code/will/django_labs/django_redo/django_redo/__init__.py diff --git a/Code/will/django_labs/django_redo/django_redo/asgi.py b/Code/will/django_labs/django_redo/django_redo/asgi.py new file mode 100644 index 00000000..a3c77a4c --- /dev/null +++ b/Code/will/django_labs/django_redo/django_redo/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for django_redo 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', 'django_redo.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/django_redo/django_redo/settings.py b/Code/will/django_labs/django_redo/django_redo/settings.py new file mode 100644 index 00000000..b2a5b51b --- /dev/null +++ b/Code/will/django_labs/django_redo/django_redo/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for django_redo 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-o-9qg%z2u@vvr&jwz0g&kufuqd&wa0_c-05^&k(^p_2yuqxemk' + +# 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 apps + 'redoapp' +] + +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 = 'django_redo.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 = 'django_redo.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/Chicago' + +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/will/django_labs/django_redo/django_redo/urls.py b/Code/will/django_labs/django_redo/django_redo/urls.py new file mode 100644 index 00000000..5e865be0 --- /dev/null +++ b/Code/will/django_labs/django_redo/django_redo/urls.py @@ -0,0 +1,22 @@ +"""django_redo 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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('unitcon/', include('redoapp.urls')) +] diff --git a/Code/will/django_labs/django_redo/django_redo/wsgi.py b/Code/will/django_labs/django_redo/django_redo/wsgi.py new file mode 100644 index 00000000..7ff1f511 --- /dev/null +++ b/Code/will/django_labs/django_redo/django_redo/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for django_redo 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', 'django_redo.settings') + +application = get_wsgi_application() diff --git a/Code/will/django_labs/django_redo/manage.py b/Code/will/django_labs/django_redo/manage.py new file mode 100644 index 00000000..08e5c2c5 --- /dev/null +++ b/Code/will/django_labs/django_redo/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', 'django_redo.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/will/django/project_1/hello_app/migrations/__init__.py b/Code/will/django_labs/django_redo/redoapp/__init__.py similarity index 100% rename from Code/will/django/project_1/hello_app/migrations/__init__.py rename to Code/will/django_labs/django_redo/redoapp/__init__.py diff --git a/Code/will/django/project_1/hello_app/admin.py b/Code/will/django_labs/django_redo/redoapp/admin.py similarity index 100% rename from Code/will/django/project_1/hello_app/admin.py rename to Code/will/django_labs/django_redo/redoapp/admin.py diff --git a/Code/will/django_labs/django_redo/redoapp/apps.py b/Code/will/django_labs/django_redo/redoapp/apps.py new file mode 100644 index 00000000..4915506e --- /dev/null +++ b/Code/will/django_labs/django_redo/redoapp/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class RedoappConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'redoapp' diff --git a/Code/will/django/project_1/kiwi_first_proj/__init__.py b/Code/will/django_labs/django_redo/redoapp/migrations/__init__.py similarity index 100% rename from Code/will/django/project_1/kiwi_first_proj/__init__.py rename to Code/will/django_labs/django_redo/redoapp/migrations/__init__.py diff --git a/Code/will/django/project_1/hello_app/models.py b/Code/will/django_labs/django_redo/redoapp/models.py similarity index 100% rename from Code/will/django/project_1/hello_app/models.py rename to Code/will/django_labs/django_redo/redoapp/models.py diff --git a/Code/will/django_labs/django_redo/redoapp/templates/redoapp/result.html b/Code/will/django_labs/django_redo/redoapp/templates/redoapp/result.html new file mode 100644 index 00000000..6b094cbb --- /dev/null +++ b/Code/will/django_labs/django_redo/redoapp/templates/redoapp/result.html @@ -0,0 +1,15 @@ + + + + + + + Unit Conversion Results + + +

Results:

+ +

{{distance_to_convert}} {{units_to_convert}} is equal to {{converted_units}} {{meters_to_units}}

+ + + \ No newline at end of file diff --git a/Code/will/django_labs/django_redo/redoapp/templates/redoapp/unitcon.html b/Code/will/django_labs/django_redo/redoapp/templates/redoapp/unitcon.html new file mode 100644 index 00000000..8b4bcc44 --- /dev/null +++ b/Code/will/django_labs/django_redo/redoapp/templates/redoapp/unitcon.html @@ -0,0 +1,27 @@ + + + + + + + Unit Converter + + +

Unit Converting

+

This converter can convert feet, miles, meters, kilometers, yards, and inches.

+ +
+ {% csrf_token %} + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/Code/will/django/project_1/hello_app/tests.py b/Code/will/django_labs/django_redo/redoapp/tests.py similarity index 100% rename from Code/will/django/project_1/hello_app/tests.py rename to Code/will/django_labs/django_redo/redoapp/tests.py diff --git a/Code/will/django_labs/django_redo/redoapp/urls.py b/Code/will/django_labs/django_redo/redoapp/urls.py new file mode 100644 index 00000000..28028e0d --- /dev/null +++ b/Code/will/django_labs/django_redo/redoapp/urls.py @@ -0,0 +1,10 @@ +from django.urls import path +from . import views + +app_name = 'redoapp' +urlpatterns = [ + path('', views.unitcon, name='unitcon'), + + path('result/', views.result, name='result') + +] diff --git a/Code/will/django_labs/django_redo/redoapp/views.py b/Code/will/django_labs/django_redo/redoapp/views.py new file mode 100644 index 00000000..3915b4a7 --- /dev/null +++ b/Code/will/django_labs/django_redo/redoapp/views.py @@ -0,0 +1,33 @@ +from http.client import HTTPResponse +from django.shortcuts import render +from django.http import HttpResponse + +# Create your views here. + + +def unitcon(request): + return render(request, 'redoapp/unitcon.html') + + +def result(request): + conversion = request.POST + + units_to_convert = conversion['convert'] + distance_to_convert = conversion['amount'] + meters_to_units = conversion['converted'] + distance_to_convert = int(distance_to_convert) + + distances = {'feet': 0.3048, 'miles': 1609.34, 'meters': 1.0, + 'kilometers': 1000, 'yards': 0.9144, 'inches': 0.0254} + # convert the meters into the desired second unit and print results + units_to_meters = distance_to_convert * distances.get(units_to_convert) + converted_units = units_to_meters / distances.get(meters_to_units) + converted_units = round(converted_units, 3) + + context = {'converted_units': converted_units, + 'meters_to_units': meters_to_units, + 'units_to_convert': units_to_convert, + 'distance_to_convert': distance_to_convert + } + + return render(request, 'redoapp/result.html', context) diff --git a/Code/will/django_labs/project_1/hello_app/__init__.py b/Code/will/django_labs/project_1/hello_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/project_1/hello_app/admin.py b/Code/will/django_labs/project_1/hello_app/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/will/django_labs/project_1/hello_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/will/django/project_1/hello_app/apps.py b/Code/will/django_labs/project_1/hello_app/apps.py similarity index 100% rename from Code/will/django/project_1/hello_app/apps.py rename to Code/will/django_labs/project_1/hello_app/apps.py diff --git a/Code/will/django_labs/project_1/hello_app/migrations/__init__.py b/Code/will/django_labs/project_1/hello_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/project_1/hello_app/models.py b/Code/will/django_labs/project_1/hello_app/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/Code/will/django_labs/project_1/hello_app/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/Code/will/django/project_1/hello_app/templates/hello_app/index.html b/Code/will/django_labs/project_1/hello_app/templates/hello_app/index.html similarity index 100% rename from Code/will/django/project_1/hello_app/templates/hello_app/index.html rename to Code/will/django_labs/project_1/hello_app/templates/hello_app/index.html diff --git a/Code/will/django_labs/project_1/hello_app/tests.py b/Code/will/django_labs/project_1/hello_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/project_1/hello_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django/project_1/hello_app/urls.py b/Code/will/django_labs/project_1/hello_app/urls.py similarity index 100% rename from Code/will/django/project_1/hello_app/urls.py rename to Code/will/django_labs/project_1/hello_app/urls.py diff --git a/Code/will/django/project_1/hello_app/views.py b/Code/will/django_labs/project_1/hello_app/views.py similarity index 100% rename from Code/will/django/project_1/hello_app/views.py rename to Code/will/django_labs/project_1/hello_app/views.py diff --git a/Code/will/django_labs/project_1/kiwi_first_proj/__init__.py b/Code/will/django_labs/project_1/kiwi_first_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django/project_1/kiwi_first_proj/asgi.py b/Code/will/django_labs/project_1/kiwi_first_proj/asgi.py similarity index 100% rename from Code/will/django/project_1/kiwi_first_proj/asgi.py rename to Code/will/django_labs/project_1/kiwi_first_proj/asgi.py diff --git a/Code/will/django/project_1/kiwi_first_proj/settings.py b/Code/will/django_labs/project_1/kiwi_first_proj/settings.py similarity index 100% rename from Code/will/django/project_1/kiwi_first_proj/settings.py rename to Code/will/django_labs/project_1/kiwi_first_proj/settings.py diff --git a/Code/will/django/project_1/kiwi_first_proj/urls.py b/Code/will/django_labs/project_1/kiwi_first_proj/urls.py similarity index 100% rename from Code/will/django/project_1/kiwi_first_proj/urls.py rename to Code/will/django_labs/project_1/kiwi_first_proj/urls.py diff --git a/Code/will/django/project_1/kiwi_first_proj/wsgi.py b/Code/will/django_labs/project_1/kiwi_first_proj/wsgi.py similarity index 100% rename from Code/will/django/project_1/kiwi_first_proj/wsgi.py rename to Code/will/django_labs/project_1/kiwi_first_proj/wsgi.py diff --git a/Code/will/django/project_1/manage.py b/Code/will/django_labs/project_1/manage.py similarity index 100% rename from Code/will/django/project_1/manage.py rename to Code/will/django_labs/project_1/manage.py From 5810889871070a48684580c2f1b77627cae461e1 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Fri, 25 Mar 2022 22:43:04 -0500 Subject: [PATCH 08/33] model notes and slight changes to html for redo lab --- .../redoapp/templates/redoapp/result.html | 1 + .../redoapp/templates/redoapp/unitcon.html | 1 + Code/will/django_labs/models_notes/manage.py | 22 +++ .../models_notes/model_proj/manage.py | 22 +++ .../model_proj/model_app/__init__.py | 0 .../model_proj/model_app/admin.py | 4 + .../models_notes/model_proj/model_app/apps.py | 6 + .../model_app/migrations/__init__.py | 0 .../model_proj/model_app/models.py | 11 ++ .../model_proj/model_app/tests.py | 3 + .../model_proj/model_app/views.py | 3 + .../model_proj/model_proj/__init__.py | 0 .../model_proj/model_proj/asgi.py | 16 +++ .../model_proj/model_proj/settings.py | 126 ++++++++++++++++++ .../model_proj/model_proj/urls.py | 21 +++ .../model_proj/model_proj/wsgi.py | 16 +++ 16 files changed, 252 insertions(+) create mode 100644 Code/will/django_labs/models_notes/manage.py create mode 100644 Code/will/django_labs/models_notes/model_proj/manage.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_app/__init__.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_app/admin.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_app/apps.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_app/migrations/__init__.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_app/models.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_app/tests.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_app/views.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_proj/__init__.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_proj/asgi.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_proj/settings.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_proj/urls.py create mode 100644 Code/will/django_labs/models_notes/model_proj/model_proj/wsgi.py diff --git a/Code/will/django_labs/django_redo/redoapp/templates/redoapp/result.html b/Code/will/django_labs/django_redo/redoapp/templates/redoapp/result.html index 6b094cbb..3d1ca2a8 100644 --- a/Code/will/django_labs/django_redo/redoapp/templates/redoapp/result.html +++ b/Code/will/django_labs/django_redo/redoapp/templates/redoapp/result.html @@ -9,6 +9,7 @@

Results:

+

{{distance_to_convert}} {{units_to_convert}} is equal to {{converted_units}} {{meters_to_units}}

diff --git a/Code/will/django_labs/django_redo/redoapp/templates/redoapp/unitcon.html b/Code/will/django_labs/django_redo/redoapp/templates/redoapp/unitcon.html index 8b4bcc44..413dcd3a 100644 --- a/Code/will/django_labs/django_redo/redoapp/templates/redoapp/unitcon.html +++ b/Code/will/django_labs/django_redo/redoapp/templates/redoapp/unitcon.html @@ -10,6 +10,7 @@

Unit Converting

This converter can convert feet, miles, meters, kilometers, yards, and inches.

+
{% csrf_token %} diff --git a/Code/will/django_labs/models_notes/manage.py b/Code/will/django_labs/models_notes/manage.py new file mode 100644 index 00000000..1cfbde4f --- /dev/null +++ b/Code/will/django_labs/models_notes/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', 'model_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/will/django_labs/models_notes/model_proj/manage.py b/Code/will/django_labs/models_notes/model_proj/manage.py new file mode 100644 index 00000000..440fd52a --- /dev/null +++ b/Code/will/django_labs/models_notes/model_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', 'model_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/will/django_labs/models_notes/model_proj/model_app/__init__.py b/Code/will/django_labs/models_notes/model_proj/model_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/admin.py b/Code/will/django_labs/models_notes/model_proj/model_app/admin.py new file mode 100644 index 00000000..f715c5b8 --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_app/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Kiwi + +# Register your models here. diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/apps.py b/Code/will/django_labs/models_notes/model_proj/model_app/apps.py new file mode 100644 index 00000000..a74b35dd --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ModelAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'model_app' diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/migrations/__init__.py b/Code/will/django_labs/models_notes/model_proj/model_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/models.py b/Code/will/django_labs/models_notes/model_proj/model_app/models.py new file mode 100644 index 00000000..68a0a0ea --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_app/models.py @@ -0,0 +1,11 @@ +from django.db import models + +# Create your models here. + + +class Kiwi(models.Model): + name = models.CharField(max_length=100) + pub_date = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f'{self.name}' diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/tests.py b/Code/will/django_labs/models_notes/model_proj/model_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/views.py b/Code/will/django_labs/models_notes/model_proj/model_app/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_app/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/Code/will/django_labs/models_notes/model_proj/model_proj/__init__.py b/Code/will/django_labs/models_notes/model_proj/model_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/models_notes/model_proj/model_proj/asgi.py b/Code/will/django_labs/models_notes/model_proj/model_proj/asgi.py new file mode 100644 index 00000000..19c66a6a --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for model_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', 'model_proj.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/models_notes/model_proj/model_proj/settings.py b/Code/will/django_labs/models_notes/model_proj/model_proj/settings.py new file mode 100644 index 00000000..a32b9b46 --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_proj/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for model_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-nukbt+(z62+&xsxf$*-!5$-b)s*e*h!ij9%ehd5po5if#ev_5!' + +# 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 apps + 'model_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 = 'model_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 = 'model_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 = 'UTC' + +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/will/django_labs/models_notes/model_proj/model_proj/urls.py b/Code/will/django_labs/models_notes/model_proj/model_proj/urls.py new file mode 100644 index 00000000..67940092 --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_proj/urls.py @@ -0,0 +1,21 @@ +"""model_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/will/django_labs/models_notes/model_proj/model_proj/wsgi.py b/Code/will/django_labs/models_notes/model_proj/model_proj/wsgi.py new file mode 100644 index 00000000..c2f1f377 --- /dev/null +++ b/Code/will/django_labs/models_notes/model_proj/model_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for model_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', 'model_proj.settings') + +application = get_wsgi_application() From 673f7ba03f14713d332163dcdc681ebb2340c9b3 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Mon, 28 Mar 2022 23:02:55 -0500 Subject: [PATCH 09/33] Django notes and Django First Program lab --- Code/will/django_labs/mysite/manage.py | 22 +++ .../model_app => mysite/mysite}/__init__.py | 0 Code/will/django_labs/mysite/mysite/asgi.py | 16 +++ .../django_labs/mysite/mysite/settings.py | 124 +++++++++++++++++ Code/will/django_labs/mysite/mysite/urls.py | 22 +++ Code/will/django_labs/mysite/mysite/wsgi.py | 16 +++ .../migrations => mysite/polls}/__init__.py | 0 .../hello_app => mysite/polls}/admin.py | 0 Code/will/django_labs/mysite/polls/apps.py | 6 + .../mysite/polls/migrations/0001_initial.py | 32 +++++ .../polls/migrations}/__init__.py | 0 Code/will/django_labs/mysite/polls/models.py | 14 ++ .../model_app => mysite/polls}/tests.py | 0 Code/will/django_labs/mysite/polls/urls.py | 7 + Code/will/django_labs/mysite/polls/views.py | 8 ++ .../is_it_xmas/is_it_xmas}/__init__.py | 0 .../is_it_xmas/is_it_xmas/asgi.py | 16 +++ .../is_it_xmas/is_it_xmas/settings.py | 126 ++++++++++++++++++ .../is_it_xmas/is_it_xmas/urls.py | 22 +++ .../is_it_xmas/is_it_xmas/wsgi.py | 16 +++ .../practice_labs/is_it_xmas/manage.py | 22 +++ .../is_it_xmas/xmas_app}/__init__.py | 0 .../is_it_xmas/xmas_app/admin.py | 3 + .../practice_labs/is_it_xmas/xmas_app/apps.py | 6 + .../xmas_app/migrations}/__init__.py | 0 .../is_it_xmas/xmas_app}/models.py | 0 .../xmas_app/templates/xmas_app/index.html | 12 ++ .../is_it_xmas/xmas_app}/tests.py | 0 .../practice_labs/is_it_xmas/xmas_app/urls.py | 8 ++ .../is_it_xmas/xmas_app/views.py | 9 ++ .../models_notes/manage.py | 0 .../models_notes/model_proj/manage.py | 0 .../model_proj/model_app/__init__.py | 0 .../model_proj/model_app/admin.py | 0 .../models_notes/model_proj/model_app/apps.py | 0 .../model_app/migrations/__init__.py | 0 .../model_proj/model_app/models.py | 0 .../model_proj/model_app/tests.py | 3 + .../model_proj/model_app/views.py | 0 .../model_proj/model_proj/__init__.py | 0 .../model_proj/model_proj/asgi.py | 0 .../model_proj/model_proj/settings.py | 0 .../model_proj/model_proj/urls.py | 0 .../model_proj/model_proj/wsgi.py | 0 .../project_1/hello_app/__init__.py | 0 .../project_1/hello_app/admin.py | 3 + .../project_1/hello_app/apps.py | 0 .../hello_app/migrations/__init__.py | 0 .../project_1/hello_app/models.py | 3 + .../hello_app/templates/hello_app/index.html | 0 .../project_1/hello_app/tests.py | 3 + .../project_1/hello_app/urls.py | 0 .../project_1/hello_app/views.py | 0 .../project_1/kiwi_first_proj/__init__.py | 0 .../project_1/kiwi_first_proj/asgi.py | 0 .../project_1/kiwi_first_proj/settings.py | 0 .../project_1/kiwi_first_proj/urls.py | 0 .../project_1/kiwi_first_proj/wsgi.py | 0 .../{ => practice_labs}/project_1/manage.py | 0 59 files changed, 519 insertions(+) create mode 100644 Code/will/django_labs/mysite/manage.py rename Code/will/django_labs/{models_notes/model_proj/model_app => mysite/mysite}/__init__.py (100%) create mode 100644 Code/will/django_labs/mysite/mysite/asgi.py create mode 100644 Code/will/django_labs/mysite/mysite/settings.py create mode 100644 Code/will/django_labs/mysite/mysite/urls.py create mode 100644 Code/will/django_labs/mysite/mysite/wsgi.py rename Code/will/django_labs/{models_notes/model_proj/model_app/migrations => mysite/polls}/__init__.py (100%) rename Code/will/django_labs/{project_1/hello_app => mysite/polls}/admin.py (100%) create mode 100644 Code/will/django_labs/mysite/polls/apps.py create mode 100644 Code/will/django_labs/mysite/polls/migrations/0001_initial.py rename Code/will/django_labs/{models_notes/model_proj/model_proj => mysite/polls/migrations}/__init__.py (100%) create mode 100644 Code/will/django_labs/mysite/polls/models.py rename Code/will/django_labs/{models_notes/model_proj/model_app => mysite/polls}/tests.py (100%) create mode 100644 Code/will/django_labs/mysite/polls/urls.py create mode 100644 Code/will/django_labs/mysite/polls/views.py rename Code/will/django_labs/{project_1/hello_app => practice_labs/is_it_xmas/is_it_xmas}/__init__.py (100%) create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/asgi.py create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/settings.py create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/urls.py create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/wsgi.py create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/manage.py rename Code/will/django_labs/{project_1/hello_app/migrations => practice_labs/is_it_xmas/xmas_app}/__init__.py (100%) create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/admin.py create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/apps.py rename Code/will/django_labs/{project_1/kiwi_first_proj => practice_labs/is_it_xmas/xmas_app/migrations}/__init__.py (100%) rename Code/will/django_labs/{project_1/hello_app => practice_labs/is_it_xmas/xmas_app}/models.py (100%) create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/templates/xmas_app/index.html rename Code/will/django_labs/{project_1/hello_app => practice_labs/is_it_xmas/xmas_app}/tests.py (100%) create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/urls.py create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/views.py rename Code/will/django_labs/{ => practice_labs}/models_notes/manage.py (100%) rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/manage.py (100%) create mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/__init__.py rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/model_app/admin.py (100%) rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/model_app/apps.py (100%) create mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/migrations/__init__.py rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/model_app/models.py (100%) create mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/tests.py rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/model_app/views.py (100%) create mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/__init__.py rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/model_proj/asgi.py (100%) rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/model_proj/settings.py (100%) rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/model_proj/urls.py (100%) rename Code/will/django_labs/{ => practice_labs}/models_notes/model_proj/model_proj/wsgi.py (100%) create mode 100644 Code/will/django_labs/practice_labs/project_1/hello_app/__init__.py create mode 100644 Code/will/django_labs/practice_labs/project_1/hello_app/admin.py rename Code/will/django_labs/{ => practice_labs}/project_1/hello_app/apps.py (100%) create mode 100644 Code/will/django_labs/practice_labs/project_1/hello_app/migrations/__init__.py create mode 100644 Code/will/django_labs/practice_labs/project_1/hello_app/models.py rename Code/will/django_labs/{ => practice_labs}/project_1/hello_app/templates/hello_app/index.html (100%) create mode 100644 Code/will/django_labs/practice_labs/project_1/hello_app/tests.py rename Code/will/django_labs/{ => practice_labs}/project_1/hello_app/urls.py (100%) rename Code/will/django_labs/{ => practice_labs}/project_1/hello_app/views.py (100%) create mode 100644 Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/__init__.py rename Code/will/django_labs/{ => practice_labs}/project_1/kiwi_first_proj/asgi.py (100%) rename Code/will/django_labs/{ => practice_labs}/project_1/kiwi_first_proj/settings.py (100%) rename Code/will/django_labs/{ => practice_labs}/project_1/kiwi_first_proj/urls.py (100%) rename Code/will/django_labs/{ => practice_labs}/project_1/kiwi_first_proj/wsgi.py (100%) rename Code/will/django_labs/{ => practice_labs}/project_1/manage.py (100%) diff --git a/Code/will/django_labs/mysite/manage.py b/Code/will/django_labs/mysite/manage.py new file mode 100644 index 00000000..a7da6671 --- /dev/null +++ b/Code/will/django_labs/mysite/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', 'mysite.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/will/django_labs/models_notes/model_proj/model_app/__init__.py b/Code/will/django_labs/mysite/mysite/__init__.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_app/__init__.py rename to Code/will/django_labs/mysite/mysite/__init__.py diff --git a/Code/will/django_labs/mysite/mysite/asgi.py b/Code/will/django_labs/mysite/mysite/asgi.py new file mode 100644 index 00000000..674a5a5a --- /dev/null +++ b/Code/will/django_labs/mysite/mysite/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for mysite 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', 'mysite.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/mysite/mysite/settings.py b/Code/will/django_labs/mysite/mysite/settings.py new file mode 100644 index 00000000..ce970f3c --- /dev/null +++ b/Code/will/django_labs/mysite/mysite/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for mysite 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-cs#6a_w4p=#k&e0&(i^qgzneo%1h28omr7j_srakq9yt%fdrq-' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'polls.apps.PollsConfig', + '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 = 'mysite.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 = 'mysite.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/Chicago' + +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/will/django_labs/mysite/mysite/urls.py b/Code/will/django_labs/mysite/mysite/urls.py new file mode 100644 index 00000000..d203d9fc --- /dev/null +++ b/Code/will/django_labs/mysite/mysite/urls.py @@ -0,0 +1,22 @@ +"""mysite 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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('polls/', include('polls.urls')) +] diff --git a/Code/will/django_labs/mysite/mysite/wsgi.py b/Code/will/django_labs/mysite/mysite/wsgi.py new file mode 100644 index 00000000..48d46fe4 --- /dev/null +++ b/Code/will/django_labs/mysite/mysite/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for mysite 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', 'mysite.settings') + +application = get_wsgi_application() diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/migrations/__init__.py b/Code/will/django_labs/mysite/polls/__init__.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_app/migrations/__init__.py rename to Code/will/django_labs/mysite/polls/__init__.py diff --git a/Code/will/django_labs/project_1/hello_app/admin.py b/Code/will/django_labs/mysite/polls/admin.py similarity index 100% rename from Code/will/django_labs/project_1/hello_app/admin.py rename to Code/will/django_labs/mysite/polls/admin.py diff --git a/Code/will/django_labs/mysite/polls/apps.py b/Code/will/django_labs/mysite/polls/apps.py new file mode 100644 index 00000000..5a5f94ca --- /dev/null +++ b/Code/will/django_labs/mysite/polls/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class PollsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'polls' diff --git a/Code/will/django_labs/mysite/polls/migrations/0001_initial.py b/Code/will/django_labs/mysite/polls/migrations/0001_initial.py new file mode 100644 index 00000000..93d4bd00 --- /dev/null +++ b/Code/will/django_labs/mysite/polls/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 4.0.3 on 2022-03-29 03:57 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Question', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('question_text', models.CharField(max_length=200)), + ('pub_date', models.DateTimeField(verbose_name='date published')), + ], + ), + migrations.CreateModel( + name='Choice', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('choice_text', models.CharField(max_length=200)), + ('votes', models.IntegerField(default=0)), + ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.question')), + ], + ), + ] diff --git a/Code/will/django_labs/models_notes/model_proj/model_proj/__init__.py b/Code/will/django_labs/mysite/polls/migrations/__init__.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_proj/__init__.py rename to Code/will/django_labs/mysite/polls/migrations/__init__.py diff --git a/Code/will/django_labs/mysite/polls/models.py b/Code/will/django_labs/mysite/polls/models.py new file mode 100644 index 00000000..8f8260b1 --- /dev/null +++ b/Code/will/django_labs/mysite/polls/models.py @@ -0,0 +1,14 @@ +from django.db import models + +# Create your models here. + + +class Question(models.Model): + question_text = models.CharField(max_length=200) + pub_date = models.DateTimeField('date published') + + +class Choice(models.Model): + question = models.ForeignKey(Question, on_delete=models.CASCADE) + choice_text = models.CharField(max_length=200) + votes = models.IntegerField(default=0) diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/tests.py b/Code/will/django_labs/mysite/polls/tests.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_app/tests.py rename to Code/will/django_labs/mysite/polls/tests.py diff --git a/Code/will/django_labs/mysite/polls/urls.py b/Code/will/django_labs/mysite/polls/urls.py new file mode 100644 index 00000000..2c52f212 --- /dev/null +++ b/Code/will/django_labs/mysite/polls/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.index, name='index') + +] diff --git a/Code/will/django_labs/mysite/polls/views.py b/Code/will/django_labs/mysite/polls/views.py new file mode 100644 index 00000000..295a80ff --- /dev/null +++ b/Code/will/django_labs/mysite/polls/views.py @@ -0,0 +1,8 @@ +from django.shortcuts import render +from django.http import HttpResponse + +# Create your views here. + + +def index(request): + return HttpResponse("Hello, world. You're at the polls index.") diff --git a/Code/will/django_labs/project_1/hello_app/__init__.py b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/__init__.py similarity index 100% rename from Code/will/django_labs/project_1/hello_app/__init__.py rename to Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/__init__.py diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/asgi.py b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/asgi.py new file mode 100644 index 00000000..61ac89b1 --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for is_it_xmas 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', 'is_it_xmas.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/settings.py b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/settings.py new file mode 100644 index 00000000..785a4190 --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for is_it_xmas 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-=gf^bf+aem1+&n9v&-ia(s)bd$fx-(*ox7*dao6!$+34%lb(g)' + +# 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 Apps + 'xmas_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 = 'is_it_xmas.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 = 'is_it_xmas.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/Chicago' + +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/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/urls.py b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/urls.py new file mode 100644 index 00000000..804d96b8 --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/urls.py @@ -0,0 +1,22 @@ +"""is_it_xmas 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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('index/', include('xmas_app.urls')) +] diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/wsgi.py b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/wsgi.py new file mode 100644 index 00000000..ab4eaa69 --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/is_it_xmas/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for is_it_xmas 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', 'is_it_xmas.settings') + +application = get_wsgi_application() diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/manage.py b/Code/will/django_labs/practice_labs/is_it_xmas/manage.py new file mode 100644 index 00000000..7a87969e --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/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', 'is_it_xmas.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/will/django_labs/project_1/hello_app/migrations/__init__.py b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/__init__.py similarity index 100% rename from Code/will/django_labs/project_1/hello_app/migrations/__init__.py rename to Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/__init__.py diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/admin.py b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/apps.py b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/apps.py new file mode 100644 index 00000000..699d5350 --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class XmasAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'xmas_app' diff --git a/Code/will/django_labs/project_1/kiwi_first_proj/__init__.py b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/migrations/__init__.py similarity index 100% rename from Code/will/django_labs/project_1/kiwi_first_proj/__init__.py rename to Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/migrations/__init__.py diff --git a/Code/will/django_labs/project_1/hello_app/models.py b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/models.py similarity index 100% rename from Code/will/django_labs/project_1/hello_app/models.py rename to Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/models.py diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/templates/xmas_app/index.html b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/templates/xmas_app/index.html new file mode 100644 index 00000000..56efbdba --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/templates/xmas_app/index.html @@ -0,0 +1,12 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git a/Code/will/django_labs/project_1/hello_app/tests.py b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/tests.py similarity index 100% rename from Code/will/django_labs/project_1/hello_app/tests.py rename to Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/tests.py diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/urls.py b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/urls.py new file mode 100644 index 00000000..98ca879c --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from . import views + +app_name = 'xmas_app' +urlpatterns = [ + path('', views.index, name='index') + +] diff --git a/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/views.py b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/views.py new file mode 100644 index 00000000..13389d86 --- /dev/null +++ b/Code/will/django_labs/practice_labs/is_it_xmas/xmas_app/views.py @@ -0,0 +1,9 @@ +from http.client import HTTPResponse +from django.shortcuts import render +from django.http import HttpResponse + +# Create your views here. + + +def index(request): + return HttpResponse('hello world') diff --git a/Code/will/django_labs/models_notes/manage.py b/Code/will/django_labs/practice_labs/models_notes/manage.py similarity index 100% rename from Code/will/django_labs/models_notes/manage.py rename to Code/will/django_labs/practice_labs/models_notes/manage.py diff --git a/Code/will/django_labs/models_notes/model_proj/manage.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/manage.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/manage.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/manage.py diff --git a/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/__init__.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/admin.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/admin.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_app/admin.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/admin.py diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/apps.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/apps.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_app/apps.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/apps.py diff --git a/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/migrations/__init__.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/models.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/models.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_app/models.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/models.py diff --git a/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/tests.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/models_notes/model_proj/model_app/views.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/views.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_app/views.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/views.py diff --git a/Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/__init__.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/models_notes/model_proj/model_proj/asgi.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/asgi.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_proj/asgi.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/asgi.py diff --git a/Code/will/django_labs/models_notes/model_proj/model_proj/settings.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/settings.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_proj/settings.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/settings.py diff --git a/Code/will/django_labs/models_notes/model_proj/model_proj/urls.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/urls.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_proj/urls.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/urls.py diff --git a/Code/will/django_labs/models_notes/model_proj/model_proj/wsgi.py b/Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/wsgi.py similarity index 100% rename from Code/will/django_labs/models_notes/model_proj/model_proj/wsgi.py rename to Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/wsgi.py diff --git a/Code/will/django_labs/practice_labs/project_1/hello_app/__init__.py b/Code/will/django_labs/practice_labs/project_1/hello_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/project_1/hello_app/admin.py b/Code/will/django_labs/practice_labs/project_1/hello_app/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/will/django_labs/practice_labs/project_1/hello_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/will/django_labs/project_1/hello_app/apps.py b/Code/will/django_labs/practice_labs/project_1/hello_app/apps.py similarity index 100% rename from Code/will/django_labs/project_1/hello_app/apps.py rename to Code/will/django_labs/practice_labs/project_1/hello_app/apps.py diff --git a/Code/will/django_labs/practice_labs/project_1/hello_app/migrations/__init__.py b/Code/will/django_labs/practice_labs/project_1/hello_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/project_1/hello_app/models.py b/Code/will/django_labs/practice_labs/project_1/hello_app/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/Code/will/django_labs/practice_labs/project_1/hello_app/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/Code/will/django_labs/project_1/hello_app/templates/hello_app/index.html b/Code/will/django_labs/practice_labs/project_1/hello_app/templates/hello_app/index.html similarity index 100% rename from Code/will/django_labs/project_1/hello_app/templates/hello_app/index.html rename to Code/will/django_labs/practice_labs/project_1/hello_app/templates/hello_app/index.html diff --git a/Code/will/django_labs/practice_labs/project_1/hello_app/tests.py b/Code/will/django_labs/practice_labs/project_1/hello_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/practice_labs/project_1/hello_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/project_1/hello_app/urls.py b/Code/will/django_labs/practice_labs/project_1/hello_app/urls.py similarity index 100% rename from Code/will/django_labs/project_1/hello_app/urls.py rename to Code/will/django_labs/practice_labs/project_1/hello_app/urls.py diff --git a/Code/will/django_labs/project_1/hello_app/views.py b/Code/will/django_labs/practice_labs/project_1/hello_app/views.py similarity index 100% rename from Code/will/django_labs/project_1/hello_app/views.py rename to Code/will/django_labs/practice_labs/project_1/hello_app/views.py diff --git a/Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/__init__.py b/Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/project_1/kiwi_first_proj/asgi.py b/Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/asgi.py similarity index 100% rename from Code/will/django_labs/project_1/kiwi_first_proj/asgi.py rename to Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/asgi.py diff --git a/Code/will/django_labs/project_1/kiwi_first_proj/settings.py b/Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/settings.py similarity index 100% rename from Code/will/django_labs/project_1/kiwi_first_proj/settings.py rename to Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/settings.py diff --git a/Code/will/django_labs/project_1/kiwi_first_proj/urls.py b/Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/urls.py similarity index 100% rename from Code/will/django_labs/project_1/kiwi_first_proj/urls.py rename to Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/urls.py diff --git a/Code/will/django_labs/project_1/kiwi_first_proj/wsgi.py b/Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/wsgi.py similarity index 100% rename from Code/will/django_labs/project_1/kiwi_first_proj/wsgi.py rename to Code/will/django_labs/practice_labs/project_1/kiwi_first_proj/wsgi.py diff --git a/Code/will/django_labs/project_1/manage.py b/Code/will/django_labs/practice_labs/project_1/manage.py similarity index 100% rename from Code/will/django_labs/project_1/manage.py rename to Code/will/django_labs/practice_labs/project_1/manage.py From aea8eab12a737b01b8c6137921750d5cdd7c9ec2 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Tue, 29 Mar 2022 23:10:14 -0500 Subject: [PATCH 10/33] Django First App progress --- Code/will/django_labs/mysite/polls/admin.py | 2 ++ Code/will/django_labs/mysite/polls/models.py | 12 +++++++++++- Code/will/django_labs/mysite/polls/urls.py | 6 ++++-- Code/will/django_labs/mysite/polls/views.py | 13 +++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Code/will/django_labs/mysite/polls/admin.py b/Code/will/django_labs/mysite/polls/admin.py index 8c38f3f3..93a4a5ea 100644 --- a/Code/will/django_labs/mysite/polls/admin.py +++ b/Code/will/django_labs/mysite/polls/admin.py @@ -1,3 +1,5 @@ from django.contrib import admin +from .models import Question # Register your models here. +admin.site.register(Question) diff --git a/Code/will/django_labs/mysite/polls/models.py b/Code/will/django_labs/mysite/polls/models.py index 8f8260b1..64074017 100644 --- a/Code/will/django_labs/mysite/polls/models.py +++ b/Code/will/django_labs/mysite/polls/models.py @@ -1,5 +1,6 @@ +import datetime from django.db import models - +from django.utils import timezone # Create your models here. @@ -7,8 +8,17 @@ class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') + def __str__(self): + return self.question_text + + def was_published_recently(self): + return self.pub_date >= timezone.now() - datetime.timedelta(days=1) + class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) + + def __str__(self): + return self.choice_text diff --git a/Code/will/django_labs/mysite/polls/urls.py b/Code/will/django_labs/mysite/polls/urls.py index 2c52f212..9e6ca5f5 100644 --- a/Code/will/django_labs/mysite/polls/urls.py +++ b/Code/will/django_labs/mysite/polls/urls.py @@ -2,6 +2,8 @@ from . import views urlpatterns = [ - path('', views.index, name='index') - + path('', views.index, name='index'), + path('/', views.detail, name='detail'), + path('/results/', views.results, name='results'), + path('/vote/', views.vote, name='vote') ] diff --git a/Code/will/django_labs/mysite/polls/views.py b/Code/will/django_labs/mysite/polls/views.py index 295a80ff..019cb3bf 100644 --- a/Code/will/django_labs/mysite/polls/views.py +++ b/Code/will/django_labs/mysite/polls/views.py @@ -6,3 +6,16 @@ def index(request): return HttpResponse("Hello, world. You're at the polls index.") + + +def detail(request, question_id): + return HttpResponse("You're looking at question %s." % question_id) + + +def results(request, question_id): + response = "You're looking athe the results of question %s." + return HttpResponse(response % question_id) + + +def vote(request, question_id): + return HttpResponse*("You're voting on question %s." % question_id) From f40c2b3ce9cef4652fcfeb12c3d6b596ea59f010 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Wed, 30 Mar 2022 23:04:56 -0500 Subject: [PATCH 11/33] Grocery List Proj Progress --- .../grocery_list_proj}/__init__.py | 0 .../grocery_list_proj/asgi.py | 16 +++ .../grocery_list_proj/settings.py | 126 ++++++++++++++++++ .../grocery_list_proj/urls.py | 22 +++ .../grocery_list_proj/wsgi.py | 16 +++ .../listapp}/__init__.py | 0 .../grocery_list_proj/listapp/admin.py | 3 + .../grocery_list_proj/listapp/apps.py | 6 + .../listapp}/migrations/__init__.py | 0 .../grocery_list_proj/listapp/models.py | 9 ++ .../listapp/templates/listapp/index.html | 12 ++ .../listapp}/tests.py | 0 .../grocery_list_proj/listapp/urls.py | 7 + .../grocery_list_proj/listapp/views.py | 8 ++ .../django_labs/grocery_list_proj/manage.py | 22 +++ .../{ => practice_labs}/mysite/manage.py | 0 .../practice_labs/mysite/mysite/__init__.py | 0 .../{ => practice_labs}/mysite/mysite/asgi.py | 0 .../mysite/mysite/settings.py | 0 .../{ => practice_labs}/mysite/mysite/urls.py | 0 .../{ => practice_labs}/mysite/mysite/wsgi.py | 0 .../practice_labs/mysite/polls/__init__.py | 0 .../{ => practice_labs}/mysite/polls/admin.py | 0 .../{ => practice_labs}/mysite/polls/apps.py | 0 .../mysite/polls/migrations/0001_initial.py | 0 .../mysite/polls/migrations/__init__.py | 0 .../mysite/polls/models.py | 0 .../practice_labs/mysite/polls/tests.py | 3 + .../{ => practice_labs}/mysite/polls/urls.py | 0 .../{ => practice_labs}/mysite/polls/views.py | 0 30 files changed, 250 insertions(+) rename Code/will/django_labs/{mysite/mysite => grocery_list_proj/grocery_list_proj}/__init__.py (100%) create mode 100644 Code/will/django_labs/grocery_list_proj/grocery_list_proj/asgi.py create mode 100644 Code/will/django_labs/grocery_list_proj/grocery_list_proj/settings.py create mode 100644 Code/will/django_labs/grocery_list_proj/grocery_list_proj/urls.py create mode 100644 Code/will/django_labs/grocery_list_proj/grocery_list_proj/wsgi.py rename Code/will/django_labs/{mysite/polls => grocery_list_proj/listapp}/__init__.py (100%) create mode 100644 Code/will/django_labs/grocery_list_proj/listapp/admin.py create mode 100644 Code/will/django_labs/grocery_list_proj/listapp/apps.py rename Code/will/django_labs/{mysite/polls => grocery_list_proj/listapp}/migrations/__init__.py (100%) create mode 100644 Code/will/django_labs/grocery_list_proj/listapp/models.py create mode 100644 Code/will/django_labs/grocery_list_proj/listapp/templates/listapp/index.html rename Code/will/django_labs/{mysite/polls => grocery_list_proj/listapp}/tests.py (100%) create mode 100644 Code/will/django_labs/grocery_list_proj/listapp/urls.py create mode 100644 Code/will/django_labs/grocery_list_proj/listapp/views.py create mode 100644 Code/will/django_labs/grocery_list_proj/manage.py rename Code/will/django_labs/{ => practice_labs}/mysite/manage.py (100%) create mode 100644 Code/will/django_labs/practice_labs/mysite/mysite/__init__.py rename Code/will/django_labs/{ => practice_labs}/mysite/mysite/asgi.py (100%) rename Code/will/django_labs/{ => practice_labs}/mysite/mysite/settings.py (100%) rename Code/will/django_labs/{ => practice_labs}/mysite/mysite/urls.py (100%) rename Code/will/django_labs/{ => practice_labs}/mysite/mysite/wsgi.py (100%) create mode 100644 Code/will/django_labs/practice_labs/mysite/polls/__init__.py rename Code/will/django_labs/{ => practice_labs}/mysite/polls/admin.py (100%) rename Code/will/django_labs/{ => practice_labs}/mysite/polls/apps.py (100%) rename Code/will/django_labs/{ => practice_labs}/mysite/polls/migrations/0001_initial.py (100%) create mode 100644 Code/will/django_labs/practice_labs/mysite/polls/migrations/__init__.py rename Code/will/django_labs/{ => practice_labs}/mysite/polls/models.py (100%) create mode 100644 Code/will/django_labs/practice_labs/mysite/polls/tests.py rename Code/will/django_labs/{ => practice_labs}/mysite/polls/urls.py (100%) rename Code/will/django_labs/{ => practice_labs}/mysite/polls/views.py (100%) diff --git a/Code/will/django_labs/mysite/mysite/__init__.py b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/__init__.py similarity index 100% rename from Code/will/django_labs/mysite/mysite/__init__.py rename to Code/will/django_labs/grocery_list_proj/grocery_list_proj/__init__.py diff --git a/Code/will/django_labs/grocery_list_proj/grocery_list_proj/asgi.py b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/asgi.py new file mode 100644 index 00000000..2b31c0c2 --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for grocery_list_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', 'grocery_list_proj.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/grocery_list_proj/grocery_list_proj/settings.py b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/settings.py new file mode 100644 index 00000000..0ba4bfa9 --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for grocery_list_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-sd_z@k=-hwfug#20+4amj&a8c=gbq@c(8s#6lty@0w*y56&nw2' + +# 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 apps + 'listapp' +] + +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_list_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_list_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/Chicago' + +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/will/django_labs/grocery_list_proj/grocery_list_proj/urls.py b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/urls.py new file mode 100644 index 00000000..791bf9af --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/urls.py @@ -0,0 +1,22 @@ +"""grocery_list_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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('index/'), include('listapp.urls') +] diff --git a/Code/will/django_labs/grocery_list_proj/grocery_list_proj/wsgi.py b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/wsgi.py new file mode 100644 index 00000000..b291aef5 --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for grocery_list_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', 'grocery_list_proj.settings') + +application = get_wsgi_application() diff --git a/Code/will/django_labs/mysite/polls/__init__.py b/Code/will/django_labs/grocery_list_proj/listapp/__init__.py similarity index 100% rename from Code/will/django_labs/mysite/polls/__init__.py rename to Code/will/django_labs/grocery_list_proj/listapp/__init__.py diff --git a/Code/will/django_labs/grocery_list_proj/listapp/admin.py b/Code/will/django_labs/grocery_list_proj/listapp/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/listapp/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/will/django_labs/grocery_list_proj/listapp/apps.py b/Code/will/django_labs/grocery_list_proj/listapp/apps.py new file mode 100644 index 00000000..c7bcf818 --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/listapp/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ListappConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'listapp' diff --git a/Code/will/django_labs/mysite/polls/migrations/__init__.py b/Code/will/django_labs/grocery_list_proj/listapp/migrations/__init__.py similarity index 100% rename from Code/will/django_labs/mysite/polls/migrations/__init__.py rename to Code/will/django_labs/grocery_list_proj/listapp/migrations/__init__.py diff --git a/Code/will/django_labs/grocery_list_proj/listapp/models.py b/Code/will/django_labs/grocery_list_proj/listapp/models.py new file mode 100644 index 00000000..6e7db86a --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/listapp/models.py @@ -0,0 +1,9 @@ +from django.db import models + +# Create your models here. + + +class GroceryItem(models.Model): + item_descrip = models.CharField(max_length=200) + + completed = models.BooleanField(default=False) diff --git a/Code/will/django_labs/grocery_list_proj/listapp/templates/listapp/index.html b/Code/will/django_labs/grocery_list_proj/listapp/templates/listapp/index.html new file mode 100644 index 00000000..fbaf39d3 --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/listapp/templates/listapp/index.html @@ -0,0 +1,12 @@ + + + + + + + stuff + + + words + + \ No newline at end of file diff --git a/Code/will/django_labs/mysite/polls/tests.py b/Code/will/django_labs/grocery_list_proj/listapp/tests.py similarity index 100% rename from Code/will/django_labs/mysite/polls/tests.py rename to Code/will/django_labs/grocery_list_proj/listapp/tests.py diff --git a/Code/will/django_labs/grocery_list_proj/listapp/urls.py b/Code/will/django_labs/grocery_list_proj/listapp/urls.py new file mode 100644 index 00000000..a87ec761 --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/listapp/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +app_name = 'listapp' +urlpatterns = [ + path('', views.index, name='index') +] diff --git a/Code/will/django_labs/grocery_list_proj/listapp/views.py b/Code/will/django_labs/grocery_list_proj/listapp/views.py new file mode 100644 index 00000000..1aae48f4 --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/listapp/views.py @@ -0,0 +1,8 @@ +from django.shortcuts import render +from django.http import HttpResponse + +# Create your views here. + + +def index(request): + return render(request, 'listapp/index.html') diff --git a/Code/will/django_labs/grocery_list_proj/manage.py b/Code/will/django_labs/grocery_list_proj/manage.py new file mode 100644 index 00000000..91f82040 --- /dev/null +++ b/Code/will/django_labs/grocery_list_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', 'grocery_list_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/will/django_labs/mysite/manage.py b/Code/will/django_labs/practice_labs/mysite/manage.py similarity index 100% rename from Code/will/django_labs/mysite/manage.py rename to Code/will/django_labs/practice_labs/mysite/manage.py diff --git a/Code/will/django_labs/practice_labs/mysite/mysite/__init__.py b/Code/will/django_labs/practice_labs/mysite/mysite/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/mysite/mysite/asgi.py b/Code/will/django_labs/practice_labs/mysite/mysite/asgi.py similarity index 100% rename from Code/will/django_labs/mysite/mysite/asgi.py rename to Code/will/django_labs/practice_labs/mysite/mysite/asgi.py diff --git a/Code/will/django_labs/mysite/mysite/settings.py b/Code/will/django_labs/practice_labs/mysite/mysite/settings.py similarity index 100% rename from Code/will/django_labs/mysite/mysite/settings.py rename to Code/will/django_labs/practice_labs/mysite/mysite/settings.py diff --git a/Code/will/django_labs/mysite/mysite/urls.py b/Code/will/django_labs/practice_labs/mysite/mysite/urls.py similarity index 100% rename from Code/will/django_labs/mysite/mysite/urls.py rename to Code/will/django_labs/practice_labs/mysite/mysite/urls.py diff --git a/Code/will/django_labs/mysite/mysite/wsgi.py b/Code/will/django_labs/practice_labs/mysite/mysite/wsgi.py similarity index 100% rename from Code/will/django_labs/mysite/mysite/wsgi.py rename to Code/will/django_labs/practice_labs/mysite/mysite/wsgi.py diff --git a/Code/will/django_labs/practice_labs/mysite/polls/__init__.py b/Code/will/django_labs/practice_labs/mysite/polls/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/mysite/polls/admin.py b/Code/will/django_labs/practice_labs/mysite/polls/admin.py similarity index 100% rename from Code/will/django_labs/mysite/polls/admin.py rename to Code/will/django_labs/practice_labs/mysite/polls/admin.py diff --git a/Code/will/django_labs/mysite/polls/apps.py b/Code/will/django_labs/practice_labs/mysite/polls/apps.py similarity index 100% rename from Code/will/django_labs/mysite/polls/apps.py rename to Code/will/django_labs/practice_labs/mysite/polls/apps.py diff --git a/Code/will/django_labs/mysite/polls/migrations/0001_initial.py b/Code/will/django_labs/practice_labs/mysite/polls/migrations/0001_initial.py similarity index 100% rename from Code/will/django_labs/mysite/polls/migrations/0001_initial.py rename to Code/will/django_labs/practice_labs/mysite/polls/migrations/0001_initial.py diff --git a/Code/will/django_labs/practice_labs/mysite/polls/migrations/__init__.py b/Code/will/django_labs/practice_labs/mysite/polls/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/mysite/polls/models.py b/Code/will/django_labs/practice_labs/mysite/polls/models.py similarity index 100% rename from Code/will/django_labs/mysite/polls/models.py rename to Code/will/django_labs/practice_labs/mysite/polls/models.py diff --git a/Code/will/django_labs/practice_labs/mysite/polls/tests.py b/Code/will/django_labs/practice_labs/mysite/polls/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/practice_labs/mysite/polls/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/mysite/polls/urls.py b/Code/will/django_labs/practice_labs/mysite/polls/urls.py similarity index 100% rename from Code/will/django_labs/mysite/polls/urls.py rename to Code/will/django_labs/practice_labs/mysite/polls/urls.py diff --git a/Code/will/django_labs/mysite/polls/views.py b/Code/will/django_labs/practice_labs/mysite/polls/views.py similarity index 100% rename from Code/will/django_labs/mysite/polls/views.py rename to Code/will/django_labs/practice_labs/mysite/polls/views.py From b5f616ae5821f1b608dfa6bef22e8d1e04e530f6 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Thu, 31 Mar 2022 23:07:29 -0500 Subject: [PATCH 12/33] Small grocery app progress --- .../django_labs/grocery_list_proj/grocery_list_proj/urls.py | 2 +- Code/will/django_labs/grocery_list_proj/listapp/urls.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/will/django_labs/grocery_list_proj/grocery_list_proj/urls.py b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/urls.py index 791bf9af..719234e9 100644 --- a/Code/will/django_labs/grocery_list_proj/grocery_list_proj/urls.py +++ b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/urls.py @@ -18,5 +18,5 @@ urlpatterns = [ path('admin/', admin.site.urls), - path('index/'), include('listapp.urls') + path('index/', include('listapp.urls')) ] diff --git a/Code/will/django_labs/grocery_list_proj/listapp/urls.py b/Code/will/django_labs/grocery_list_proj/listapp/urls.py index a87ec761..6de1b6cd 100644 --- a/Code/will/django_labs/grocery_list_proj/listapp/urls.py +++ b/Code/will/django_labs/grocery_list_proj/listapp/urls.py @@ -1,7 +1,7 @@ from django.urls import path from . import views -app_name = 'listapp' + urlpatterns = [ path('', views.index, name='index') ] From 576f33823794db3dc49006cd8504cc311f4aa201 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Fri, 1 Apr 2022 23:05:11 -0500 Subject: [PATCH 13/33] Sessions Practice Lab --- .../practice_labs/sessions/manage.py | 22 +++ .../sessions/seshapp/__init__.py | 0 .../practice_labs/sessions/seshapp/admin.py | 3 + .../practice_labs/sessions/seshapp/apps.py | 6 + .../sessions/seshapp/migrations/__init__.py | 0 .../practice_labs/sessions/seshapp/models.py | 3 + .../seshapp/templates/seshapp/add.html | 18 +++ .../seshapp/templates/seshapp/index.html | 20 +++ .../practice_labs/sessions/seshapp/tests.py | 3 + .../practice_labs/sessions/seshapp/urls.py | 8 ++ .../practice_labs/sessions/seshapp/views.py | 35 +++++ .../sessions/sessions/__init__.py | 0 .../practice_labs/sessions/sessions/asgi.py | 16 +++ .../sessions/sessions/settings.py | 126 ++++++++++++++++++ .../practice_labs/sessions/sessions/urls.py | 22 +++ .../practice_labs/sessions/sessions/wsgi.py | 16 +++ 16 files changed, 298 insertions(+) create mode 100644 Code/will/django_labs/practice_labs/sessions/manage.py create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/__init__.py create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/admin.py create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/apps.py create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/migrations/__init__.py create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/models.py create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/templates/seshapp/add.html create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/templates/seshapp/index.html create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/tests.py create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/urls.py create mode 100644 Code/will/django_labs/practice_labs/sessions/seshapp/views.py create mode 100644 Code/will/django_labs/practice_labs/sessions/sessions/__init__.py create mode 100644 Code/will/django_labs/practice_labs/sessions/sessions/asgi.py create mode 100644 Code/will/django_labs/practice_labs/sessions/sessions/settings.py create mode 100644 Code/will/django_labs/practice_labs/sessions/sessions/urls.py create mode 100644 Code/will/django_labs/practice_labs/sessions/sessions/wsgi.py diff --git a/Code/will/django_labs/practice_labs/sessions/manage.py b/Code/will/django_labs/practice_labs/sessions/manage.py new file mode 100644 index 00000000..3b4a18bb --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/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', 'sessions.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/will/django_labs/practice_labs/sessions/seshapp/__init__.py b/Code/will/django_labs/practice_labs/sessions/seshapp/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/admin.py b/Code/will/django_labs/practice_labs/sessions/seshapp/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/seshapp/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/apps.py b/Code/will/django_labs/practice_labs/sessions/seshapp/apps.py new file mode 100644 index 00000000..de092c20 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/seshapp/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SeshappConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'seshapp' diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/migrations/__init__.py b/Code/will/django_labs/practice_labs/sessions/seshapp/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/models.py b/Code/will/django_labs/practice_labs/sessions/seshapp/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/seshapp/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/templates/seshapp/add.html b/Code/will/django_labs/practice_labs/sessions/seshapp/templates/seshapp/add.html new file mode 100644 index 00000000..bace3fc5 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/seshapp/templates/seshapp/add.html @@ -0,0 +1,18 @@ + + + + + + + Add A Task + + +

Add A Task

+ + {% csrf_token %} + {{form}} + + + View Tasks + + \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/templates/seshapp/index.html b/Code/will/django_labs/practice_labs/sessions/seshapp/templates/seshapp/index.html new file mode 100644 index 00000000..b63698c0 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/seshapp/templates/seshapp/index.html @@ -0,0 +1,20 @@ + + + + + + + Sessions + + + {% for task in tasks %} +
  • + {{task}} +
  • + + {%empty%} +
  • No tasks currently managed
  • + + {% endfor %} + + \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/tests.py b/Code/will/django_labs/practice_labs/sessions/seshapp/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/seshapp/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/urls.py b/Code/will/django_labs/practice_labs/sessions/seshapp/urls.py new file mode 100644 index 00000000..1a204ff8 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/seshapp/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from . import views + +app_name = 'tasks' +urlpatterns = [ + path('', views.index, name='index'), + path('add/', views.add, name='add') +] diff --git a/Code/will/django_labs/practice_labs/sessions/seshapp/views.py b/Code/will/django_labs/practice_labs/sessions/seshapp/views.py new file mode 100644 index 00000000..1a915f31 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/seshapp/views.py @@ -0,0 +1,35 @@ +from django.urls import reverse +from django.http import HttpResponse, HttpResponseRedirect +from django.shortcuts import render +from django import forms + +# Create your views here. + +tasks = [] + + +def index(request): + if 'tasks' not in request.session: + request.session['tasks'] = [] + + return render(request, 'seshapp/index.html', {'tasks': tasks}) + + +class NewTaskForm(forms.Form): + task = forms.CharField(label='New Task', max_length=200) + + +def add(request): + if request.method == 'POST': + form = NewTaskForm(request.POST) + if form.is_valid(): + task = form.cleaned_data['task'] + tasks.append(task) + return HttpResponseRedirect(reverse('tasks:index')) + else: + return render(request, 'seshapp/add.html', { + 'form': form + }) + return render(request, 'seshapp/add.html', { + 'form': NewTaskForm() + }) diff --git a/Code/will/django_labs/practice_labs/sessions/sessions/__init__.py b/Code/will/django_labs/practice_labs/sessions/sessions/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/sessions/sessions/asgi.py b/Code/will/django_labs/practice_labs/sessions/sessions/asgi.py new file mode 100644 index 00000000..03106f0e --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/sessions/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for sessions 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', 'sessions.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/practice_labs/sessions/sessions/settings.py b/Code/will/django_labs/practice_labs/sessions/sessions/settings.py new file mode 100644 index 00000000..09bf4de5 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/sessions/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for sessions 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-1qpt2j$zo1yd_+gtl9lews&+ndh#oh4l*g6s7p1#q80%w-ldp_' + +# 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 Apps + 'seshapp' +] + +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 = 'sessions.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 = 'sessions.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/Chicago' + +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/will/django_labs/practice_labs/sessions/sessions/urls.py b/Code/will/django_labs/practice_labs/sessions/sessions/urls.py new file mode 100644 index 00000000..494027d2 --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/sessions/urls.py @@ -0,0 +1,22 @@ +"""sessions 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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('sessions/', include('seshapp.urls')) +] diff --git a/Code/will/django_labs/practice_labs/sessions/sessions/wsgi.py b/Code/will/django_labs/practice_labs/sessions/sessions/wsgi.py new file mode 100644 index 00000000..eec6507a --- /dev/null +++ b/Code/will/django_labs/practice_labs/sessions/sessions/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for sessions 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', 'sessions.settings') + +application = get_wsgi_application() From 0bce7632ce968f9ea635dab1bd466cecb4b0e76a Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Wed, 6 Apr 2022 23:30:57 -0500 Subject: [PATCH 14/33] Twitter Practice Project --- .../practice_labs/twitter_proj/manage.py | 22 +++ .../twitter_proj/messages_app/__init__.py | 0 .../twitter_proj/messages_app/admin.py | 5 + .../twitter_proj/messages_app/apps.py | 6 + .../twitter_proj/messages_app/forms.py | 5 + .../messages_app/migrations/0001_initial.py | 28 ++++ .../messages_app/migrations/__init__.py | 0 .../twitter_proj/messages_app/models.py | 16 +++ .../templates/messages_app/index.html | 26 ++++ .../twitter_proj/messages_app/tests.py | 3 + .../twitter_proj/messages_app/urls.py | 7 + .../twitter_proj/messages_app/views.py | 25 ++++ .../twitter_proj/twitter_proj/__init__.py | 0 .../twitter_proj/twitter_proj/asgi.py | 16 +++ .../twitter_proj/twitter_proj/settings.py | 127 ++++++++++++++++++ .../twitter_proj/twitter_proj/urls.py | 23 ++++ .../twitter_proj/twitter_proj/wsgi.py | 16 +++ .../twitter_proj/users_app/__init__.py | 0 .../twitter_proj/users_app/admin.py | 3 + .../twitter_proj/users_app/apps.py | 6 + .../twitter_proj/users_app/forms.py | 16 +++ .../users_app/migrations/__init__.py | 0 .../twitter_proj/users_app/models.py | 3 + .../users_app/templates/users_app/login.html | 16 +++ .../templates/users_app/profile.html | 14 ++ .../users_app/templates/users_app/signup.html | 16 +++ .../twitter_proj/users_app/tests.py | 3 + .../twitter_proj/users_app/urls.py | 9 ++ .../twitter_proj/users_app/views.py | 53 ++++++++ 29 files changed, 464 insertions(+) create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/manage.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/__init__.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/admin.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/apps.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/forms.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/migrations/0001_initial.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/migrations/__init__.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/models.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/templates/messages_app/index.html create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/tests.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/urls.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/messages_app/views.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/__init__.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/asgi.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/settings.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/urls.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/wsgi.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/__init__.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/admin.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/apps.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/forms.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/migrations/__init__.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/models.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/login.html create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/profile.html create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/signup.html create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/tests.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/urls.py create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/users_app/views.py diff --git a/Code/will/django_labs/practice_labs/twitter_proj/manage.py b/Code/will/django_labs/practice_labs/twitter_proj/manage.py new file mode 100644 index 00000000..91206c78 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_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', 'twitter_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/will/django_labs/practice_labs/twitter_proj/messages_app/__init__.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/admin.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/admin.py new file mode 100644 index 00000000..bdfd93c7 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from .models import * + +# Register your models here. +admin.site.register(Tweet) diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/apps.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/apps.py new file mode 100644 index 00000000..e44dcdbc --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class MessagesAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'messages_app' diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/forms.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/forms.py new file mode 100644 index 00000000..73ff6be5 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/forms.py @@ -0,0 +1,5 @@ +from django import forms + + +class NewTweetForm(forms.Form): + text = forms.CharField(label='Tweet', max_length=120) diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/migrations/0001_initial.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/migrations/0001_initial.py new file mode 100644 index 00000000..296cf32b --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 4.0.3 on 2022-04-07 03:58 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Tweet', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=120)), + ('likes', models.IntegerField(default=1)), + ('dislikes', models.IntegerField(default=0)), + ('publish_date', models.DateTimeField(auto_now=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tweets', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/migrations/__init__.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/models.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/models.py new file mode 100644 index 00000000..66d8b573 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/models.py @@ -0,0 +1,16 @@ +from django.db import models +from django.contrib.auth.models import User + +# Create your models here. + + +class Tweet(models.Model): + text = models.CharField(max_length=120) + user = models.ForeignKey( + User, on_delete=models.CASCADE, related_name='tweets') + likes = models.IntegerField(default=1) + dislikes = models.IntegerField(default=0) + publish_date = models.DateTimeField(auto_now=True) + + def __str__(self): + return f'{self.user}: {self.text[:15]} {self.published_date.year}/{self.published_date.month}/{self.published_date.day}' diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/templates/messages_app/index.html b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/templates/messages_app/index.html new file mode 100644 index 00000000..236cd357 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/templates/messages_app/index.html @@ -0,0 +1,26 @@ + + + + + + + Welcome + + +

    Welcome 2 Twitter

    +
    + {% csrf_token %} + {{form}} + +
    + + {% for tweet in tweets %} +
    + {{tweet.text}} +
    {{tweet.user}}
    +

    Likes: {{tweet.likes}} Dislikes: {{tweet.dislikes}}

    +

    {{tweet.published.date}}

    +
    + {% endfor %} + + \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/tests.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/urls.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/urls.py new file mode 100644 index 00000000..19d0b214 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.index, name='index'), + path('new', views.new_tweet, name='new_tweet') +] diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/views.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/views.py new file mode 100644 index 00000000..8925c5e3 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/views.py @@ -0,0 +1,25 @@ +from django.shortcuts import render +from django.http import HttpResponseRedirect +from django.urls import reverse +from .forms import * +from .models import Tweet +# Create your views here. + + +def index(request): + tweets = Tweet.objects.all().order_by('-publish_date')[:20] + return render(request, 'messages_app/index.html', { + 'tweets': tweets, 'form': NewTweetForm() + }) + + +def new_tweet(request): + if request.method == 'POST': + form = NewTweetForm(request.POST) + if form.is_valid(): + tweet = Tweet() + tweet.user = request.user + tweet.text = forms.cleaned_data['text'] + tweet.save() + + return HttpResponseRedirect(reverse('index')) diff --git a/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/__init__.py b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/asgi.py b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/asgi.py new file mode 100644 index 00000000..2c01d7f1 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for twitter_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', 'twitter_proj.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/settings.py b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/settings.py new file mode 100644 index 00000000..f1622872 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/settings.py @@ -0,0 +1,127 @@ +""" +Django settings for twitter_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-%^pm(gx&+68sfsn-+rthnx7k(0dy9eb%e%*8x8^n1n_!u!n78u' + +# 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 Applications + 'users_app', + 'messages_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 = 'twitter_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 = 'twitter_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/Chicago' + +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/will/django_labs/practice_labs/twitter_proj/twitter_proj/urls.py b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/urls.py new file mode 100644 index 00000000..d0912696 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/urls.py @@ -0,0 +1,23 @@ +"""twitter_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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('users/', include('users_app.urls')), + path('', include('messages_app.urls')) +] diff --git a/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/wsgi.py b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/wsgi.py new file mode 100644 index 00000000..242d53ea --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/twitter_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for twitter_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', 'twitter_proj.settings') + +application = get_wsgi_application() diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/__init__.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/admin.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/apps.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/apps.py new file mode 100644 index 00000000..7200dd57 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class UsersAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'users_app' diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/forms.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/forms.py new file mode 100644 index 00000000..2b19481f --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/forms.py @@ -0,0 +1,16 @@ +from django import forms + + +class NewSignupForm(forms.Form): + username = forms.CharField(label='Username', max_length=20) + password = forms.CharField( + widget=forms.PasswordInput, label='Password', max_length=10) + first_name = forms.CharField(label='First Name', max_length=20) + last_name = forms.CharField(label='Last Name', max_length=20) + email = forms.EmailField(label='Email') + + +class NewLoginForm(forms.Form): + username = forms.CharField(label='Username', max_length=20) + password = forms.CharField( + widget=forms.PasswordInput, label='Password', max_length=10) diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/migrations/__init__.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/models.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/login.html b/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/login.html new file mode 100644 index 00000000..09ea283d --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/login.html @@ -0,0 +1,16 @@ + + + + + + + Login + + +
    + {% csrf_token %} + {{form}} + +
    + + \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/profile.html b/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/profile.html new file mode 100644 index 00000000..3940eecd --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/profile.html @@ -0,0 +1,14 @@ + + + + + + + {{request.user}}'s Profile + + +

    Welcome {{request.user}}

    + + Logout + + \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/signup.html b/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/signup.html new file mode 100644 index 00000000..cd2a0dd9 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/templates/users_app/signup.html @@ -0,0 +1,16 @@ + + + + + + + Sign Up + + +
    + {% csrf_token %} + {{form}} + +
    + + \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/tests.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/urls.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/urls.py new file mode 100644 index 00000000..2ad39f8b --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('signup/', views.signup, name='signup'), + path('login/', views.user_login, name='login'), + path('profile/', views.profile, name='profile'), + path('logout/', views.user_logout, name='logout') +] diff --git a/Code/will/django_labs/practice_labs/twitter_proj/users_app/views.py b/Code/will/django_labs/practice_labs/twitter_proj/users_app/views.py new file mode 100644 index 00000000..7e2b866b --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/users_app/views.py @@ -0,0 +1,53 @@ +from django.http import HttpResponseRedirect +from django.shortcuts import render +from .forms import * +from django.contrib.auth.models import User +from django.urls import reverse +from django.contrib.auth import authenticate, login, logout +# Create your views here. + + +def signup(request): + if request.method == 'GET': + form = NewSignupForm() + return render(request, 'users_app/signup.html', {'form': form}) + + elif request.method == 'POST': + form = NewSignupForm(request.POST) + if form.is_valid(): + # create a new user + user = User.objects.create_user( + username=form.cleaned_data['username'], + first_name=form.cleaned_data['first_name'], + last_name=form.cleaned_data['last_name'], + email=form.cleaned_data['email'], + password=form.cleaned_data['password'] + ) + return HttpResponseRedirect(reverse('signup')) + + +def user_login(request): + if request.method == 'GET': + return render(request, 'users_app/login.html', {'form': NewLoginForm()}) + + elif request.method == 'POST': + form = NewLoginForm(request.POST) + if form.is_valid(): + password = form.cleaned_data['password'] + user = authenticate( + request, username=form.cleaned_data['username'], password=password) + if user is not None: + login(request, user) + return HttpResponseRedirect(reverse('profile')) + else: + form.add_error('username', 'Invalid username or password') + return render(request, 'users_app/login.html', {'form': form}) + + +def profile(request): + return render(request, 'users_app/profile.html') + + +def user_logout(request): + logout(request) + return HttpResponseRedirect(reverse('login')) From cbb182138b756b04881ade26e63665d11f39419e Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Thu, 7 Apr 2022 22:38:52 -0500 Subject: [PATCH 15/33] Todo lab progress --- Code/will/django_labs/todo_proj/manage.py | 22 +++ .../todo_proj/todo_app/__init__.py | 0 .../django_labs/todo_proj/todo_app/admin.py | 3 + .../django_labs/todo_proj/todo_app/apps.py | 6 + .../django_labs/todo_proj/todo_app/forms.py | 7 + .../todo_proj/todo_app/migrations/__init__.py | 0 .../django_labs/todo_proj/todo_app/models.py | 18 +++ .../todo_app/templates/todo_app/index.html | 12 ++ .../todo_app/templates/todo_app/save.html | 12 ++ .../django_labs/todo_proj/todo_app/tests.py | 3 + .../django_labs/todo_proj/todo_app/urls.py | 7 + .../django_labs/todo_proj/todo_app/views.py | 14 ++ .../todo_proj/todo_proj/__init__.py | 0 .../django_labs/todo_proj/todo_proj/asgi.py | 16 +++ .../todo_proj/todo_proj/settings.py | 126 ++++++++++++++++++ .../django_labs/todo_proj/todo_proj/urls.py | 22 +++ .../django_labs/todo_proj/todo_proj/wsgi.py | 16 +++ 17 files changed, 284 insertions(+) create mode 100644 Code/will/django_labs/todo_proj/manage.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/__init__.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/admin.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/apps.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/forms.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/migrations/__init__.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/models.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html create mode 100644 Code/will/django_labs/todo_proj/todo_app/templates/todo_app/save.html create mode 100644 Code/will/django_labs/todo_proj/todo_app/tests.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/urls.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/views.py create mode 100644 Code/will/django_labs/todo_proj/todo_proj/__init__.py create mode 100644 Code/will/django_labs/todo_proj/todo_proj/asgi.py create mode 100644 Code/will/django_labs/todo_proj/todo_proj/settings.py create mode 100644 Code/will/django_labs/todo_proj/todo_proj/urls.py create mode 100644 Code/will/django_labs/todo_proj/todo_proj/wsgi.py diff --git a/Code/will/django_labs/todo_proj/manage.py b/Code/will/django_labs/todo_proj/manage.py new file mode 100644 index 00000000..6be564d2 --- /dev/null +++ b/Code/will/django_labs/todo_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', 'todo_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/will/django_labs/todo_proj/todo_app/__init__.py b/Code/will/django_labs/todo_proj/todo_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/todo_proj/todo_app/admin.py b/Code/will/django_labs/todo_proj/todo_app/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Code/will/django_labs/todo_proj/todo_app/apps.py b/Code/will/django_labs/todo_proj/todo_app/apps.py new file mode 100644 index 00000000..d8f1498d --- /dev/null +++ b/Code/will/django_labs/todo_proj/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/will/django_labs/todo_proj/todo_app/forms.py b/Code/will/django_labs/todo_proj/todo_app/forms.py new file mode 100644 index 00000000..ae6d57f2 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/forms.py @@ -0,0 +1,7 @@ +from django import forms +from django_labs.todo_proj.todo_app.models import Priority + + +class NewTodoForm(forms.Form): + text = forms.CharField(label='todo', max_length=120) + priority = Priority() diff --git a/Code/will/django_labs/todo_proj/todo_app/migrations/__init__.py b/Code/will/django_labs/todo_proj/todo_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/todo_proj/todo_app/models.py b/Code/will/django_labs/todo_proj/todo_app/models.py new file mode 100644 index 00000000..49cb4aa8 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/models.py @@ -0,0 +1,18 @@ +from django.db import models + +# Create your models here. +priority_choices = (('high', 'HIGH'), ('medium', 'MEDIUM'), ('low', 'LOW')) + + +class Priority(models.Model): + + name = models.CharField( + max_length=6, choices=priority_choices, defaul='low') + + +class TodoItem(models.Model): + + text = models.CharField(max_length=120, label='todo item') + priority = models.ForeignKey( + Priority, on_delete=models.CASCADE, related_name='priority') + created_date = models.DateTimeField(auto_now=True) diff --git a/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html new file mode 100644 index 00000000..8d1a5507 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html @@ -0,0 +1,12 @@ + + + + + + + Home + + + Yo + + \ No newline at end of file diff --git a/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/save.html b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/save.html new file mode 100644 index 00000000..7386229f --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/save.html @@ -0,0 +1,12 @@ + + + + + + + Add New Item + + + save todo item + + \ No newline at end of file diff --git a/Code/will/django_labs/todo_proj/todo_app/tests.py b/Code/will/django_labs/todo_proj/todo_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/todo_proj/todo_app/urls.py b/Code/will/django_labs/todo_proj/todo_app/urls.py new file mode 100644 index 00000000..1fe48f40 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.index, name='index'), + path('save/', views.save_task, name='save') +] diff --git a/Code/will/django_labs/todo_proj/todo_app/views.py b/Code/will/django_labs/todo_proj/todo_app/views.py new file mode 100644 index 00000000..123602d6 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/views.py @@ -0,0 +1,14 @@ +from django.shortcuts import render +from .forms import * +from .models import Priority +from django.http import HttpResponseRedirect +from django.urls import reverse +# Create your views here. + + +def index(request): + return render(request, 'todo_app/index.html') + + +def save_task(request): + return render(request, 'todo_app/save.html') diff --git a/Code/will/django_labs/todo_proj/todo_proj/__init__.py b/Code/will/django_labs/todo_proj/todo_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/todo_proj/todo_proj/asgi.py b/Code/will/django_labs/todo_proj/todo_proj/asgi.py new file mode 100644 index 00000000..5a0fd4de --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_proj/asgi.py @@ -0,0 +1,16 @@ +""" +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/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_proj.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/todo_proj/todo_proj/settings.py b/Code/will/django_labs/todo_proj/todo_proj/settings.py new file mode 100644 index 00000000..a2ad5dcd --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_proj/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for todo_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-jedro#eh5d+4(ojiwmn%y8f@-en!0+fku1l=rk)i6gie)2ch72' + +# 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 apps + '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/Chicago' + +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/will/django_labs/todo_proj/todo_proj/urls.py b/Code/will/django_labs/todo_proj/todo_proj/urls.py new file mode 100644 index 00000000..02fb6069 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_proj/urls.py @@ -0,0 +1,22 @@ +"""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/ +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('index/', include('todo_app.urls')) +] diff --git a/Code/will/django_labs/todo_proj/todo_proj/wsgi.py b/Code/will/django_labs/todo_proj/todo_proj/wsgi.py new file mode 100644 index 00000000..5f96a37b --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +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/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_proj.settings') + +application = get_wsgi_application() From bdec03789bd6f8401c3574651d675f6a22abd97f Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Fri, 8 Apr 2022 22:39:15 -0500 Subject: [PATCH 16/33] Todo App Progress --- .../django_labs/todo_proj/todo_app/forms.py | 7 +++-- .../todo_app/migrations/0001_initial.py | 31 +++++++++++++++++++ .../django_labs/todo_proj/todo_app/models.py | 12 +++---- .../todo_app/templates/todo_app/index.html | 15 ++++++++- .../todo_app/templates/todo_app/save.html | 12 ------- .../django_labs/todo_proj/todo_app/urls.py | 2 +- .../django_labs/todo_proj/todo_app/views.py | 20 ++++++++++-- 7 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 Code/will/django_labs/todo_proj/todo_app/migrations/0001_initial.py delete mode 100644 Code/will/django_labs/todo_proj/todo_app/templates/todo_app/save.html diff --git a/Code/will/django_labs/todo_proj/todo_app/forms.py b/Code/will/django_labs/todo_proj/todo_app/forms.py index ae6d57f2..05b01b7d 100644 --- a/Code/will/django_labs/todo_proj/todo_app/forms.py +++ b/Code/will/django_labs/todo_proj/todo_app/forms.py @@ -1,7 +1,8 @@ from django import forms -from django_labs.todo_proj.todo_app.models import Priority + +priority_choices = (('high', 'High'), ('medium', 'Medium'), ('low', 'Low')) class NewTodoForm(forms.Form): - text = forms.CharField(label='todo', max_length=120) - priority = Priority() + text = forms.CharField(max_length=120) + priority = forms.ChoiceField(choices=priority_choices) diff --git a/Code/will/django_labs/todo_proj/todo_app/migrations/0001_initial.py b/Code/will/django_labs/todo_proj/todo_app/migrations/0001_initial.py new file mode 100644 index 00000000..20dfa0e5 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/migrations/0001_initial.py @@ -0,0 +1,31 @@ +# Generated by Django 4.0.3 on 2022-04-09 03:12 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Priority', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(choices=[('high', 'HIGH'), ('medium', 'MEDIUM'), ('low', 'LOW')], default='low', max_length=6)), + ], + ), + migrations.CreateModel( + name='TodoItem', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=120)), + ('created_date', models.DateTimeField(auto_now=True)), + ('priority', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tasks', to='todo_app.priority')), + ], + ), + ] diff --git a/Code/will/django_labs/todo_proj/todo_app/models.py b/Code/will/django_labs/todo_proj/todo_app/models.py index 49cb4aa8..68d2ffed 100644 --- a/Code/will/django_labs/todo_proj/todo_app/models.py +++ b/Code/will/django_labs/todo_proj/todo_app/models.py @@ -1,18 +1,18 @@ from django.db import models - # Create your models here. -priority_choices = (('high', 'HIGH'), ('medium', 'MEDIUM'), ('low', 'LOW')) class Priority(models.Model): name = models.CharField( - max_length=6, choices=priority_choices, defaul='low') + max_length=6, choices=(('high', 'High'), ('medium', 'Medium'), ('low', 'Low')), default='low') class TodoItem(models.Model): - - text = models.CharField(max_length=120, label='todo item') + text = models.CharField(max_length=120) priority = models.ForeignKey( - Priority, on_delete=models.CASCADE, related_name='priority') + Priority, on_delete=models.CASCADE) created_date = models.DateTimeField(auto_now=True) + + def __str__(self): + return f'{self.text} {self.priority} {self.created_date.day}' diff --git a/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html index 8d1a5507..0eb12a95 100644 --- a/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html +++ b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html @@ -7,6 +7,19 @@ Home - Yo + +
    + {% csrf_token %} + {{form}} + +
    + + +

    To Do List:

    + {% for task in tasks %} +
    +
    {{task.text}} {{task.priority}}
    +
    + {% endfor %} \ No newline at end of file diff --git a/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/save.html b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/save.html deleted file mode 100644 index 7386229f..00000000 --- a/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/save.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Add New Item - - - save todo item - - \ No newline at end of file diff --git a/Code/will/django_labs/todo_proj/todo_app/urls.py b/Code/will/django_labs/todo_proj/todo_app/urls.py index 1fe48f40..0ecd6851 100644 --- a/Code/will/django_labs/todo_proj/todo_app/urls.py +++ b/Code/will/django_labs/todo_proj/todo_app/urls.py @@ -3,5 +3,5 @@ urlpatterns = [ path('', views.index, name='index'), - path('save/', views.save_task, name='save') + path('save', views.save_task, name='save_task') ] diff --git a/Code/will/django_labs/todo_proj/todo_app/views.py b/Code/will/django_labs/todo_proj/todo_app/views.py index 123602d6..540637ea 100644 --- a/Code/will/django_labs/todo_proj/todo_app/views.py +++ b/Code/will/django_labs/todo_proj/todo_app/views.py @@ -1,14 +1,28 @@ from django.shortcuts import render from .forms import * -from .models import Priority +from .models import TodoItem from django.http import HttpResponseRedirect from django.urls import reverse # Create your views here. +tasks = [ + +] + def index(request): - return render(request, 'todo_app/index.html') + tasks = TodoItem.objects.all().order_by('-created_date') + return render(request, 'todo_app/index.html', { + 'tasks': tasks, 'form': NewTodoForm() + }) def save_task(request): - return render(request, 'todo_app/save.html') + form = NewTodoForm(request.POST) + if request.method == 'POST' and form.is_valid(): + tasks = TodoItem() + tasks.text = forms.cleaned_data['text'] + tasks.priority = forms.cleaned_data['priority'] + tasks.save() + + return HttpResponseRedirect(reverse('index')) From fa46967ee8a174863b80f0bee42b982892aafc8a Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Mon, 11 Apr 2022 22:52:39 -0500 Subject: [PATCH 17/33] twitter practice lab updates --- Code/will/django_labs/django_redo/.gitignore | Bin 0 -> 14 bytes .../django_labs/grocery_list_proj/.gitignore | 1 + .../practice_labs/twitter_proj/.gitignore | 1 + .../templates/messages_app/index.html | 18 ++++++++++++++---- .../twitter_proj/messages_app/urls.py | 3 ++- .../twitter_proj/messages_app/views.py | 10 ++++++++++ 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 Code/will/django_labs/django_redo/.gitignore create mode 100644 Code/will/django_labs/grocery_list_proj/.gitignore create mode 100644 Code/will/django_labs/practice_labs/twitter_proj/.gitignore diff --git a/Code/will/django_labs/django_redo/.gitignore b/Code/will/django_labs/django_redo/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5e49e1af0ecd54f40c12e6b2c0c11eb722ce63c1 GIT binary patch literal 14 VcmezWPmdv$A&;SqftP`c0RSg_1B?Iw literal 0 HcmV?d00001 diff --git a/Code/will/django_labs/grocery_list_proj/.gitignore b/Code/will/django_labs/grocery_list_proj/.gitignore new file mode 100644 index 00000000..2eea525d --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/twitter_proj/.gitignore b/Code/will/django_labs/practice_labs/twitter_proj/.gitignore new file mode 100644 index 00000000..2eea525d --- /dev/null +++ b/Code/will/django_labs/practice_labs/twitter_proj/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/templates/messages_app/index.html b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/templates/messages_app/index.html index 236cd357..9ee2b642 100644 --- a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/templates/messages_app/index.html +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/templates/messages_app/index.html @@ -8,18 +8,28 @@

    Welcome 2 Twitter

    + {% if not request.user.is_anonymous %}
    {% csrf_token %} {{form}}
    + {% endif %} + {% for tweet in tweets %}
    - {{tweet.text}} -
    {{tweet.user}}
    -

    Likes: {{tweet.likes}} Dislikes: {{tweet.dislikes}}

    -

    {{tweet.published.date}}

    +

    {{tweet.text}}

    + + {% if request.user == tweet.user %} + X + {% endif %} + + +
    {{tweet.user}}
    + +

    Likes: {{tweet.likes}} Dislikes: {{tweet.dislikes}}

    +

    {{tweet.published.date}}

    {% endfor %} diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/urls.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/urls.py index 19d0b214..248f45bd 100644 --- a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/urls.py +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/urls.py @@ -3,5 +3,6 @@ urlpatterns = [ path('', views.index, name='index'), - path('new', views.new_tweet, name='new_tweet') + path('new', views.new_tweet, name='new_tweet'), + path('delete/', views.delete_tweet, name='delete_tweet') ] diff --git a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/views.py b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/views.py index 8925c5e3..85d6140d 100644 --- a/Code/will/django_labs/practice_labs/twitter_proj/messages_app/views.py +++ b/Code/will/django_labs/practice_labs/twitter_proj/messages_app/views.py @@ -3,6 +3,8 @@ from django.urls import reverse from .forms import * from .models import Tweet +from django.contrib.auth.decorators import login_required +from messages_app.forms import NewTweetForm # Create your views here. @@ -13,6 +15,7 @@ def index(request): }) +@login_required def new_tweet(request): if request.method == 'POST': form = NewTweetForm(request.POST) @@ -23,3 +26,10 @@ def new_tweet(request): tweet.save() return HttpResponseRedirect(reverse('index')) + + +@login_required +def delete_tweet(request, tweet_id): + tweet = Tweet.objects.get(id=tweet_id, user=request.user) + tweet.delete() + return HttpResponseRedirect(reverse('index')) From 82e3c3faab57400109a03c28017bf2dca25d2d52 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Tue, 12 Apr 2022 23:03:26 -0500 Subject: [PATCH 18/33] Grocery List proj and adding gitignore to projects --- .../django_redo/django_redo/settings.py | 4 +- .../grocery_list_proj/settings.py | 5 +- .../grocery_list_proj/listapp/admin.py | 3 + .../listapp/migrations/0001_initial.py | 31 +++++ .../grocery_list_proj/listapp/models.py | 15 ++- .../listapp/templates/listapp/index.html | 37 ++++- .../grocery_list_proj/listapp/urls.py | 6 +- .../grocery_list_proj/listapp/views.py | 39 +++++- .../grocery_list_proj/requirements.txt | Bin 0 -> 1232 bytes .../practice_labs/is_it_xmas/.gitignore | 1 + .../is_it_xmas/is_it_xmas/settings.py | 3 +- .../practice_labs/models_notes/manage.py | 22 --- .../models_notes/model_proj/manage.py | 22 --- .../model_proj/model_app/__init__.py | 0 .../model_proj/model_app/admin.py | 4 - .../models_notes/model_proj/model_app/apps.py | 6 - .../model_app/migrations/__init__.py | 0 .../model_proj/model_app/models.py | 11 -- .../model_proj/model_app/tests.py | 3 - .../model_proj/model_app/views.py | 3 - .../model_proj/model_proj/__init__.py | 0 .../model_proj/model_proj/asgi.py | 16 --- .../model_proj/model_proj/settings.py | 126 ------------------ .../model_proj/model_proj/urls.py | 21 --- .../model_proj/model_proj/wsgi.py | 16 --- .../practice_labs/mysite/.gitignore | 1 + .../practice_labs/mysite/mysite/settings.py | 5 +- .../practice_labs/project_1/.gitignore | 1 + .../project_1/kiwi_first_proj/settings.py | 5 +- .../practice_labs/sessions/.gitignore | 1 + .../sessions/sessions/settings.py | 4 +- .../twitter_proj/twitter_proj/settings.py | 3 +- Code/will/django_labs/todo_proj/.gitignore | 1 + .../todo_proj/todo_proj/settings.py | 4 +- 34 files changed, 146 insertions(+), 273 deletions(-) create mode 100644 Code/will/django_labs/grocery_list_proj/listapp/migrations/0001_initial.py create mode 100644 Code/will/django_labs/grocery_list_proj/requirements.txt create mode 100644 Code/will/django_labs/practice_labs/is_it_xmas/.gitignore delete mode 100644 Code/will/django_labs/practice_labs/models_notes/manage.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/manage.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/__init__.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/admin.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/apps.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/migrations/__init__.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/models.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/tests.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_app/views.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/__init__.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/asgi.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/settings.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/urls.py delete mode 100644 Code/will/django_labs/practice_labs/models_notes/model_proj/model_proj/wsgi.py create mode 100644 Code/will/django_labs/practice_labs/mysite/.gitignore create mode 100644 Code/will/django_labs/practice_labs/project_1/.gitignore create mode 100644 Code/will/django_labs/practice_labs/sessions/.gitignore create mode 100644 Code/will/django_labs/todo_proj/.gitignore diff --git a/Code/will/django_labs/django_redo/django_redo/settings.py b/Code/will/django_labs/django_redo/django_redo/settings.py index b2a5b51b..ca28045f 100644 --- a/Code/will/django_labs/django_redo/django_redo/settings.py +++ b/Code/will/django_labs/django_redo/django_redo/settings.py @@ -10,6 +10,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/ """ +from decouple import config from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -19,8 +20,7 @@ # 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-o-9qg%z2u@vvr&jwz0g&kufuqd&wa0_c-05^&k(^p_2yuqxemk' +SECRET_KEY = config("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True diff --git a/Code/will/django_labs/grocery_list_proj/grocery_list_proj/settings.py b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/settings.py index 0ba4bfa9..d48ff619 100644 --- a/Code/will/django_labs/grocery_list_proj/grocery_list_proj/settings.py +++ b/Code/will/django_labs/grocery_list_proj/grocery_list_proj/settings.py @@ -10,6 +10,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/ """ +from decouple import config from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -19,8 +20,8 @@ # 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-sd_z@k=-hwfug#20+4amj&a8c=gbq@c(8s#6lty@0w*y56&nw2' + +SECRET_KEY = config("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True diff --git a/Code/will/django_labs/grocery_list_proj/listapp/admin.py b/Code/will/django_labs/grocery_list_proj/listapp/admin.py index 8c38f3f3..95b665dd 100644 --- a/Code/will/django_labs/grocery_list_proj/listapp/admin.py +++ b/Code/will/django_labs/grocery_list_proj/listapp/admin.py @@ -1,3 +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/will/django_labs/grocery_list_proj/listapp/migrations/0001_initial.py b/Code/will/django_labs/grocery_list_proj/listapp/migrations/0001_initial.py new file mode 100644 index 00000000..1933114b --- /dev/null +++ b/Code/will/django_labs/grocery_list_proj/listapp/migrations/0001_initial.py @@ -0,0 +1,31 @@ +# Generated by Django 4.0.3 on 2022-04-13 01:31 + +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='listapp.department')), + ], + ), + ] diff --git a/Code/will/django_labs/grocery_list_proj/listapp/models.py b/Code/will/django_labs/grocery_list_proj/listapp/models.py index 6e7db86a..c259a2ff 100644 --- a/Code/will/django_labs/grocery_list_proj/listapp/models.py +++ b/Code/will/django_labs/grocery_list_proj/listapp/models.py @@ -3,7 +3,18 @@ # Create your models here. -class GroceryItem(models.Model): - item_descrip = models.CharField(max_length=200) +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} ' # item -- completion status diff --git a/Code/will/django_labs/grocery_list_proj/listapp/templates/listapp/index.html b/Code/will/django_labs/grocery_list_proj/listapp/templates/listapp/index.html index fbaf39d3..b181739b 100644 --- a/Code/will/django_labs/grocery_list_proj/listapp/templates/listapp/index.html +++ b/Code/will/django_labs/grocery_list_proj/listapp/templates/listapp/index.html @@ -4,9 +4,42 @@ - stuff + Grocery - words +

    My Grocery List

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

    {{department.name}}

    + +
    + {% endfor %} +
    + \ No newline at end of file diff --git a/Code/will/django_labs/grocery_list_proj/listapp/urls.py b/Code/will/django_labs/grocery_list_proj/listapp/urls.py index 6de1b6cd..888a5dfd 100644 --- a/Code/will/django_labs/grocery_list_proj/listapp/urls.py +++ b/Code/will/django_labs/grocery_list_proj/listapp/urls.py @@ -1,7 +1,11 @@ from django.urls import path from . import views +app_name = 'listapp' urlpatterns = [ - path('', views.index, name='index') + path('', views.index, name='index'), + path('add_items', views.add_item, name='add'), + path('buy//', views.buy_item, name='buy'), + path('delete/', views.delete_item, name='delete') ] diff --git a/Code/will/django_labs/grocery_list_proj/listapp/views.py b/Code/will/django_labs/grocery_list_proj/listapp/views.py index 1aae48f4..2b0be30b 100644 --- a/Code/will/django_labs/grocery_list_proj/listapp/views.py +++ b/Code/will/django_labs/grocery_list_proj/listapp/views.py @@ -1,8 +1,41 @@ from django.shortcuts import render -from django.http import HttpResponse - +from . import models +from django.http import HttpResponseRedirect +from django.urls import reverse # Create your views here. def index(request): - return render(request, 'listapp/index.html') + grocery_list = models.GroceryItem.objects.all().order_by('department') + departments = models.Department.objects.all().order_by('name') + + return render(request, 'listapp/index.html', { + 'grocery_list': grocery_list, + 'departments': departments + }) + + +def add_item(request): + item_text = request.POST['item'] + department_id = request.POST['department'] + new_item = models.GroceryItem() + new_item.item = item_text + if department_id: + department = models.Department.objects.get(id=department_id) + new_item.department = department + new_item.save() + + return HttpResponseRedirect(reverse('listapp:index')) + + +def buy_item(request, item_id): + grocery_item = models.GroceryItem.objects.get(id=item_id) + grocery_item.completed = not grocery_item.completed + grocery_item.save() + return HttpResponseRedirect(reverse('listapp:index')) + + +def delete_item(request, item_id): + grocery_item = models.GroceryItem.objects.get(id=item_id) + grocery_item.delete() + return HttpResponseRedirect(reverse('listapp:index')) diff --git a/Code/will/django_labs/grocery_list_proj/requirements.txt b/Code/will/django_labs/grocery_list_proj/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..07091272eca0a10e2bbe27e104ac545b94c58b7f GIT binary patch literal 1232 zcmZuwOHYGf5ZtqgKc$V(YJ2f!JeYX$;2G&dlmhao)*r9V>;PYz8bZ>tJF_$U`29(& zv8`oR+uAmEi)Ut2yT*HEmv&)^wN}~=8L53DE5rXaFwBgQH9yI0k)c?87VVs=0=ly0 zh`$-}DIzs;GU&)W9z%n8BK(>HMMbH-LKW+*kv*{j`f4alEC=q}S*R{{<|%ZwmXRj2$vo~N1^s@A*`oauqrlTCnSYuE? zY;b>%7-u1MgLa`aTY))oUZRGth5IQHBmdUpoQYo6<+K{0rHuV8t;3h0KOyr0xrKX( z$2xLIo<}g$(AHsgPx!romvfE^5xPr!qu2}Ou!=NS?y?15Gh+FE8PUa^#)hjro Date: Wed, 13 Apr 2022 23:03:04 -0500 Subject: [PATCH 19/33] Phonebook app practice --- .../practice_labs/phonebook_proj/.gitignore | 1 + .../phonebook_proj/contactsapp/__init__.py | 0 .../phonebook_proj/contactsapp/admin.py | 5 + .../phonebook_proj/contactsapp/apps.py | 6 + .../contactsapp/migrations/0001_initial.py | 26 ++++ .../contactsapp/migrations/__init__.py | 0 .../phonebook_proj/contactsapp/models.py | 32 +++++ .../templates/contactsapp/all_contacts.html | 30 +++++ .../templates/contactsapp/index.html | 18 +++ .../phonebook_proj/contactsapp/tests.py | 3 + .../phonebook_proj/contactsapp/urls.py | 11 ++ .../phonebook_proj/contactsapp/views.py | 50 +++++++ .../practice_labs/phonebook_proj/manage.py | 22 +++ .../phonebook_proj/phonebook_proj/__init__.py | 0 .../phonebook_proj/phonebook_proj/asgi.py | 16 +++ .../phonebook_proj/phonebook_proj/settings.py | 126 ++++++++++++++++++ .../phonebook_proj/phonebook_proj/urls.py | 22 +++ .../phonebook_proj/phonebook_proj/wsgi.py | 16 +++ 18 files changed, 384 insertions(+) create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/.gitignore create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/__init__.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/admin.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/apps.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/migrations/0001_initial.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/migrations/__init__.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/models.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/templates/contactsapp/all_contacts.html create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/templates/contactsapp/index.html create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/tests.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/urls.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/views.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/manage.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/__init__.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/asgi.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/settings.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/urls.py create mode 100644 Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/wsgi.py diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/.gitignore b/Code/will/django_labs/practice_labs/phonebook_proj/.gitignore new file mode 100644 index 00000000..2eea525d --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/__init__.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/admin.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/admin.py new file mode 100644 index 00000000..5913a1bc --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from .models import * + +# Register your models here. +admin.site.register(Contact) diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/apps.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/apps.py new file mode 100644 index 00000000..489746a5 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ContactsappConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'contactsapp' diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/migrations/0001_initial.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/migrations/0001_initial.py new file mode 100644 index 00000000..a5fa53ae --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 4.0.3 on 2022-04-14 01:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Contact', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=50)), + ('last_name', models.CharField(blank=True, max_length=50, null=True)), + ('phone_number', models.CharField(max_length=15)), + ('email', models.EmailField(blank=True, max_length=254, null=True)), + ('address', models.CharField(blank=True, max_length=150, null=True)), + ('is_cool', models.BooleanField(default=False)), + ], + ), + ] diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/migrations/__init__.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/models.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/models.py new file mode 100644 index 00000000..4ed95a65 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/models.py @@ -0,0 +1,32 @@ +from django.db import models + +# Create your models here. + + +class Contact(models.Model): + first_name = models.CharField(max_length=50) + last_name = models.CharField(max_length=50, null=True, blank=True) + phone_number = models.CharField(max_length=15) + email = models.EmailField(null=True, blank=True) + address = models.CharField(max_length=150, null=True, blank=True) + is_cool = models.BooleanField(default=False) + + def __str__(self): + return f'{self.first_name} {self.last_name}' + + def full_name(self): + if self.last_name: + return f'{self.first_name} {self.last_name}' + + else: + return f'{self.first_name}' + + def coolness(self): + if self.is_cool: + return 'cool' + + else: + return 'not cool' + + def __str__(self): + return f'{self.full_name()} -- {self.coolness()}' diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/templates/contactsapp/all_contacts.html b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/templates/contactsapp/all_contacts.html new file mode 100644 index 00000000..a4442ac1 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/templates/contactsapp/all_contacts.html @@ -0,0 +1,30 @@ + + + + + + + Contacts + + +

    All Contacts

    + +
    + {% csrf_token %} + + + + + + + + +
    + + {% for contact in contacts %} +
    {{contact.full_name}} is {{contact.coolness}}
    + {% endfor %} + + \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/templates/contactsapp/index.html b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/templates/contactsapp/index.html new file mode 100644 index 00000000..fbc4a7f6 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/templates/contactsapp/index.html @@ -0,0 +1,18 @@ + + + + + + + Home + + +

    Welcome to the Contacts App

    +
    + {% csrf_token %} + + +
    + + + \ No newline at end of file diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/tests.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/urls.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/urls.py new file mode 100644 index 00000000..ca8c7e1a --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/urls.py @@ -0,0 +1,11 @@ +from django.urls import path +from . import views + +app_name = 'contactsapp' + +urlpatterns = [ + path('', views.home_page, name='home'), + path('all/', views.all_contacts, name='all_contacts'), + path('save_contact/', views.save_contact, name='save_contact'), + path('search/', views.search_contact, name='search_contact') +] diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/views.py b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/views.py new file mode 100644 index 00000000..be0171a4 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/contactsapp/views.py @@ -0,0 +1,50 @@ +from django.shortcuts import render +from .models import * +from django.http import HttpResponse, HttpResponseRedirect +from django.urls import reverse +# Create your views here. + + +def home_page(request): + return render(request, 'contactsapp/index.html') + + +def all_contacts(request): + contacts = Contact.objects.all() + + contact = { + 'contacts': contacts + } + return render(request, 'contactsapp/all_contacts.html', contact) + + +def save_contact(request): + contact = Contact() + form = request.POST + + if request.POST: + + contact.first_name = form['first_name'] + contact.last_name = form['last_name'] + contact.phone_number = form['phone_number'] + contact.email = form['email'] + contact.address = form['address'] + if form.get('is_cool') == 'on': + contact.is_cool = True + else: + contact.is_cool = False + + contact.save() + + return HttpResponseRedirect(reverse('contactsapp:all_contacts')) + + +def search_contact(request): + name = request.POST['first_name'] + if name: + contact = Contact.objects.filter(first_name=name) + + else: + contact = '' + + return HttpResponse(contact) diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/manage.py b/Code/will/django_labs/practice_labs/phonebook_proj/manage.py new file mode 100644 index 00000000..75f0d8b9 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_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', 'phonebook_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/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/__init__.py b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/asgi.py b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/asgi.py new file mode 100644 index 00000000..9226ab4b --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for phonebook_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', 'phonebook_proj.settings') + +application = get_asgi_application() diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/settings.py b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/settings.py new file mode 100644 index 00000000..2e35a4f1 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for phonebook_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 decouple import config +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 = config("SECRET_KEY") + +# 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 Apps + 'contactsapp' +] + +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 = 'phonebook_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 = 'phonebook_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/Chicago' + +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/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/urls.py b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/urls.py new file mode 100644 index 00000000..c069f3e5 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/urls.py @@ -0,0 +1,22 @@ +"""phonebook_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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('contacts/', include('contactsapp.urls')) +] diff --git a/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/wsgi.py b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/wsgi.py new file mode 100644 index 00000000..54e908f5 --- /dev/null +++ b/Code/will/django_labs/practice_labs/phonebook_proj/phonebook_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for phonebook_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', 'phonebook_proj.settings') + +application = get_wsgi_application() From e22f2fd171f5471148ee653c566cfbb3fb2b854e Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Thu, 14 Apr 2022 22:29:13 -0500 Subject: [PATCH 20/33] Submit Todo Project --- .../django_labs/todo_proj/todo_app/admin.py | 3 +++ .../django_labs/todo_proj/todo_app/forms.py | 8 ------ ...r_priority_name_alter_todoitem_priority.py | 24 +++++++++++++++++ .../django_labs/todo_proj/todo_app/models.py | 10 ++++--- .../todo_app/templates/todo_app/index.html | 25 +++++++++++++----- .../django_labs/todo_proj/todo_app/urls.py | 2 ++ .../django_labs/todo_proj/todo_app/views.py | 26 +++++++++---------- 7 files changed, 66 insertions(+), 32 deletions(-) delete mode 100644 Code/will/django_labs/todo_proj/todo_app/forms.py create mode 100644 Code/will/django_labs/todo_proj/todo_app/migrations/0002_alter_priority_name_alter_todoitem_priority.py diff --git a/Code/will/django_labs/todo_proj/todo_app/admin.py b/Code/will/django_labs/todo_proj/todo_app/admin.py index 8c38f3f3..da7003ed 100644 --- a/Code/will/django_labs/todo_proj/todo_app/admin.py +++ b/Code/will/django_labs/todo_proj/todo_app/admin.py @@ -1,3 +1,6 @@ from django.contrib import admin +from .models import * # Register your models here. +admin.site.register(TodoItem) +admin.site.register(Priority) diff --git a/Code/will/django_labs/todo_proj/todo_app/forms.py b/Code/will/django_labs/todo_proj/todo_app/forms.py deleted file mode 100644 index 05b01b7d..00000000 --- a/Code/will/django_labs/todo_proj/todo_app/forms.py +++ /dev/null @@ -1,8 +0,0 @@ -from django import forms - -priority_choices = (('high', 'High'), ('medium', 'Medium'), ('low', 'Low')) - - -class NewTodoForm(forms.Form): - text = forms.CharField(max_length=120) - priority = forms.ChoiceField(choices=priority_choices) diff --git a/Code/will/django_labs/todo_proj/todo_app/migrations/0002_alter_priority_name_alter_todoitem_priority.py b/Code/will/django_labs/todo_proj/todo_app/migrations/0002_alter_priority_name_alter_todoitem_priority.py new file mode 100644 index 00000000..a70d7b34 --- /dev/null +++ b/Code/will/django_labs/todo_proj/todo_app/migrations/0002_alter_priority_name_alter_todoitem_priority.py @@ -0,0 +1,24 @@ +# Generated by Django 4.0.3 on 2022-04-15 02:16 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('todo_app', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='priority', + name='name', + field=models.CharField(choices=[('high', 'High'), ('medium', 'Medium'), ('low', 'Low')], default='low', max_length=6), + ), + migrations.AlterField( + model_name='todoitem', + name='priority', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='todo_app.priority'), + ), + ] diff --git a/Code/will/django_labs/todo_proj/todo_app/models.py b/Code/will/django_labs/todo_proj/todo_app/models.py index 68d2ffed..2f307fd5 100644 --- a/Code/will/django_labs/todo_proj/todo_app/models.py +++ b/Code/will/django_labs/todo_proj/todo_app/models.py @@ -3,16 +3,18 @@ class Priority(models.Model): - name = models.CharField( - max_length=6, choices=(('high', 'High'), ('medium', 'Medium'), ('low', 'Low')), default='low') + max_length=6, choices=(('High', 'High'), ('Medium', 'Medium'), ('Low', 'Low'))) + + def __str__(self): + return f'{self.name}' class TodoItem(models.Model): text = models.CharField(max_length=120) priority = models.ForeignKey( - Priority, on_delete=models.CASCADE) + Priority, on_delete=models.CASCADE, related_name='items') created_date = models.DateTimeField(auto_now=True) def __str__(self): - return f'{self.text} {self.priority} {self.created_date.day}' + return f'{self.text} {self.created_date.month}/{self.created_date.day}' diff --git a/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html index 0eb12a95..c8cb0e7b 100644 --- a/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html +++ b/Code/will/django_labs/todo_proj/todo_app/templates/todo_app/index.html @@ -8,17 +8,30 @@ -
    + {% csrf_token %} - {{form}} - -
    + + +

    To Do List:

    - {% for task in tasks %} + + {% for priority in priorities %}
    -
    {{task.text}} {{task.priority}}
    +

    {{priority.name}}

    + + {% for task in priority.items.all %} +
    +
    {{task.text}} {{task.created_date.month}}/{{task.created_date.day}}
    +
    + {% endfor %}
    {% endfor %} diff --git a/Code/will/django_labs/todo_proj/todo_app/urls.py b/Code/will/django_labs/todo_proj/todo_app/urls.py index 0ecd6851..e90482f6 100644 --- a/Code/will/django_labs/todo_proj/todo_app/urls.py +++ b/Code/will/django_labs/todo_proj/todo_app/urls.py @@ -1,6 +1,8 @@ from django.urls import path from . import views +app_name = 'todo_app' + urlpatterns = [ path('', views.index, name='index'), path('save', views.save_task, name='save_task') diff --git a/Code/will/django_labs/todo_proj/todo_app/views.py b/Code/will/django_labs/todo_proj/todo_app/views.py index 540637ea..bf08593f 100644 --- a/Code/will/django_labs/todo_proj/todo_app/views.py +++ b/Code/will/django_labs/todo_proj/todo_app/views.py @@ -1,28 +1,26 @@ from django.shortcuts import render -from .forms import * -from .models import TodoItem +from .models import * from django.http import HttpResponseRedirect from django.urls import reverse # Create your views here. -tasks = [ - -] - def index(request): + priorities = Priority.objects.all() tasks = TodoItem.objects.all().order_by('-created_date') return render(request, 'todo_app/index.html', { - 'tasks': tasks, 'form': NewTodoForm() + 'tasks': tasks, 'priorities': priorities }) def save_task(request): - form = NewTodoForm(request.POST) - if request.method == 'POST' and form.is_valid(): - tasks = TodoItem() - tasks.text = forms.cleaned_data['text'] - tasks.priority = forms.cleaned_data['priority'] - tasks.save() + task_text = request.POST['item'] + task_prio = request.POST['priority'] + new_task = TodoItem() + new_task.text = task_text + if task_prio: + priority = Priority.objects.get(id=task_prio) + new_task.priority = priority + new_task.save() - return HttpResponseRedirect(reverse('index')) + return HttpResponseRedirect(reverse('todo_app:index')) From 716b7190658c5e991c51ee756558ebdda78a95c2 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Mon, 18 Apr 2022 22:42:48 -0500 Subject: [PATCH 21/33] javascript intro notes --- Code/will/javascript/practice/intro/app.js | 99 +++++++++++++++++++ .../will/javascript/practice/intro/index.html | 13 +++ 2 files changed, 112 insertions(+) create mode 100644 Code/will/javascript/practice/intro/app.js create mode 100644 Code/will/javascript/practice/intro/index.html diff --git a/Code/will/javascript/practice/intro/app.js b/Code/will/javascript/practice/intro/app.js new file mode 100644 index 00000000..a9b79f2e --- /dev/null +++ b/Code/will/javascript/practice/intro/app.js @@ -0,0 +1,99 @@ +// //alert('Hello World') +// console.log('Hello Class Kiwi') +// console.warn('Something is up...') +// console.info('Page Loaded') + +// //let userInput = prompt('How is your day?') + +// const favColor = 'Orange' //Unchanging variable, constant +// console.log(favColor, 'My favorite color') + +// let lastName = 'Smith' //changeable variable + +// let color = 'bluegreen' +// console.log(typeof color) // returns string + +// let numOne = 1 +// console.log(typeof numOne) // returns int + +// Data Types +// 'Hello World' //string +// "Hello World" //string + +// 4 //number +// 4.7 //number (not a float) + +// true //Boolean +// false //Boolean + +// [1,2,3] //array (works like a list) + +// {name: 'Tom'} //Object (works like a dictionary) + +// undefined //undefined (value does not exist) +// null //intentional absence of value + +// console.log(x) +// let x = 24 + ' Tomorrow' + +// let number = 5 +// console.log(number == '5') // 5 is equal to int 5 and string 5 + +// let number = 5 +// console.log(number === '5') // number IS a string, no coercion + +// let a = 1 // number (Js) int(Py) +// let b = 1.2 //number(Js) float(Py) +// let c = 123e7 //large number +// let d = 123e-7 //scientific notation + +// let number = 5 +// if (number < 10){ +// console.log('Hooray!') +// }else if(number>10){ +// console.log('This is a large number.') +// }else{ +// console.log('This number is 10.') +// } + +// let person = { +// firstName: 'John', +// lastName: 'Snow', +// age: 30, + +// pets: { +// dog: 'Spot', +// cat: 'Claudius' +// } +// } +// console.log(person) +// console.log(person['firstName']) +// console.log(person.lastName) + +// //update.age +// person.age = 40 + +//increment age +// person.age ++ // adds 1 +// person.age += 2 + +// reference nested object +// console.log(person.pets['dog']) + +// function sayHello(){ +// let color = 'blue' +// return color +// } + +// console.log(sayHello()) + +// function addNums(num1, num2){ +// return num1 + num2 +// } + +// console.log(addNums(3,5)) + +// const arrowFunct = (num1, num2) => { +// return num1 + num2 +// } +// console.log(arrowFunct(2,8)) \ No newline at end of file diff --git a/Code/will/javascript/practice/intro/index.html b/Code/will/javascript/practice/intro/index.html new file mode 100644 index 00000000..2465678a --- /dev/null +++ b/Code/will/javascript/practice/intro/index.html @@ -0,0 +1,13 @@ + + + + + + + + Intro + + +

    Javascript Intro

    + + \ No newline at end of file From 543dcf6f6976f696387bccf6656854393b7ef2e6 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Tue, 19 Apr 2022 23:21:27 -0500 Subject: [PATCH 22/33] intro 2 notes --- Code/will/javascript/practice/intro2/app.js | 63 +++++++++++++++++++ .../javascript/practice/intro2/index.html | 13 ++++ 2 files changed, 76 insertions(+) create mode 100644 Code/will/javascript/practice/intro2/app.js create mode 100644 Code/will/javascript/practice/intro2/index.html diff --git a/Code/will/javascript/practice/intro2/app.js b/Code/will/javascript/practice/intro2/app.js new file mode 100644 index 00000000..f69b032d --- /dev/null +++ b/Code/will/javascript/practice/intro2/app.js @@ -0,0 +1,63 @@ +// var user +// user = 'Lisa' + +// console.log(user) + +// Js variables accept letters, numbers (not leading), and % _ symbols + +// message = 'Hello World' +// console.log(window) +// console.log(window.message) + +// window.console.log('hello') +// console = 'hello' +// console.log('hello') + +// let day +// day = 'Tuesday' +// console.log(day) +// day = 'Friday' +// console.log(day) + +// const numbers = [3,4] + +// numbers.push(5,6) +// console.log(numbers) + +// numbers.unshift(1,2) +// console.log(numbers) + +// numbers.splice(2,0,'a','b') +// console.log(numbers) + +// const numbers = [1,2,3,4] +// console.log(numbers) +// const last = numbers.pop() +// console.log(last) + +// const first = numbers.shift() +// console.log(first) +// console.log(numbers) + +// numbers.push(7,9) +// console.log(numbers) +// // numbers.splice(1, 2) +// // console.log(numbers) +// console.log(numbers.indexOf('2')) +// console.log(numbers.indexOf(9)) +// console.log(numbers.includes(2)) + +// numbers.push(3) +// console.log(numbers) +// console.log(numbers.lastIndexOf(2)) + +const courses = [ + {id: 1, name: 'apple'}, + {id: 2, name: 'banana'}, + {id: 3, name: 'pear'} +] + +const course = courses.find(function(course){ + return course.name === 'apple' +}) +console.log(course.name) \ No newline at end of file diff --git a/Code/will/javascript/practice/intro2/index.html b/Code/will/javascript/practice/intro2/index.html new file mode 100644 index 00000000..7032d5cc --- /dev/null +++ b/Code/will/javascript/practice/intro2/index.html @@ -0,0 +1,13 @@ + + + + + + + + Intro Pt.2 + + +

    Javascript Day 2

    + + \ No newline at end of file From 3dccf18f48399c777056fb3596bc861d80c1ee44 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Wed, 20 Apr 2022 23:25:23 -0500 Subject: [PATCH 23/33] DOM notes and Js Redo start --- .../javascript/Labs/javascript_redo/app.js | 14 +++++ .../Labs/javascript_redo/index.html | 14 +++++ Code/will/javascript/practice/DOM/app.js | 54 +++++++++++++++++++ Code/will/javascript/practice/DOM/index.html | 21 ++++++++ Code/will/javascript/practice/DOM/style.css | 0 Code/will/javascript/practice/intro2/app.js | 20 +++---- 6 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 Code/will/javascript/Labs/javascript_redo/app.js create mode 100644 Code/will/javascript/Labs/javascript_redo/index.html create mode 100644 Code/will/javascript/practice/DOM/app.js create mode 100644 Code/will/javascript/practice/DOM/index.html create mode 100644 Code/will/javascript/practice/DOM/style.css diff --git a/Code/will/javascript/Labs/javascript_redo/app.js b/Code/will/javascript/Labs/javascript_redo/app.js new file mode 100644 index 00000000..ec0c1cb3 --- /dev/null +++ b/Code/will/javascript/Labs/javascript_redo/app.js @@ -0,0 +1,14 @@ +const button = document.querySelector('#submit') + + +button.addEventListener('click', function(){ + var compChoices = ['Rock', 'Paper', 'Scissors'] + var compSelect = compChoices[Math.floor(Math.random() * compChoices.length)] + document.body.innerHTML = compSelect +}) +// let userInput = prompt('Rock, Paper, or Scissors?') + +// if (userInput === 'Rock'){ +// alert +// } +// }) \ No newline at end of file diff --git a/Code/will/javascript/Labs/javascript_redo/index.html b/Code/will/javascript/Labs/javascript_redo/index.html new file mode 100644 index 00000000..d8deeb4a --- /dev/null +++ b/Code/will/javascript/Labs/javascript_redo/index.html @@ -0,0 +1,14 @@ + + + + + + + Rock Paper Scissors + + +

    Rock, Paper, Scissors

    + + + + \ No newline at end of file diff --git a/Code/will/javascript/practice/DOM/app.js b/Code/will/javascript/practice/DOM/app.js new file mode 100644 index 00000000..d92f24b2 --- /dev/null +++ b/Code/will/javascript/practice/DOM/app.js @@ -0,0 +1,54 @@ +// const headers = document.getElementsByTagName('h2') +// console.log(headers) +// console.log(headers[1]) + +// const list = document.getElementsByClassName('item') +// console.log(list) + +// const button = document.getElementById('submit') //getElementById gets first instance of given Id +// console.log(button) + +// const headers = document.querySelectorAll('h2') +// console.log(headers) + +// const list = document.querySelectorAll('.item') // reference classes with .classname, id with #id +// console.log(list) + +// const list = document.querySelector('#list a') +// console.log(list) + +//SELECTORS +// const button = document.querySelector('#submit') + + +//LISTENERS +// button.addEventListener('click', function(){ +// console.log('Test Button') +// }) + +// button.addEventListener('click', addItem) +// function addItem(){ +// console.log('Test Button') +// } + +//SELECTORS +const button = document.querySelector('#submit') +const todoList = document.querySelector('#todo-list') +const todoItems = todoList.children +const todoNum = document.querySelector('.todo-num b') +const mainTitle = document.querySelector('.main-title') + +//LISTENERS +button.addEventListener('click', function(){ + const newItem = document.createElement('li') + newItem.classList.add('item') + newItem.innerText = `Item ${todoItems.length + 1}` + todoList.appendChild(newItem) + console.log(newItem) + todoNum.innerText = todoItems.length +}) + +button.addEventListener('click', function(){ + mainTitle.style.color = 'blue' + mainTitle.style.fontSize = '2.5rem' +}) \ No newline at end of file diff --git a/Code/will/javascript/practice/DOM/index.html b/Code/will/javascript/practice/DOM/index.html new file mode 100644 index 00000000..861ee584 --- /dev/null +++ b/Code/will/javascript/practice/DOM/index.html @@ -0,0 +1,21 @@ + + + + + + + + + DOM + + +

    Javascript - Working with DOM

    +
      +
    • Item 1
    • +
    • Item 2
    • +
    + +

    Number of items:

    + + + \ No newline at end of file diff --git a/Code/will/javascript/practice/DOM/style.css b/Code/will/javascript/practice/DOM/style.css new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/javascript/practice/intro2/app.js b/Code/will/javascript/practice/intro2/app.js index f69b032d..ee6512d0 100644 --- a/Code/will/javascript/practice/intro2/app.js +++ b/Code/will/javascript/practice/intro2/app.js @@ -51,13 +51,13 @@ // console.log(numbers) // console.log(numbers.lastIndexOf(2)) -const courses = [ - {id: 1, name: 'apple'}, - {id: 2, name: 'banana'}, - {id: 3, name: 'pear'} -] - -const course = courses.find(function(course){ - return course.name === 'apple' -}) -console.log(course.name) \ No newline at end of file +// const courses = [ +// {id: 1, name: 'apple'}, +// {id: 2, name: 'banana'}, +// {id: 3, name: 'pear'} +// ] + +// const course = courses.find(function(course){ +// return course.name === 'apple' +// }) +// console.log(course.name) \ No newline at end of file From 00b926443bc060d80f972f17909714a634ebf6e2 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Thu, 21 Apr 2022 21:44:39 -0500 Subject: [PATCH 24/33] Js redo submission --- .../javascript/Labs/javascript_redo/app.js | 42 ++++++++++++++----- .../Labs/javascript_redo/index.html | 9 +++- Code/will/javascript/practice/DOM/app.js | 34 ++++++++++++--- Code/will/javascript/practice/DOM/index.html | 8 ++-- 4 files changed, 72 insertions(+), 21 deletions(-) diff --git a/Code/will/javascript/Labs/javascript_redo/app.js b/Code/will/javascript/Labs/javascript_redo/app.js index ec0c1cb3..78f31adc 100644 --- a/Code/will/javascript/Labs/javascript_redo/app.js +++ b/Code/will/javascript/Labs/javascript_redo/app.js @@ -1,14 +1,36 @@ const button = document.querySelector('#submit') +const choiceInput = document.querySelector('.choice-input') +var compChoices = ["rock", "paper", "scissors"] -button.addEventListener('click', function(){ - var compChoices = ['Rock', 'Paper', 'Scissors'] - var compSelect = compChoices[Math.floor(Math.random() * compChoices.length)] - document.body.innerHTML = compSelect -}) -// let userInput = prompt('Rock, Paper, or Scissors?') +button.addEventListener('click', function(e){ + e.preventDefault() + const compSelect = compChoices[(Math.random() * compChoices.length) | 0] + playerChoice = choiceInput.value + playerChoice = playerChoice.toLowerCase() + console.log(playerChoice) + console.log(compSelect) -// if (userInput === 'Rock'){ -// alert -// } -// }) \ No newline at end of file + if(playerChoice === compSelect){ + alert("It's a tie!") + }else if(playerChoice === 'rock'){ + if(compSelect === 'scissors'){ + alert("You win!") + }else if(compSelect === 'paper'){ + alert("You lose.") + } + }else if(playerChoice === 'paper'){ + if(compSelect === 'rock'){ + alert("You win!") + }else if(compSelect === 'scissors'){ + alert("You lose.") + } + }else if(playerChoice === 'scissors'){ + if(compSelect === 'paper'){ + alert("You win!") + }else if(compSelect === 'rock'){ + alert("You lose.") + } + } + choiceInput.value = '' +}) \ No newline at end of file diff --git a/Code/will/javascript/Labs/javascript_redo/index.html b/Code/will/javascript/Labs/javascript_redo/index.html index d8deeb4a..1c37aa31 100644 --- a/Code/will/javascript/Labs/javascript_redo/index.html +++ b/Code/will/javascript/Labs/javascript_redo/index.html @@ -4,11 +4,16 @@ + Rock Paper Scissors -

    Rock, Paper, Scissors

    +

    Rock, Paper, or Scissors?

    - +
    + + + +
    \ No newline at end of file diff --git a/Code/will/javascript/practice/DOM/app.js b/Code/will/javascript/practice/DOM/app.js index d92f24b2..2fac8457 100644 --- a/Code/will/javascript/practice/DOM/app.js +++ b/Code/will/javascript/practice/DOM/app.js @@ -37,18 +37,40 @@ const todoList = document.querySelector('#todo-list') const todoItems = todoList.children const todoNum = document.querySelector('.todo-num b') const mainTitle = document.querySelector('.main-title') +const nameInput = document.querySelector('.name-input') //LISTENERS -button.addEventListener('click', function(){ +button.addEventListener('click', function(e){ + e.preventDefault() const newItem = document.createElement('li') newItem.classList.add('item') - newItem.innerText = `Item ${todoItems.length + 1}` + // newItem.innerText = `Item ${todoItems.length + 1}` + newItem.innerText = nameInput.value todoList.appendChild(newItem) - console.log(newItem) todoNum.innerText = todoItems.length + nameInput.value = '' + + newItem.addEventListener('click', deleteItem) }) -button.addEventListener('click', function(){ - mainTitle.style.color = 'blue' +button.addEventListener('click', function(){ mainTitle.style.color = 'blue' mainTitle.style.fontSize = '2.5rem' -}) \ No newline at end of file +}) + +// for (item of items){ +// item.addEventListener('click', deleteItem) +// } + +todoList.addEventListener('click', function(){ + todoList.classList.toggle('fade') + +}) + + +function deleteItem(e){ + // console.log(e) + // console.log(e.target) + e.stopPropagation() + e.target.remove() + todoNum.innerText = todoItems.length +} \ No newline at end of file diff --git a/Code/will/javascript/practice/DOM/index.html b/Code/will/javascript/practice/DOM/index.html index 861ee584..a55e231b 100644 --- a/Code/will/javascript/practice/DOM/index.html +++ b/Code/will/javascript/practice/DOM/index.html @@ -11,11 +11,13 @@

    Javascript - Working with DOM

      -
    • Item 1
    • -
    • Item 2

    Number of items:

    - +
    + + + +
    \ No newline at end of file From 889364288f70cccc167be15ab6b144ad43d84f7a Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Mon, 25 Apr 2022 23:55:05 -0500 Subject: [PATCH 25/33] Js ToDo List Lab progress --- Code/will/javascript/Labs/todo_list/app.js | 32 +++++++++++++++++++ .../will/javascript/Labs/todo_list/index.html | 21 ++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Code/will/javascript/Labs/todo_list/app.js create mode 100644 Code/will/javascript/Labs/todo_list/index.html diff --git a/Code/will/javascript/Labs/todo_list/app.js b/Code/will/javascript/Labs/todo_list/app.js new file mode 100644 index 00000000..9906100d --- /dev/null +++ b/Code/will/javascript/Labs/todo_list/app.js @@ -0,0 +1,32 @@ +const button = document.querySelector("#submit") +const todoList = document.querySelector('#todo-list') +const todoItems = todoList.children +const nameInput = document.querySelector('.name-input') + +//LISTENERS +button.addEventListener('click', function(e){ + e.preventDefault() + const newItem = document.createElement('li') + newItem.classList.add('item') + // newItem.innerText = `Item ${todoItems.length + 1}` + newItem.innerText = nameInput.value + todoList.appendChild(newItem) + todoNum.innerText = todoItems.length + nameInput.value = '' + + newItem.addEventListener('click', deleteItem) +}) + +todoList.addEventListener('click', function(){ + todoList.classList.toggle('fade') + +}) + + +function deleteItem(e){ + // console.log(e) + // console.log(e.target) + e.stopPropagation() + e.target.remove() + todoNum.innerText = todoItems.length +} \ No newline at end of file diff --git a/Code/will/javascript/Labs/todo_list/index.html b/Code/will/javascript/Labs/todo_list/index.html new file mode 100644 index 00000000..6c9b29eb --- /dev/null +++ b/Code/will/javascript/Labs/todo_list/index.html @@ -0,0 +1,21 @@ + + + + + + + + Todo List + + +

    To Do:

    +
      + +
    + +
    + + +
    + + \ No newline at end of file From 1f7d45d428f5816ef70b36ddd62d7749081f9048 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Tue, 26 Apr 2022 23:23:50 -0500 Subject: [PATCH 26/33] API Notes and Todo List progress --- Code/will/javascript/Labs/todo_list/app.js | 7 ++-- .../will/javascript/Labs/todo_list/index.html | 2 +- Code/will/javascript/practice/APIs/app.js | 42 +++++++++++++++++++ Code/will/javascript/practice/APIs/index.html | 13 ++++++ Code/will/javascript/practice/DOM/app.js | 1 - 5 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 Code/will/javascript/practice/APIs/app.js create mode 100644 Code/will/javascript/practice/APIs/index.html diff --git a/Code/will/javascript/Labs/todo_list/app.js b/Code/will/javascript/Labs/todo_list/app.js index 9906100d..1f53aedf 100644 --- a/Code/will/javascript/Labs/todo_list/app.js +++ b/Code/will/javascript/Labs/todo_list/app.js @@ -8,12 +8,14 @@ button.addEventListener('click', function(e){ e.preventDefault() const newItem = document.createElement('li') newItem.classList.add('item') - // newItem.innerText = `Item ${todoItems.length + 1}` newItem.innerText = nameInput.value todoList.appendChild(newItem) - todoNum.innerText = todoItems.length nameInput.value = '' + var button = document.createElement('button') + button.innerText = 'x' + todoList.appendChild(button) + newItem.addEventListener('click', deleteItem) }) @@ -28,5 +30,4 @@ function deleteItem(e){ // console.log(e.target) e.stopPropagation() e.target.remove() - todoNum.innerText = todoItems.length } \ No newline at end of file diff --git a/Code/will/javascript/Labs/todo_list/index.html b/Code/will/javascript/Labs/todo_list/index.html index 6c9b29eb..a3ae800f 100644 --- a/Code/will/javascript/Labs/todo_list/index.html +++ b/Code/will/javascript/Labs/todo_list/index.html @@ -15,7 +15,7 @@

    To Do:

    - +
    \ No newline at end of file diff --git a/Code/will/javascript/practice/APIs/app.js b/Code/will/javascript/practice/APIs/app.js new file mode 100644 index 00000000..292b9f66 --- /dev/null +++ b/Code/will/javascript/practice/APIs/app.js @@ -0,0 +1,42 @@ +// ************* FETCH REQUEST ************** +// console.log(fetch('http://jsonplaceholder.typicode.com/posts/1')) + +// fetch('http://jsonplaceholder.typicode.com/posts/1') +// .then(function(response){ +// return response.json +// }) +// .then(function(data){ +// console.log(data) +// console.log(data.title) +// console.log(data.id) +// }) + + +// ********** POST REQUEST ************ +// const blogPost = { +// title: "Kiwi Post", +// body: "Class Kiwi 2022", +// userId: 1 +// } + +// fetch('http://jsonplaceholder.typicode.com/posts', { +// method: "POST", +// headers: {"Content-Type": "application/json"}, +// body: JSON.stringify(blogPost) +// }) +// .then(function(response){ +// return response.json() +// }) +// .then(function(data){ +// console.log(data) +// }) + +fetch('http://jsonplaceholder.typicode.com/postss/1') +.then(function(response){ + if(!response.ok) + return new Error('Bad Requests ') +}) +.then(function(data){ + console.log(data) +}) + diff --git a/Code/will/javascript/practice/APIs/index.html b/Code/will/javascript/practice/APIs/index.html new file mode 100644 index 00000000..5f8062be --- /dev/null +++ b/Code/will/javascript/practice/APIs/index.html @@ -0,0 +1,13 @@ + + + + + + + + API + + +

    API/Fetch Introduction

    + + \ No newline at end of file diff --git a/Code/will/javascript/practice/DOM/app.js b/Code/will/javascript/practice/DOM/app.js index 2fac8457..e82d5cd9 100644 --- a/Code/will/javascript/practice/DOM/app.js +++ b/Code/will/javascript/practice/DOM/app.js @@ -47,7 +47,6 @@ button.addEventListener('click', function(e){ // newItem.innerText = `Item ${todoItems.length + 1}` newItem.innerText = nameInput.value todoList.appendChild(newItem) - todoNum.innerText = todoItems.length nameInput.value = '' newItem.addEventListener('click', deleteItem) From ee2b2ad931abbb7acf311c755fa5c58e7386d690 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Wed, 27 Apr 2022 23:18:48 -0500 Subject: [PATCH 27/33] todo list changes --- Code/will/javascript/Labs/todo_list/app.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Code/will/javascript/Labs/todo_list/app.js b/Code/will/javascript/Labs/todo_list/app.js index 1f53aedf..d6df765e 100644 --- a/Code/will/javascript/Labs/todo_list/app.js +++ b/Code/will/javascript/Labs/todo_list/app.js @@ -12,10 +12,6 @@ button.addEventListener('click', function(e){ todoList.appendChild(newItem) nameInput.value = '' - var button = document.createElement('button') - button.innerText = 'x' - todoList.appendChild(button) - newItem.addEventListener('click', deleteItem) }) From 4733abc86c5aac4f3dfab79294e75b9789b4bada Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Thu, 28 Apr 2022 23:21:17 -0500 Subject: [PATCH 28/33] todo list app submission --- Code/will/javascript/Labs/todo_list/app.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Code/will/javascript/Labs/todo_list/app.js b/Code/will/javascript/Labs/todo_list/app.js index d6df765e..57995603 100644 --- a/Code/will/javascript/Labs/todo_list/app.js +++ b/Code/will/javascript/Labs/todo_list/app.js @@ -2,6 +2,7 @@ const button = document.querySelector("#submit") const todoList = document.querySelector('#todo-list') const todoItems = todoList.children const nameInput = document.querySelector('.name-input') +const taskList = document.getElementsByTagName('li') //LISTENERS button.addEventListener('click', function(e){ @@ -12,7 +13,7 @@ button.addEventListener('click', function(e){ todoList.appendChild(newItem) nameInput.value = '' - newItem.addEventListener('click', deleteItem) + newItem.addEventListener('dblclick', deleteItem) }) todoList.addEventListener('click', function(){ @@ -20,10 +21,18 @@ todoList.addEventListener('click', function(){ }) +todoList.addEventListener('click', function(){ + +}) + +todoList.addEventListener('click', markComplete) function deleteItem(e){ - // console.log(e) - // console.log(e.target) e.stopPropagation() e.target.remove() +} + +function markComplete(e){ + e.stopPropagation() + e.target.style.setProperty("text-decoration", "line-through") } \ No newline at end of file From cf3e53d5a694ff2ee5efa42fb3542c3d7ef34d74 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Tue, 3 May 2022 23:17:20 -0500 Subject: [PATCH 29/33] cards_api practice upload --- .../will/javascript/practice/cards_api/app.js | 97 +++++++++++++++++++ .../javascript/practice/cards_api/index.html | 20 ++++ 2 files changed, 117 insertions(+) create mode 100644 Code/will/javascript/practice/cards_api/app.js create mode 100644 Code/will/javascript/practice/cards_api/index.html diff --git a/Code/will/javascript/practice/cards_api/app.js b/Code/will/javascript/practice/cards_api/app.js new file mode 100644 index 00000000..02b37447 --- /dev/null +++ b/Code/will/javascript/practice/cards_api/app.js @@ -0,0 +1,97 @@ +const shuffleBtn = document.querySelector("#shuffle-btn") +const dealBtn = document.querySelector("#deal-btn") +let deckID = null +let hands = { + dealer: [], + player: [] +} + + +shuffleBtn.addEventListener("click", getCards) +dealBtn.addEventListener("click", dealCards) + + +///// ASYNC WAIT METHOD ///// +async function getCards(){ + const response = await fetch("http://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=6") + const data = await response.json() + console.log(data) + deckID = data.deck_id +} + + +async function dealCards(){ + const url = `http://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 + console.log(data) + playerValue = showCards() + dealerValue = showCards(true) + whoWins(playerValue, dealerValue) +} + + +function addHand(value){ + const strValue = value + let intValue = 0 + if(strValue == 'KING'){ + intValue =10 + }else if(strValue == 'QUEEN'){ + intValue =10 + }else if(strValue == 'JACK'){ + intValue = 10 + }else if(strValue == 'ACE'){ + intValue = 11 + }else{ + intValue = parseInt(value) + } + return intValue +} + + + + + +function showCards(dealer = false){ + const hand = dealer ? hands.dealer : hands.player + const selector = dealer ? '#dealer' : '#player' + let handValue = 0 + const handContainer = document.querySelector(selector) + handContainer.innerHTML = '' + + for(card of hand){ + const cardImage = document.createElement('img') + cardImage.src = card.image + handContainer.append(cardImage) + cardValue = addHand(card.value) + handValue += cardValue + } + return handValue +} + + +function whoWins(playerValue, dealerValue){ + if(playerValue > dealerValue && playerValue <= 21){ + alert('You Win!') + }else if(dealerValue > playerValue && dealerValue <= 21){ + alert('Dealer Wins.') + }else if(dealerValue = playerValue){ + alert('Push.') + } +} + + + + + +///// DOT THEN METHOD ///// +// fetch("http://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1") +// .then(function(data){ +// return data.json() +// } +// ).then(function(data){ +// console.log(data) +// }) diff --git a/Code/will/javascript/practice/cards_api/index.html b/Code/will/javascript/practice/cards_api/index.html new file mode 100644 index 00000000..0545e920 --- /dev/null +++ b/Code/will/javascript/practice/cards_api/index.html @@ -0,0 +1,20 @@ + + + + + + + + BlackJack + + +
    + + +
    +

    Your Hand

    +
    +

    Dealer's Hand

    +
    + + \ No newline at end of file From 42d07f8d2fb832ef8cca00e695b6b986fe5c0742 Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Tue, 10 May 2022 22:58:53 -0500 Subject: [PATCH 30/33] Vue practice --- Code/will/javascript/practice/vue/index.html | 111 +++++++++++++++++++ Code/will/javascript/practice/vue/styles.css | 0 2 files changed, 111 insertions(+) create mode 100644 Code/will/javascript/practice/vue/index.html create mode 100644 Code/will/javascript/practice/vue/styles.css diff --git a/Code/will/javascript/practice/vue/index.html b/Code/will/javascript/practice/vue/index.html new file mode 100644 index 00000000..450212bf --- /dev/null +++ b/Code/will/javascript/practice/vue/index.html @@ -0,0 +1,111 @@ + + + + + + + + + + + + + Document + + + +
    +

    {{headerText}}

    + +
    +
    + + +
    + + +
    +

    Incomplete

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

    Complete

    +
    + + {{todo.id}} {{todo.text}} + +
    + + +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/Code/will/javascript/practice/vue/styles.css b/Code/will/javascript/practice/vue/styles.css new file mode 100644 index 00000000..e69de29b From d29af04feb3f47fb1f0415cdabf662b1ad73339e Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Wed, 11 May 2022 23:11:43 -0500 Subject: [PATCH 31/33] backend for vue todo app --- Code/will/javascript/practice/vue/.gitignore | 1 + Code/will/javascript/practice/vue/manage.py | 22 +++ .../practice/vue/todoAPI_proj/__init__.py | 0 .../practice/vue/todoAPI_proj/asgi.py | 16 ++ .../practice/vue/todoAPI_proj/settings.py | 126 +++++++++++++++ .../practice/vue/todoAPI_proj/urls.py | 23 +++ .../practice/vue/todoAPI_proj/wsgi.py | 16 ++ .../practice/vue/todo_app/__init__.py | 0 .../javascript/practice/vue/todo_app/admin.py | 5 + .../javascript/practice/vue/todo_app/apps.py | 6 + .../vue/todo_app/migrations/0001_initial.py | 22 +++ .../vue/todo_app/migrations/__init__.py | 0 .../practice/vue/todo_app/models.py | 11 ++ .../practice/vue/todo_app/serializers.py | 8 + .../todo_app/templates/todo_app/index.html | 148 ++++++++++++++++++ .../javascript/practice/vue/todo_app/tests.py | 3 + .../javascript/practice/vue/todo_app/urls.py | 9 ++ .../javascript/practice/vue/todo_app/views.py | 55 +++++++ 18 files changed, 471 insertions(+) create mode 100644 Code/will/javascript/practice/vue/.gitignore create mode 100644 Code/will/javascript/practice/vue/manage.py create mode 100644 Code/will/javascript/practice/vue/todoAPI_proj/__init__.py create mode 100644 Code/will/javascript/practice/vue/todoAPI_proj/asgi.py create mode 100644 Code/will/javascript/practice/vue/todoAPI_proj/settings.py create mode 100644 Code/will/javascript/practice/vue/todoAPI_proj/urls.py create mode 100644 Code/will/javascript/practice/vue/todoAPI_proj/wsgi.py create mode 100644 Code/will/javascript/practice/vue/todo_app/__init__.py create mode 100644 Code/will/javascript/practice/vue/todo_app/admin.py create mode 100644 Code/will/javascript/practice/vue/todo_app/apps.py create mode 100644 Code/will/javascript/practice/vue/todo_app/migrations/0001_initial.py create mode 100644 Code/will/javascript/practice/vue/todo_app/migrations/__init__.py create mode 100644 Code/will/javascript/practice/vue/todo_app/models.py create mode 100644 Code/will/javascript/practice/vue/todo_app/serializers.py create mode 100644 Code/will/javascript/practice/vue/todo_app/templates/todo_app/index.html create mode 100644 Code/will/javascript/practice/vue/todo_app/tests.py create mode 100644 Code/will/javascript/practice/vue/todo_app/urls.py create mode 100644 Code/will/javascript/practice/vue/todo_app/views.py diff --git a/Code/will/javascript/practice/vue/.gitignore b/Code/will/javascript/practice/vue/.gitignore new file mode 100644 index 00000000..2eea525d --- /dev/null +++ b/Code/will/javascript/practice/vue/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Code/will/javascript/practice/vue/manage.py b/Code/will/javascript/practice/vue/manage.py new file mode 100644 index 00000000..3a1054e8 --- /dev/null +++ b/Code/will/javascript/practice/vue/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', 'todoAPI_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/will/javascript/practice/vue/todoAPI_proj/__init__.py b/Code/will/javascript/practice/vue/todoAPI_proj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/javascript/practice/vue/todoAPI_proj/asgi.py b/Code/will/javascript/practice/vue/todoAPI_proj/asgi.py new file mode 100644 index 00000000..afcf347d --- /dev/null +++ b/Code/will/javascript/practice/vue/todoAPI_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for todoAPI_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', 'todoAPI_proj.settings') + +application = get_asgi_application() diff --git a/Code/will/javascript/practice/vue/todoAPI_proj/settings.py b/Code/will/javascript/practice/vue/todoAPI_proj/settings.py new file mode 100644 index 00000000..bd79fc17 --- /dev/null +++ b/Code/will/javascript/practice/vue/todoAPI_proj/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for todoAPI_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 decouple import config +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 = config("SECRET_KEY") + +# 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', + + 'rest_framework', + '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 = 'todoAPI_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 = 'todoAPI_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/Chicago' + +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/will/javascript/practice/vue/todoAPI_proj/urls.py b/Code/will/javascript/practice/vue/todoAPI_proj/urls.py new file mode 100644 index 00000000..648db019 --- /dev/null +++ b/Code/will/javascript/practice/vue/todoAPI_proj/urls.py @@ -0,0 +1,23 @@ +"""todoAPI_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, include + +urlpatterns = [ + path('api-auth/', include('rest_framework.urls')), + path('admin/', admin.site.urls), + path('index/', include('todo_app.urls')), +] diff --git a/Code/will/javascript/practice/vue/todoAPI_proj/wsgi.py b/Code/will/javascript/practice/vue/todoAPI_proj/wsgi.py new file mode 100644 index 00000000..22651897 --- /dev/null +++ b/Code/will/javascript/practice/vue/todoAPI_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for todoAPI_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', 'todoAPI_proj.settings') + +application = get_wsgi_application() diff --git a/Code/will/javascript/practice/vue/todo_app/__init__.py b/Code/will/javascript/practice/vue/todo_app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/javascript/practice/vue/todo_app/admin.py b/Code/will/javascript/practice/vue/todo_app/admin.py new file mode 100644 index 00000000..9d284016 --- /dev/null +++ b/Code/will/javascript/practice/vue/todo_app/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from .models import * + +# Register your models here. +admin.site.register(TodoItem) diff --git a/Code/will/javascript/practice/vue/todo_app/apps.py b/Code/will/javascript/practice/vue/todo_app/apps.py new file mode 100644 index 00000000..d8f1498d --- /dev/null +++ b/Code/will/javascript/practice/vue/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/will/javascript/practice/vue/todo_app/migrations/0001_initial.py b/Code/will/javascript/practice/vue/todo_app/migrations/0001_initial.py new file mode 100644 index 00000000..199b458e --- /dev/null +++ b/Code/will/javascript/practice/vue/todo_app/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 4.0.3 on 2022-05-12 01:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='TodoItem', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=500)), + ('completed', models.BooleanField(default=False)), + ], + ), + ] diff --git a/Code/will/javascript/practice/vue/todo_app/migrations/__init__.py b/Code/will/javascript/practice/vue/todo_app/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Code/will/javascript/practice/vue/todo_app/models.py b/Code/will/javascript/practice/vue/todo_app/models.py new file mode 100644 index 00000000..a54aa1e3 --- /dev/null +++ b/Code/will/javascript/practice/vue/todo_app/models.py @@ -0,0 +1,11 @@ +from django.db import models + +# Create your models here. + + +class TodoItem(models.Model): + text = models.CharField(max_length=500) + completed = models.BooleanField(default=False) + + def __str__(self): + return self.text diff --git a/Code/will/javascript/practice/vue/todo_app/serializers.py b/Code/will/javascript/practice/vue/todo_app/serializers.py new file mode 100644 index 00000000..427e9de7 --- /dev/null +++ b/Code/will/javascript/practice/vue/todo_app/serializers.py @@ -0,0 +1,8 @@ +from rest_framework import serializers +from .models import * + + +class TodoSerializer(serializers.ModelSerializer): + class Meta: + model = TodoItem + fields = '__all__' diff --git a/Code/will/javascript/practice/vue/todo_app/templates/todo_app/index.html b/Code/will/javascript/practice/vue/todo_app/templates/todo_app/index.html new file mode 100644 index 00000000..f7a9d623 --- /dev/null +++ b/Code/will/javascript/practice/vue/todo_app/templates/todo_app/index.html @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + Vue + + + {% csrf_token %} + +
    +

    [[headerText]]

    + +
    +
    + + +
    + + +
    +

    Incomplete

    +
    + [[todo.id]] [[todo.text]] +
    + + +
    +
    +
    + +
    +

    Complete

    +
    + + [[todo.id]] [[todo.text]] + +
    + + +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/Code/will/javascript/practice/vue/todo_app/tests.py b/Code/will/javascript/practice/vue/todo_app/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Code/will/javascript/practice/vue/todo_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Code/will/javascript/practice/vue/todo_app/urls.py b/Code/will/javascript/practice/vue/todo_app/urls.py new file mode 100644 index 00000000..9e74518f --- /dev/null +++ b/Code/will/javascript/practice/vue/todo_app/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from . import views + +app_name = 'todo_app' +urlpatterns = [ + path('', views.index, name='index'), + path('list/', views.todo_list, name='todo_list'), + path('create/', views.create_todo, name='create_todo') +] diff --git a/Code/will/javascript/practice/vue/todo_app/views.py b/Code/will/javascript/practice/vue/todo_app/views.py new file mode 100644 index 00000000..9f1fef5a --- /dev/null +++ b/Code/will/javascript/practice/vue/todo_app/views.py @@ -0,0 +1,55 @@ +from django.shortcuts import render +from rest_framework.decorators import api_view +from rest_framework.response import Response +from .models import * +from .serializers import TodoSerializer + +# Create your views here. + + +def index(request): + return render(request, 'todo_app/index.html') + + +@api_view(["GET"]) +def todo_list(request): + response = Response() + + todos = TodoItem.objects.all() + + todo_serializer = TodoSerializer(todos, many=True) + + response.data = { + 'todos': todo_serializer.data + } + + return response + + +@api_view(["POST"]) +def create_todo(request): + response = Response() + + # extract new todo from request data + new_todo_text = request.data.get('new_todo_text') + + # instantiate TodoSerializer with text from the request + todo_serialzer = TodoSerializer(data={'text': new_todo_text}) + + # if serializer fields are valid + if todo_serialzer.is_valid(): + # create new todo object in DB + todo_serialzer.save() + + # pull all todos from DB + todos = TodoItem.objects.all() + + # serialize + todo_serialzer = TodoSerializer(todos, many=True) + + # attach data to response + response.data = { + 'todos': todo_serialzer.dta + } + + print(request.data) From 29cbb6ceec844cd5a322b3e429e5b295e19d081f Mon Sep 17 00:00:00 2001 From: Nithfaris Date: Thu, 12 May 2022 22:51:50 -0500 Subject: [PATCH 32/33] vue practice and vue_redo lab begun --- Code/will/javascript/Labs/vue_redo/index.html | 45 +++++++++++ .../todo_app/templates/todo_app/index.html | 75 +++++++++++++------ .../javascript/practice/vue/todo_app/urls.py | 5 +- .../javascript/practice/vue/todo_app/views.py | 49 +++++++++++- 4 files changed, 146 insertions(+), 28 deletions(-) create mode 100644 Code/will/javascript/Labs/vue_redo/index.html diff --git a/Code/will/javascript/Labs/vue_redo/index.html b/Code/will/javascript/Labs/vue_redo/index.html new file mode 100644 index 00000000..f6b2ca57 --- /dev/null +++ b/Code/will/javascript/Labs/vue_redo/index.html @@ -0,0 +1,45 @@ + + + + + + + + + + + + Rock, Paper Scissors + + + +
    +
    +

    Rock, Paper, Scissors

    +
    + +
    +

    Player's Choice

    +
    + +
    +

    Opponent's Choice

    +
    +
    + + + + \ No newline at end of file diff --git a/Code/will/javascript/practice/vue/todo_app/templates/todo_app/index.html b/Code/will/javascript/practice/vue/todo_app/templates/todo_app/index.html index f7a9d623..6bd01927 100644 --- a/Code/will/javascript/practice/vue/todo_app/templates/todo_app/index.html +++ b/Code/will/javascript/practice/vue/todo_app/templates/todo_app/index.html @@ -9,7 +9,9 @@ - + + +