From a20ecc740f601f2c094362603b026cfb4a76a440 Mon Sep 17 00:00:00 2001 From: Jeremiah Mauga Date: Thu, 1 Jul 2021 14:02:59 -0700 Subject: [PATCH] Jeremiah, Reno, and Shawn's Solution to Posts and Comments --- .gitignore | 1 + db.sqlite3 | Bin 0 -> 147456 bytes manage.py | 22 +++ postsncomments/__init__.py | 0 .../__pycache__/__init__.cpython-39.pyc | Bin 0 -> 186 bytes .../__pycache__/settings.cpython-39.pyc | Bin 0 -> 2389 bytes .../__pycache__/urls.cpython-39.pyc | Bin 0 -> 1077 bytes .../__pycache__/wsgi.cpython-39.pyc | Bin 0 -> 603 bytes postsncomments/asgi.py | 16 +++ postsncomments/settings.py | 127 ++++++++++++++++++ postsncomments/urls.py | 23 ++++ postsncomments/wsgi.py | 16 +++ postsncomments_app/__init__.py | 0 .../__pycache__/__init__.cpython-39.pyc | Bin 0 -> 190 bytes .../__pycache__/admin.cpython-39.pyc | Bin 0 -> 231 bytes .../__pycache__/apps.cpython-39.pyc | Bin 0 -> 490 bytes .../__pycache__/models.cpython-39.pyc | Bin 0 -> 783 bytes .../__pycache__/urls.cpython-39.pyc | Bin 0 -> 458 bytes .../__pycache__/views.cpython-39.pyc | Bin 0 -> 703 bytes postsncomments_app/admin.py | 3 + postsncomments_app/apps.py | 6 + postsncomments_app/migrations/0001_initial.py | 30 +++++ .../migrations/0002_comment_body.py | 19 +++ postsncomments_app/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-39.pyc | Bin 0 -> 958 bytes .../0002_comment_body.cpython-39.pyc | Bin 0 -> 670 bytes .../__pycache__/__init__.cpython-39.pyc | Bin 0 -> 201 bytes postsncomments_app/models.py | 11 ++ .../templates/postsncomments_app/index.html | 23 ++++ .../templates/postsncomments_app/posts.html | 19 +++ postsncomments_app/tests.py | 3 + postsncomments_app/urls.py | 11 ++ postsncomments_app/views.py | 14 ++ 33 files changed, 344 insertions(+) create mode 100644 .gitignore create mode 100644 db.sqlite3 create mode 100755 manage.py create mode 100644 postsncomments/__init__.py create mode 100644 postsncomments/__pycache__/__init__.cpython-39.pyc create mode 100644 postsncomments/__pycache__/settings.cpython-39.pyc create mode 100644 postsncomments/__pycache__/urls.cpython-39.pyc create mode 100644 postsncomments/__pycache__/wsgi.cpython-39.pyc create mode 100644 postsncomments/asgi.py create mode 100644 postsncomments/settings.py create mode 100644 postsncomments/urls.py create mode 100644 postsncomments/wsgi.py create mode 100644 postsncomments_app/__init__.py create mode 100644 postsncomments_app/__pycache__/__init__.cpython-39.pyc create mode 100644 postsncomments_app/__pycache__/admin.cpython-39.pyc create mode 100644 postsncomments_app/__pycache__/apps.cpython-39.pyc create mode 100644 postsncomments_app/__pycache__/models.cpython-39.pyc create mode 100644 postsncomments_app/__pycache__/urls.cpython-39.pyc create mode 100644 postsncomments_app/__pycache__/views.cpython-39.pyc create mode 100644 postsncomments_app/admin.py create mode 100644 postsncomments_app/apps.py create mode 100644 postsncomments_app/migrations/0001_initial.py create mode 100644 postsncomments_app/migrations/0002_comment_body.py create mode 100644 postsncomments_app/migrations/__init__.py create mode 100644 postsncomments_app/migrations/__pycache__/0001_initial.cpython-39.pyc create mode 100644 postsncomments_app/migrations/__pycache__/0002_comment_body.cpython-39.pyc create mode 100644 postsncomments_app/migrations/__pycache__/__init__.cpython-39.pyc create mode 100644 postsncomments_app/models.py create mode 100644 postsncomments_app/templates/postsncomments_app/index.html create mode 100644 postsncomments_app/templates/postsncomments_app/posts.html create mode 100644 postsncomments_app/tests.py create mode 100644 postsncomments_app/urls.py create mode 100644 postsncomments_app/views.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f7275bb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv/ diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..886b4799d72c91276893c8c3e59c186f401920cf GIT binary patch literal 147456 zcmeI5ZEPFKdB?fpt4xtAS(5k8wyYIp*=BT#xO|gn=X$5Jd1uA8be84j{NcJ?k}G*_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5A@MR@IwEvusLCB@D6#ZZy=!Hd)U#i!an_dnB^&FrT^sAx`ZgIjyIx{ZlN;%Ute!S^i!8fn_h`vFrj^>)i*2{UvZlSj zQ7qZiym2NdJ)9MGL~A3)%F`7c<$kUeK~mgOj{k{29xc+>^fxcBdFx_4d|aymf9eD5>P-hwJv9(y{Hm zn$v}%zNi)<@xgeKDTH; zvA@T2iyiqq+t7dgO26l7F1>%HPInJH{S6;${GsmX%R%qm+=7g|yFRA3#&SXFMqFs+ z?88NaywXeG8`fXjGU~d@p0cz|F`LY0Q+%M{CeyCN#BTY!1_*9Q;n~U}H;L>*P>RQe zowKavy36biO?9_WcOrG%7IRm(%~sO(XMNjigoIbyp43|FeW}?l(`D=a!eT&LjrW@` zbc<7!?r@CE zBbf$diKI@?2DsFAI@ic7j+qu*Tib$*qQT?i#A0G5K*h9^sS0|2YK){!#r>>w_G8PP z;#nv*O44WM{Ji{*1s7o295rpYf{qQBz``d-h|T0#Kh@ANpdwh{+%QRlbJ{ zQmm+FL}EF=;NyC%1ZvAgS&`2~O>3^qN}$$Uo)vi}LagJ8k7~4HsVNm|#mo#5yR(Xy zsU^PxO@0%;{;;E!M93^A9wuh9884S=H{?Ps(<7!S*J(H9Dm$jrgT!=Z-b+Q=?Wn|# zQ7lA_<_4HT{*#OyfjoRBNNnQD0GDU8;_BLV0n?6av)OTJJVy2tyXn~hD$Hg?b@AW{ zpWib$dDd)X@AW@I)eZRfB*=900@8p2!H?x zfB*=9z+oU@`}hBcp}MFe2!H?xfB*=900@8p2!H?xfB*;_N&>d`{|{yTQE3nW0T2KI z5C8!X009sH0T2KI5I773F#kUct&BQ?00@8p2!H?xfB*=900@8p2po0-c>n*f_W;x% Z1V8`;KmY_l00ck)1V8`;K;SSC_+N1-@k9Us literal 0 HcmV?d00001 diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..e741e56 --- /dev/null +++ b/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', 'postsncomments.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/postsncomments/__init__.py b/postsncomments/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/postsncomments/__pycache__/__init__.cpython-39.pyc b/postsncomments/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b8d112017e58e292edec49840f5e78bf923bc6dd GIT binary patch literal 186 zcmYe~<>g`k0v@q@2_X70h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o10gKeRZts8~NM zwJ0?=GchAKu{1qV-zBv;yClCr-@iCHu_!(uC$S_yKTkj0)zv%ROurz%xTIJ&F)u|o rIX^cyHLs)?B9sT`#>Z#oWtPOp>lIYq;;_lhPbtkwwF6oF8HgDGHBT`L literal 0 HcmV?d00001 diff --git a/postsncomments/__pycache__/settings.cpython-39.pyc b/postsncomments/__pycache__/settings.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2e748e53bb95f7c84cbc2cd82295818dda02d46c GIT binary patch literal 2389 zcmb7G&2!U66qga~X+I-Q0m*-4CHrm5{+t={+k-g~>Y>-8F!eQx~r!=K9>_j~>_ zHDxjiU@QP-!z~LfZ`myj6|1&o!O-g1NEtwU>o7E9#o*8kd^txcy z;8}*}SyVBX5pWQXGG6U@Z#Bw1ik=2HYVVgxcCzY1J}lkh4f2FLV-iYsgI)wAS4O< z5*U@bA<3Mi`jj@O)p*xQR-=J0w(`e+h|*{%wqSZj@cx|W=L@me0N#8YGQ0zB z#L4S*PH}M)M^Mcxcc<{pX+3z)CS2m|O>AcmdPe+iGqOFbg;{gZIlZ;F3q*_~mnPE8 z7{gxZLSKrzUifLKxZMA!9%J<~1 z8dc#qNS-XjpI1?6Q@S5S$but>pxm7}pg59Q*1R#pI`N2WXU*|!DiK78|1UCb8kCfb)*##)Q z0AZJk8)O9C6>JjhqF&=_TCprR^ero`gmARFWH%}TwrSO}vU4V*N0giQ^U_7z< zvaauF+luu}?zDlaK_S*Va&K!OZ>d&GQ&ce6?y8olLCsVL5ODk67rp7KbMMn$TFz*O z341WWM=OgXT~*XgdC)N|@S$0oZMCEP!bLX$k9_*ulCnyo(ga7?Blg&{QTdW=y|KSh$6~2fjN5KXe#kESgkE=Zhw+eT_*Q6vs4K%mm96$lVeAqAw=jlH{BVmq=ON_*|E z;VkoH-y7%oPa0oVgJpu zcwQy7(IS_eGhsA3e)9tDNii*EwIZgFB8uM489J#|SrKEH68Z#{g*HgZ+A#NnMnxyCjaLwSv({V#+=E5{h0>@)x*;b6Et(23c zT+8D~tl%qYx15cO`-CM+%DfXda^NMwyb;(!nWDIp3U2~t{B3J0%QPc}}y_R8a=v{!xu zcR2Ew_RtF_{sJewiHd?Hk2N!zd2i-f93LknoTHPQ>{~?0ug2Lw?clr$7as>B$(+bY z#yXlu;ce--Y|UE{foRqKejwZO;71(1)>kq=l<|!84zF*L^Vw)jb88l=pbP70WznO_ zZCQfxNGoSokoz=A#-75LkOicE33OK{v=*N=P=Qp?(#o}lzJ?8Gx)DxoQ$~~^X_kqq z(kd5TS(9a<-=3$Jq>F(lyS9ic{l(VKzLZO6(SZiP3 z-2?tfTqEn&{Q1Pr5FD}g`kf;O>x2_X70h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o10bKeRZts8~NM zwJ0?=GchAKu{1qV-zBv;yClCr-@iCHu_!(uC$S_yKTkj0)zv%ROurz%xTIJ&F)u|o wIX^cyHLs)?B9sT?#wQjO=*P!r=4F<|$LkeT-r}&y%}*)KNwou6{uziF0AoEfC;$Ke literal 0 HcmV?d00001 diff --git a/postsncomments_app/__pycache__/admin.cpython-39.pyc b/postsncomments_app/__pycache__/admin.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f8c7ef7cbc25ce4486feab3d1151e5f34f8c8976 GIT binary patch literal 231 zcmYe~<>g`kf;O>x3HCtxF^Gc(44TX@fuanW zjJH@5Q*tx&{4|-O_)@YG^V0M6lJoOQiZYXmKnAR2C}IXuVB%MTerR!OQL%njYEf!# zW@1KeVrhD!zDsIxc1eDLzJGCYVo`iRPGU)Zex81~tE+dsnSMcjaY?amVqS`Fa(-@Z oYFT5_zav_%tWd-pnh*!FS zg^5>S!k3m(EZJv&w!gD2y4@B*dENQAeZ%+D2AkqyFhJG&Xn+7sNJ>LW$vFWB*b4zB z=`#x*aIc8h_`)jUQL{D7^AnZL;%I7-O`#YJQ1vz%NkR$)yJ^V430+{w;+oxw(xuL( zDotfp>NVNZ9?V4+DIf0qRDn#ie;h}{s#IsOOu+Q=e|=o!`PgfiCg+(*CFiEaIrdeF z^*fwDRw7wtdLU<_N=hz}jn8U2*XG_yVNX<>ZysE0S?FLc3z^2^J{46Yf>WsmA$#Prb%5|BV&)5_G)!o bSvYngTl+WL(rY7Tnup6JkL<0rt?jTME3t!N literal 0 HcmV?d00001 diff --git a/postsncomments_app/__pycache__/models.cpython-39.pyc b/postsncomments_app/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ea30c0238017f88785e325eb1eaea6ec37430558 GIT binary patch literal 783 zcmZuvJ8u**5VrTd%O0RKbW}8pl-rI9p^GjTiii*?LP*;f=f=4QyX(W=lSmCMKO{ZB z#sv-4{RJv!b}!LMU}-+h!yeCkGjcS_7@nWce|@^)jQu9#@C0Z~P%Hs3;5BP_#X0F- z?KOVobM}^j55ac^f#U1nn_q?K2_ZsHwD&|1U$G+DVHQ?!7d0AGZBa|7OKHwls)jkm z4v&w<1jW8UP^{v>Do^?A062I*cop`#-|GPX}bIc%=w%cx7LGU38wz+wbQatEMP(el5%Nm-{ZrvnHvi0vBdvjMA_6zI>lD{hfasagEb+qmLY*tL_^ zv6Zw^m3*oAdcoPTba#!Z*}0o@TU=DUF-EhSlatfppsjVxwHW_))k^=GWLVy$e)8#5 W8L_V93ll`6vyq@xunpmDj~74AO?cyWn)4J2|6Jil}c6Vmej=7U4jz_+Xu8tr?Rr~ zCHP7nSUUA9F!7#`Lq+06et9qX>+k2EET+>t1mgbFpJ(4GA=lX4js%*Qu-s!vl1Qpa zM;DY5nMkIScSLfTekBVgCo+RKm-#U%c5XmT3K}L>^-|dzu*Q}?sj=DygM!0)1^v+CnoId4!AH?oL^XsfUamu=~ zRaSM4Sao8(6yK6o>fZ(S{Hb)2+NBq>N&u%uH zhcph06kHC8&^$hN59%5R+y+Yi!g>hJ2G&R={RW5-51?Xzjz~7Lh>FhvdeX?iajO5a zisNoraXSH9n?VX}ss8Zc7H>$%P*^q6?xW@|CM2{;Q&gnU3ja9tA#@K;V(&pUFVe-n vY(>8`Gq*C<*K6-0{V?f_RNBSkM(r)v=pU`~=O9~a^#X5Cbl;_Ul4rjGoJ*)3 literal 0 HcmV?d00001 diff --git a/postsncomments_app/admin.py b/postsncomments_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/postsncomments_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/postsncomments_app/apps.py b/postsncomments_app/apps.py new file mode 100644 index 0000000..1b9a530 --- /dev/null +++ b/postsncomments_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class PostsncommentsAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'postsncomments_app' diff --git a/postsncomments_app/migrations/0001_initial.py b/postsncomments_app/migrations/0001_initial.py new file mode 100644 index 0000000..075fa55 --- /dev/null +++ b/postsncomments_app/migrations/0001_initial.py @@ -0,0 +1,30 @@ +# Generated by Django 3.2.5 on 2021-07-01 19:50 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Post', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=100)), + ('body', models.CharField(max_length=1800)), + ], + ), + migrations.CreateModel( + name='Comment', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='postsncomments_app.post')), + ], + ), + ] diff --git a/postsncomments_app/migrations/0002_comment_body.py b/postsncomments_app/migrations/0002_comment_body.py new file mode 100644 index 0000000..3415f6e --- /dev/null +++ b/postsncomments_app/migrations/0002_comment_body.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.5 on 2021-07-01 20:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('postsncomments_app', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='comment', + name='body', + field=models.CharField(default=1, max_length=1800), + preserve_default=False, + ), + ] diff --git a/postsncomments_app/migrations/__init__.py b/postsncomments_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/postsncomments_app/migrations/__pycache__/0001_initial.cpython-39.pyc b/postsncomments_app/migrations/__pycache__/0001_initial.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b06a6158386ad56854368e498f3d3ebd395edc53 GIT binary patch literal 958 zcmZuw%Wl*#6m=ZWOy=40kPwIkY(TTP3wA`Ig=1~-puKPqbt=@Y zQRqT%L95#Se`^Q0x+A-BFK)&CcmOM~3fC6y5e=!W3~8_e*HOt0)81Q3cxBi@u1iBB z*fI3Q){vQ=n3Xx7Dk(|{rdy~e6>82;47X{ z1~QvQQY(t&O?O=B-m}N5@Cp&rdlrS8=*W&GZQA2wq3X1=lPej8*)AH>gji%@ZYWHQ zSMkH^fdV%V$D3Q*rjr-);>vs_>H%(Bgg`kf;O>x2_X70h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o10RKeRZts8~NM zwJ0?=GchAKu{1qV-zBv;yClCr-@iCHu_!(uC$S_yKTkj0)zv%ROurz%xTIJ&F)u|o zIX^cyHLs)?B9sT?#wQjO=;vmp7bTWt=I0gb$H!;pWtPOp>lIYq;;_lhPbtkwwF9~1 IGY~TX0N0T>p8x;= literal 0 HcmV?d00001 diff --git a/postsncomments_app/models.py b/postsncomments_app/models.py new file mode 100644 index 0000000..649dd30 --- /dev/null +++ b/postsncomments_app/models.py @@ -0,0 +1,11 @@ +from django.db import models +from django.db.models.fields import CharField + +class Post(models.Model): + title = models.CharField(max_length=100) + body = models.CharField(max_length=1800) + + +class Comment(models.Model): + post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments') + body = models.CharField(max_length=1800) diff --git a/postsncomments_app/templates/postsncomments_app/index.html b/postsncomments_app/templates/postsncomments_app/index.html new file mode 100644 index 0000000..39c5869 --- /dev/null +++ b/postsncomments_app/templates/postsncomments_app/index.html @@ -0,0 +1,23 @@ + + + + + + + Document + + +

All Posts

+ {% if post_list %} +
+ {% else %} +

No posts are available.

+ {% endif %} + + + + diff --git a/postsncomments_app/templates/postsncomments_app/posts.html b/postsncomments_app/templates/postsncomments_app/posts.html new file mode 100644 index 0000000..73f76d1 --- /dev/null +++ b/postsncomments_app/templates/postsncomments_app/posts.html @@ -0,0 +1,19 @@ + + + + + + + Document + + +

Details about Post {{ post.id }}

+

{{ post.title }}

+

{{ post.body }}

+
    + {% for comment in post.comments.all %} +
  • {{ comment.body }}
  • + {% endfor %} +
+ + \ No newline at end of file diff --git a/postsncomments_app/tests.py b/postsncomments_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/postsncomments_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/postsncomments_app/urls.py b/postsncomments_app/urls.py new file mode 100644 index 0000000..1dc9bb1 --- /dev/null +++ b/postsncomments_app/urls.py @@ -0,0 +1,11 @@ +from django import urls +from django.urls import path +from . import views +import postsncomments_app + + +app_name = "postsncomments_app" +urlpatterns = [ + path('', views.index, name="index"), + path('/posts//', views.posts, name="posts"), +] \ No newline at end of file diff --git a/postsncomments_app/views.py b/postsncomments_app/views.py new file mode 100644 index 0000000..e3625d2 --- /dev/null +++ b/postsncomments_app/views.py @@ -0,0 +1,14 @@ +from django.shortcuts import render +from .models import * + +def index(request): + post_list = Post.objects.all + print(post_list) + data = { 'post_list': post_list} + return render(request, 'postsncomments_app/index.html', data) + + +def posts(request, post_id): + post = Post.objects.get(id = post_id) + data = {'post': post} + return render(request, 'postsncomments_app/posts.html', data) \ No newline at end of file