From ac1f869c94558d3095fb4104afb0d6071955145e Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Thu, 2 Jul 2020 12:31:58 +1000 Subject: [PATCH] initial commit, up to part 4/5 --- mysite/db.sqlite3 | Bin 0 -> 143360 bytes mysite/manage.py | 22 ++++ mysite/mysite/__init__.py | 0 .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 144 bytes .../__pycache__/settings.cpython-37.pyc | Bin 0 -> 2278 bytes mysite/mysite/__pycache__/urls.cpython-37.pyc | Bin 0 -> 986 bytes mysite/mysite/__pycache__/wsgi.cpython-37.pyc | Bin 0 -> 546 bytes mysite/mysite/settings.py | 121 ++++++++++++++++++ mysite/mysite/urls.py | 22 ++++ mysite/mysite/wsgi.py | 16 +++ mysite/polls/__init__.py | 0 .../polls/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 143 bytes mysite/polls/__pycache__/admin.cpython-37.pyc | Bin 0 -> 258 bytes mysite/polls/__pycache__/apps.cpython-37.pyc | Bin 0 -> 357 bytes .../polls/__pycache__/models.cpython-37.pyc | Bin 0 -> 1229 bytes mysite/polls/__pycache__/urls.cpython-37.pyc | Bin 0 -> 453 bytes mysite/polls/__pycache__/views.cpython-37.pyc | Bin 0 -> 1504 bytes mysite/polls/admin.py | 4 + mysite/polls/apps.py | 5 + mysite/polls/migrations/0001_initial.py | 32 +++++ mysite/polls/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-37.pyc | Bin 0 -> 993 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 154 bytes mysite/polls/models.py | 24 ++++ mysite/polls/templates/polls/detail.html | 13 ++ mysite/polls/templates/polls/index.html | 9 ++ mysite/polls/templates/polls/result.html | 9 ++ mysite/polls/tests.py | 3 + mysite/polls/urls.py | 11 ++ mysite/polls/views.py | 31 +++++ 30 files changed, 322 insertions(+) create mode 100644 mysite/db.sqlite3 create mode 100755 mysite/manage.py create mode 100644 mysite/mysite/__init__.py create mode 100644 mysite/mysite/__pycache__/__init__.cpython-37.pyc create mode 100644 mysite/mysite/__pycache__/settings.cpython-37.pyc create mode 100644 mysite/mysite/__pycache__/urls.cpython-37.pyc create mode 100644 mysite/mysite/__pycache__/wsgi.cpython-37.pyc create mode 100644 mysite/mysite/settings.py create mode 100644 mysite/mysite/urls.py create mode 100644 mysite/mysite/wsgi.py create mode 100644 mysite/polls/__init__.py create mode 100644 mysite/polls/__pycache__/__init__.cpython-37.pyc create mode 100644 mysite/polls/__pycache__/admin.cpython-37.pyc create mode 100644 mysite/polls/__pycache__/apps.cpython-37.pyc create mode 100644 mysite/polls/__pycache__/models.cpython-37.pyc create mode 100644 mysite/polls/__pycache__/urls.cpython-37.pyc create mode 100644 mysite/polls/__pycache__/views.cpython-37.pyc create mode 100644 mysite/polls/admin.py create mode 100644 mysite/polls/apps.py create mode 100644 mysite/polls/migrations/0001_initial.py create mode 100644 mysite/polls/migrations/__init__.py create mode 100644 mysite/polls/migrations/__pycache__/0001_initial.cpython-37.pyc create mode 100644 mysite/polls/migrations/__pycache__/__init__.cpython-37.pyc create mode 100644 mysite/polls/models.py create mode 100644 mysite/polls/templates/polls/detail.html create mode 100644 mysite/polls/templates/polls/index.html create mode 100644 mysite/polls/templates/polls/result.html create mode 100644 mysite/polls/tests.py create mode 100644 mysite/polls/urls.py create mode 100644 mysite/polls/views.py diff --git a/mysite/db.sqlite3 b/mysite/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..76f833317159cdb7bd7c592bacb79e9d8ffade33 GIT binary patch literal 143360 zcmeI5du$s=e#du3QY0;sqlab2v1L(`6`N3GFPAS-Nt(!xEX%g&*pVMHF5NE46-AjZ zlay@biUM?;yW+0xA3gMd9?+&JP_#w+M|&-Be_ZoNQxxg@isG)owRc5Z6i6SqyY_%y z{^%9x%=qtQ7jI^+_@rWfj3yQ}VUSR#hphB~2-*_mrYm z&NnuCI*BHwXk;lsom?}VNGZd~R-Jk(s`bXc97zc&nmFgDj$St%&Dk9>Z~G85HdXP^;-c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l-foWDRjsAW_yWlgOFTV7jUz9(40%SDX>LetD=@4VFm!elFtpkWgokK> znYfDy?yzQ}?WRWuspRky`|G3qzY}VTfYUXZ_S- zY}(1hnAuDPyFTWlc@tp=zk9w`*{Zf~&tsDVG=F;5VcfrEVF=J|4(K+9f|iXTfya+} zsm=Ha2h-3pU?OsxtSQmmxs-PH1Qvd_?CWiVSql$H2=ziw?Pvoe^q zA9W3Z`IK1Bf0Y;-Spa1{> literal 0 HcmV?d00001 diff --git a/mysite/manage.py b/mysite/manage.py new file mode 100755 index 0000000..afbc784 --- /dev/null +++ b/mysite/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/mysite/mysite/__init__.py b/mysite/mysite/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mysite/mysite/__pycache__/__init__.cpython-37.pyc b/mysite/mysite/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..caa798b6093d64281bb2f0773497dc54cadf9d3b GIT binary patch literal 144 zcmZ?b<>g`kg1qe?;z0Cc5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6vKKO;XkRX;H= zvp7S)w75t=CACaHB`Yy6JzqB^H8)>Bx3W01Bo#)*$7kkcmc+;F6;$5hu*uC&Da}c> K0~z@lh#3G2Vk15P literal 0 HcmV?d00001 diff --git a/mysite/mysite/__pycache__/settings.cpython-37.pyc b/mysite/mysite/__pycache__/settings.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fe3c765b9081203cea7f08326c657ff20ab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h+ z18uLC=+|o%B`K3wIP$3%&sG&(Nt|o(O{Js1GTVx#9klkV<{PD6LtzVRY@x0+_d3d+ zYF1iR6=7=))ihdI7Nrh`UE6rp98&d-^=4d1c)Ec*(a}>SiRQOVa2HD_o&MR8`@TzL z%cHC>hb)kRd>Hlg8W7i)hvhr|jQ_i&!AV^D!Sx|@$n!ZwV>(Vku9Ux16!Jn&DCDwd hqad8oxojaX4A;3acd;N86MCs!$S0#*LWJQc{0sIC0E_?t literal 0 HcmV?d00001 diff --git a/mysite/mysite/__pycache__/urls.cpython-37.pyc b/mysite/mysite/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e10d51868f8f6c609d9a76d98d5262fa820b764b GIT binary patch literal 986 zcma)5&5qMB5O#jL?S@_0NALkDjns`P5|?U0z={n z$NbV0e&&lH3p}?E%24#Oo`<;4LLRW*#@qOyAMoDlVAbFF3qKpM{zsGy=-Nj}tW9A# z{`}z`K38&HENV?{p=1<&T5^0<>$0NOaxKjjE(>F^R<-5EIT&mezA5+@li~}du~3@h zLe7;IEd;JgP7TL~^GSqZEv>E0gb=23ld=_+3sq^g;<-(8B?y;foQ}uDs;bBhan=Ol z8xp{ZBfT5e#IE35*MOU+D2VUBm(-ZkYsii5;r@?@vP-TVm9(u@N9ZkJwfyhR z$9bgG%pA-xxx?vF=4H(axqw2n5nXyYbhN9{Wm_B!WS~dRmJbs=-<5N+E!nmw&f&0v7u1Aq;+xPV*gOE)4fr>t z51pqIf1VN7Y(iyWmZUbCFn&X}Xs3(|MYa#8`#G?*S~r6;p;%q=7monM3_yh5iFXtn Gd4B=z&og@f literal 0 HcmV?d00001 diff --git a/mysite/mysite/__pycache__/wsgi.cpython-37.pyc b/mysite/mysite/__pycache__/wsgi.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9840dbab529ada3f4b4d148b4fbd1a3feca8d461 GIT binary patch literal 546 zcmYk3zi$&U6vur|+C&Eh2E^<&5h`M#^zqcB*~1( zL{gp1lGt}NHJw=}A&{)PKMrJ99{i-S>U<-!LrJG(aCq}8{WKkoS%G$;O18k7nXOYE zSXJW+3ZJFv*faQAp##VK5?H%mXf3{IV8SuM49c~JV+|Y7Y$Iy5Te8A{Wb?VGDy<6P z725ec>b-AFum+}V^fS8!hBk^T#}-P%bLIfjrT3M4#ks`7WpX8KiF>934F}7I*>K30 zcWlJ~cgg`kf=k;!#DVC?AOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;!H8enx(7s(xZ# zW^smoX>pN$N@|&YN>*ZCdcJN-YHq%MZe?+1NveK9eojuYetdjpUS>&ryk0@&Ee@O9 Q{FKt1R6CG~pMjVG02l}(FaQ7m literal 0 HcmV?d00001 diff --git a/mysite/polls/__pycache__/admin.cpython-37.pyc b/mysite/polls/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c7dbf5fc4861ace87313e3796a068911a1a4f0a0 GIT binary patch literal 258 zcmXv|J5Iwu5Z&?Gk%bb@feW$~9YTl$L_%~fkPI_QHrh|LV@GnCn}m`>a1pmu>8Yrg zO~jMt^G0vx&C_CWr37DxpVv|9cP9VP(mYD=jU-eEPI+hn6c(sm;dQG)5p2t2MfxMp z%NNyDCsC^grm914!wD{|ejbQ>8^fxZwb!`q!a6SBW9XB8OND5rnU6@0Q<+K0wx_91 zw6@$+`c$cw@j3n8nN9R$x?p)@22KWPZ!Q;ak$g0M%-d!conv$UV!0cq`d$nMM-TZU J&MtG97k_9GLdF09 literal 0 HcmV?d00001 diff --git a/mysite/polls/__pycache__/apps.cpython-37.pyc b/mysite/polls/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..429cbd05f276d88fb2f570788f4535898bd98181 GIT binary patch literal 357 zcmYLEu}%Xq40SG7=~`NePhh=)X6cAffq|_;LM%5lI^ncElw87vL+T7a!x!)$j9Ho3 zn3-^LR9Nz}o#$sem$TUf$Ufe`*LM^@V{x#Yk|nu6AwWQ;!LW)kxCYFSzXEc_UU-#Z zehcO3i@Km>VSM4-m2Ef8_CCHGj8U>A_s0YZDuzHxR&mTo&BM`+)!GljYUEsN2TxMDII+>RI4J-EQqEDr1G& z`{qfBv_{m<`MKM7ob>V2J|iets#o!}K{=0oUE~t;zi!CJM1fgc5Z$%o*iMsDl@C>L;hF=r#DPkkf*ayD?3Gh*oH;RLJ5ei@m3BOyUC+FE^O9%1UWeiO`Qy)rZw_O>>1DoJ=xpNF zFVRRQdB$=cb56dKIkAIJH*@n=+~Vv7lP&3eWzqva@xHim8zXJ$W5jPFzI1k3Ke)tf ztj}#bFC}Dph;Crg98SvuMszk`E;^gI^oZ1!jz!oQoUY8VuQ!L+0D5?*0(c)C0%-WTbHU7loi+B! zL(uNEi1g?CJvS;&|Ba*g%LP$w3I)5dzztX5@E;IGiR~eWIvc8xF>a+DRdk%BT033R}_yyFB;6&+zNeGij?uPyq96;Am6zvB#tbYRQa<2lSR;v6> oaB9*_*IM-6&_6J5Qgo2Ws}_`5<)`a1}TUeDilSCj)sPAg@{%fD{Opp-94Un%(K0IfFnVN@@g6g<3HMQ3y44;FA&56h zzFHr*jn>vPAFCSV8%5P+C3j~tRlA#)PFkm$dZA!0d;-#yO7AXDeMZ_&JBu*~Yj<%P zvuT_ZKBDVkGVmF!%X-;NJEN@$uqcy|L?}Kj+jc>9m>#|LNobTNBX5RZuoWjwZ9kY9 zlY`{vTCAE%in3OAB|2*a$c;FpxdK@=qS{)8Mf~+FDDkx2`gB$`&}liR$=Dnv5Aq-i HMx6F92Ag~h literal 0 HcmV?d00001 diff --git a/mysite/polls/__pycache__/views.cpython-37.pyc b/mysite/polls/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ff3ed69585775e9faed50da63339d1f9237184b1 GIT binary patch literal 1504 zcmbtU&u=3&6t+E{$t0OHDHP};4m}{TbJ%7Ni;xgP2v`XTRA7q)%z@D~_BNCC#KCq- z6Q!qxY|0-Fu7WSt%+f zuVdKi2jAbgFI8>bdbH3=*>MelT^>(eqjGNW5`3o((E3yx09u}{3|;|53V?$TlZAB? zJ$Lfb{X)z>^#6Q&Jk^aHSM%CV$4hI*LSBr;teT(edqOsP+^lTv6ZaK&!gI+_#H{qEf4EX+bMOh2;3NFFm+Ug}-khJ~=U|YN!LNjV!gZ6*G zH3zVNi`PiIR4(8R0R9WAc@;MOJH*xn0>6cLxC;@1ci|6=Zot@Obal94Gd2S`&A0%G z0nhX*`kKt|a^hl_%sP+Rlb-pE68u~W`~&-fi}>dtzHi7T;$+qp$vcFRvb%|%_g>)2 zzRN@hd=DN|kv?Nj=_%wdh_wqh7AWw^WUA|l+)}Y~b?eu^)ypGMi}_pb$VvstbW|O+ z%X1cJ@B?WKq-7(mtGp<-VGCJ`vOVpe zs^aJiz|`M6mPXkYd(vnjp@R=W$ibj&gW3rgc3_9J2pN&S2fLO^zK_pV Qz&`@y8Gcb3r#$6<0n%V$6951J literal 0 HcmV?d00001 diff --git a/mysite/polls/admin.py b/mysite/polls/admin.py new file mode 100644 index 0000000..5832a6d --- /dev/null +++ b/mysite/polls/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Question +# Register your models here. +admin.site.register(Question) diff --git a/mysite/polls/apps.py b/mysite/polls/apps.py new file mode 100644 index 0000000..d0f109e --- /dev/null +++ b/mysite/polls/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PollsConfig(AppConfig): + name = 'polls' diff --git a/mysite/polls/migrations/0001_initial.py b/mysite/polls/migrations/0001_initial.py new file mode 100644 index 0000000..f28d63f --- /dev/null +++ b/mysite/polls/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 3.0.7 on 2020-06-22 14:12 + +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.AutoField(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.AutoField(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/mysite/polls/migrations/__init__.py b/mysite/polls/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mysite/polls/migrations/__pycache__/0001_initial.cpython-37.pyc b/mysite/polls/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d37e6f677a61461384f2dc8974a0e93bf74e8acf GIT binary patch literal 993 zcmZuwOK;Oa5caN}*v_jD3J6XdxEP5zh$})ZDXl8hN{F6(z;ZHEXN@1}+Nqje;hO&e z|A8OCZ`doR-Z*n&)=sF9SZl}g?cLEaL%Z8uQc)tYZUAu)Y{zAxm1H&7cMRgWKcsoGfqn3iW# zJ-2CHa`vg0U&){mFfalREHGmuu&|Z1frE*5;sB%1f)=z_)&&Qf#$0f~T`@u(LLKNr zPovm`{)*Ro2mjr>_0QgILS5K_-J0nhp&s^=L1HIc$u{i4{S_xpOLN9N*ntOB-$Uh| zZVEeB&ie(Hx<synU!HL+@46&03}HT*WRI2I$&M^nfr-A}=3aq;0TANdSDWs`K z+yj#ANawBG@hp;!+drg2&qam}?49Hl#<-sB92F8poWCPk+mJ+gTqq6`<g8iH4!5{vS&Z{NHeh?^#v8DDo!3@w6JrRIT8~D8M}G&0&1)HM f3XxBB#yZAb?v3}1#+37_IfB<($x<)dW{&v>wuc~( literal 0 HcmV?d00001 diff --git a/mysite/polls/migrations/__pycache__/__init__.cpython-37.pyc b/mysite/polls/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8005e44c77e81fdc09ea10b80b321b4772ead9d4 GIT binary patch literal 154 zcmZ?b<>g`kf=k;!#DVC?AOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;!Hsenx(7s(xZ# zW^smoX>pN$N@|&YN>*ZCdcJN-YHq%MZe?+1NveK9eojuYer{%ZQDRAEeqOPDe0*kJ bW=VX!UP0w84x8Nkl+v73JCNa@ftUdR+RP`X literal 0 HcmV?d00001 diff --git a/mysite/polls/models.py b/mysite/polls/models.py new file mode 100644 index 0000000..598052f --- /dev/null +++ b/mysite/polls/models.py @@ -0,0 +1,24 @@ +from django.db import models +import datetime +from django.utils import timezone + +# Create your models here. +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 wasRecent(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/mysite/polls/templates/polls/detail.html b/mysite/polls/templates/polls/detail.html new file mode 100644 index 0000000..0c4fa5b --- /dev/null +++ b/mysite/polls/templates/polls/detail.html @@ -0,0 +1,13 @@ +

{{ question }}

+ +{% if error_message %}

{{ error_message }}

{% endif %} + +
+ {% csrf_token %} + {% for choice in question.choice_set.all %} + + +
+ {% endfor %} + +
diff --git a/mysite/polls/templates/polls/index.html b/mysite/polls/templates/polls/index.html new file mode 100644 index 0000000..de92577 --- /dev/null +++ b/mysite/polls/templates/polls/index.html @@ -0,0 +1,9 @@ +{% if question_list %} + +{% else %} +

No Polls available.

+{% endif %} diff --git a/mysite/polls/templates/polls/result.html b/mysite/polls/templates/polls/result.html new file mode 100644 index 0000000..74cf879 --- /dev/null +++ b/mysite/polls/templates/polls/result.html @@ -0,0 +1,9 @@ +

{{ question }}

+ +
    +{% for choice in question.choice_set.all %} +
  • {{ choice.choice_text }} -- {{ choice.votes }} vote{{choice.votes|pluralize}}
  • +{% endfor %} +
+ +Vote again? diff --git a/mysite/polls/tests.py b/mysite/polls/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/mysite/polls/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/mysite/polls/urls.py b/mysite/polls/urls.py new file mode 100644 index 0000000..06524e9 --- /dev/null +++ b/mysite/polls/urls.py @@ -0,0 +1,11 @@ +from django.urls import path + +from . import views + +app_name = 'polls' +urlpatterns = [ + path('', views.index, name='index'), + path('/', views.detail, name='detail'), + path('/results/', views.result, name='result'), + path('/vote/', views.vote, name='vote') +] diff --git a/mysite/polls/views.py b/mysite/polls/views.py new file mode 100644 index 0000000..9905f27 --- /dev/null +++ b/mysite/polls/views.py @@ -0,0 +1,31 @@ +from django.shortcuts import render, get_object_or_404 +from django.http import HttpResponse, Http404, HttpResponseRedirect +from django.template import loader +from django.urls import reverse +from .models import Question + +# Create your views here. +def index(request): + question_list = Question.objects.order_by('-pub_date')[:5] + context = { 'question_list': question_list } + return render(request, 'polls/index.html', context) + +def detail(request, question_id): + question = get_object_or_404(Question, pk=question_id) + return render(request, 'polls/detail.html', {'question': question}) + +def result(request, question_id): + question = get_object_or_404(Question, pk=question_id) + return render(request, 'polls/result.html', {'question': question}) + +def vote(request, question_id): + question = get_object_or_404(Question, pk=question_id) + try: + selected_choice = question.choice_set.get(pk=request.POST['choice']) + except(KeyError, choice.DoesNotExist): + return render(request, 'polls/detail.html', {"question": question, "error_message": "You didn't select a choice",}) + else: + selected_choice.votes += 1 + selected_choice.save() + return HttpResponseRedirect(reverse('polls:result', args=(question.id, ))) +