diff --git a/assets/create1poll.css b/assets/create1poll.css new file mode 100644 index 0000000..e8e02cc --- /dev/null +++ b/assets/create1poll.css @@ -0,0 +1,197 @@ +@import url('https://fonts.googleapis.com/css2?family=Lobster&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Mulish:ital,wght@0,300;1,200&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@700&display=swap'); + +body { + background: linear-gradient(360deg, #2f2e41 10%, #f50057 80%); + margin: 0; + font-family: 'Mulish', sans-serif; + +} + +.navbar { + padding: 0; +} + +.navbar-brand { + font-family: 'Lobster', cursive; + font-size: 30px; + + +} + +.container-fluid { + font-family: 'Mulish', sans-serif; + font-size: 20px; + + background-color: #2f2e41; +} + +.collapse { + text-align: right; + font-weight: lighter; + +} + +.btn { + color: white; + border: 2px solid #f50057; + margin-right: 40px; + +} + +.btn:hover { + background-color: #f50057; + border: 2px solid white; +} + + +.container { + background-color: white; + max-width: 900px; + border: 2px solid red; + margin: auto; + margin-top: 20px; + + +} + +h1 { + text-align: center; + font-family: 'Lobster', cursive; + margin: 30px; + color: #3487f7; +} + +label { + margin-left: 10px; + color: #2f2e41; + font-size: 20px; +} + +.field { + margin: 10px; + padding: 2px; + +} + +.input { + display: block; + border: 2px solid rgb(114, 114, 114); + border-radius: 4px; + padding: 4px; + margin: 0px; + margin-top: 4px; + font-size: 15px; + width: 99.1%; + height: 30px; +} + +button { + margin-top: 4px; + width: 150px; + border: 2px solid #3487f7; + border-radius: 4px; + color: #3487f7; +} + +button:hover { + background-color: #f50057; + border: 2px solid white; + box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); + color: #fff; +} + +.features { + display: flex; + flex-wrap: wrap; + background-color: #2f2e41; + padding-top: 120PX; + + justify-content: center; +} + + +.box { + text-align: center; + background-color: white; + margin: 10px; + width: 300px; + height: 400px; + box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); + transition: all .4s; +} + +.box:hover { + width: 320px; + height: 420px; + +} + +.icon { + height: 100px; + margin: 40px; +} +.description{ + margin: 20px; + padding: 10px; +} + +.h{ + font-family: 'Lobster', cursive; + font-size: 20px; + color: #3487f7; + +} + + +#footer { + font-family: 'Mulish', sans-serif; + text-align: center; + line-height: 30px; + background-color: #2f2e41; + color: white; + padding-top: 100PX; +} + +#contact { + font-family: 'Lobster', cursive; + letter-spacing: 2px; + margin: auto; + background-color: #2f2e41; + padding: 30px; +} + +.cont { + background-color: #2f2e41; + color: white; + text-decoration: none; + margin-left: 30px; + padding: 20px; + font-size: 20px; + transition: all .4s; + + + +} + +.cont:hover { + font-size: 25px; + text-shadow: 0px 1px 5px black; + text-shadow: 0 0 20px #fff, 0 0 10px #f50057, 0 0 20px #f50057, 0 0 30px #ff4da6; +} + + +.aa { + padding: 10px; + +} + +a:hover { + color: white; +} +@media screen and (max-width: 800px) { + .cont{ + display: block; + } +} \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index c8c1209..dd49c34 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/polling/__pycache__/forms.cpython-39.pyc b/polling/__pycache__/forms.cpython-39.pyc index a834dea..20f83f4 100644 Binary files a/polling/__pycache__/forms.cpython-39.pyc and b/polling/__pycache__/forms.cpython-39.pyc differ diff --git a/polling/__pycache__/models.cpython-39.pyc b/polling/__pycache__/models.cpython-39.pyc index 18a6fc5..9a9c132 100644 Binary files a/polling/__pycache__/models.cpython-39.pyc and b/polling/__pycache__/models.cpython-39.pyc differ diff --git a/polling/__pycache__/urls.cpython-39.pyc b/polling/__pycache__/urls.cpython-39.pyc index ee354c3..f516355 100644 Binary files a/polling/__pycache__/urls.cpython-39.pyc and b/polling/__pycache__/urls.cpython-39.pyc differ diff --git a/polling/__pycache__/views.cpython-39.pyc b/polling/__pycache__/views.cpython-39.pyc index cfa55e7..732d655 100644 Binary files a/polling/__pycache__/views.cpython-39.pyc and b/polling/__pycache__/views.cpython-39.pyc differ diff --git a/polling/forms.py b/polling/forms.py index 059451e..224c379 100644 --- a/polling/forms.py +++ b/polling/forms.py @@ -8,7 +8,7 @@ class Meta: fields = ["Title","o1","o2","o3","o4","on1","on2","on3","on4","one_1","two_1","three_1","four_1"] class Meta: model = OpenPoll - fields = ["Title","o1","o2","o3","o4","on1","on2","on3","on4"] + fields = ["title","o1","o2","o3","o4","on1","on2","on3","on4"] diff --git a/polling/migrations/0013_auto_20210401_2048.py b/polling/migrations/0013_auto_20210401_2048.py new file mode 100644 index 0000000..c20ebba --- /dev/null +++ b/polling/migrations/0013_auto_20210401_2048.py @@ -0,0 +1,38 @@ +# Generated by Django 3.1.7 on 2021-04-01 15:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('polling', '0012_creatpoll_votes'), + ] + + operations = [ + migrations.RenameField( + model_name='openpoll', + old_name='Title', + new_name='title', + ), + migrations.AlterField( + model_name='openpoll', + name='o1', + field=models.TextField(), + ), + migrations.AlterField( + model_name='openpoll', + name='o2', + field=models.TextField(), + ), + migrations.AlterField( + model_name='openpoll', + name='o3', + field=models.TextField(), + ), + migrations.AlterField( + model_name='openpoll', + name='o4', + field=models.TextField(), + ), + ] diff --git a/polling/migrations/0014_openpoll_votes.py b/polling/migrations/0014_openpoll_votes.py new file mode 100644 index 0000000..d27a79b --- /dev/null +++ b/polling/migrations/0014_openpoll_votes.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.7 on 2021-04-03 09:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('polling', '0013_auto_20210401_2048'), + ] + + operations = [ + migrations.AddField( + model_name='openpoll', + name='votes', + field=models.IntegerField(default=0), + ), + ] diff --git a/polling/migrations/__pycache__/0013_auto_20210401_2048.cpython-39.pyc b/polling/migrations/__pycache__/0013_auto_20210401_2048.cpython-39.pyc new file mode 100644 index 0000000..93c9d8d Binary files /dev/null and b/polling/migrations/__pycache__/0013_auto_20210401_2048.cpython-39.pyc differ diff --git a/polling/migrations/__pycache__/0014_openpoll_votes.cpython-39.pyc b/polling/migrations/__pycache__/0014_openpoll_votes.cpython-39.pyc new file mode 100644 index 0000000..6f78643 Binary files /dev/null and b/polling/migrations/__pycache__/0014_openpoll_votes.cpython-39.pyc differ diff --git a/polling/models.py b/polling/models.py index ac06864..df2f74c 100644 --- a/polling/models.py +++ b/polling/models.py @@ -20,13 +20,14 @@ class CreatPoll(models.Model): class OpenPoll(models.Model): - Title = models.TextField() - o1 = models.CharField( max_length=50) - o2 = models.CharField( max_length=50) - o3 = models.CharField( max_length=50) - o4 = models.CharField( max_length=50) + title = models.TextField() + o1 = models.TextField() + o2 = models.TextField() + o3 = models.TextField() + o4 = models.TextField() on1= models.IntegerField(default=0) on2= models.IntegerField(default=0) on3= models.IntegerField(default=0) on4= models.IntegerField(default=0) + votes=models.IntegerField(default=0) diff --git a/polling/urls.py b/polling/urls.py index d8cd280..62b2ec1 100644 --- a/polling/urls.py +++ b/polling/urls.py @@ -9,5 +9,6 @@ path('pollResult//',views.pollResult,name='result'), path('Tpolls',views.Tpolls,name='Tpolls'), path('Teams',views.Teams,name="Team"), - path('Openpoll//',views.OpenPoll,name='open') + path('Openpoll//',views.OpePoll,name='open'), + path('openResult//',views.OpenResult,name='openResult') ] \ No newline at end of file diff --git a/polling/views.py b/polling/views.py index 17a21f6..806632c 100644 --- a/polling/views.py +++ b/polling/views.py @@ -7,22 +7,36 @@ def index(request): return render(request,'index.html') + +#create poll def create(request): if request.method == 'POST': - select=request.POST['polltype'] + if request.POST['polltype'] == 'preference': + select=request.POST['polltype'] + + title=request.POST['Title1'] + o1=request.POST['o1'] + o2=request.POST['o2'] + o3=request.POST['o3'] + o4=request.POST['o4'] + + create=CreatPoll(Title=title,o1=o1,o2=o2,o3=o3,o4=o4) + create.save() + + - title=request.POST['Title'] - o1=request.POST['o1'] - o2=request.POST['o2'] - o3=request.POST['o3'] - o4=request.POST['o4'] + return redirect('Tpolls') - create=CreatPoll(Title=title,o1=o1,o2=o2,o3=o3,o4=o4) - create.save() - - + else: + title=request.POST['Title1'] + o1=request.POST['o1'] + o2=request.POST['o2'] + o3=request.POST['o3'] + o4=request.POST['o4'] + create=OpenPoll(title=title,o1=o1,o2=o2,o3=o3,o4=o4) + create.save() + return redirect('Tpolls') - return redirect('Tpolls') else: form = PollForm() @@ -34,42 +48,50 @@ def create(request): return render(request,'createpoll.html',context) +#polls display def Tpolls(request): + op=OpenPoll.objects.all() o=CreatPoll.objects.all() - # objects_Open=OpenPoll.objects.all() + context={ - 'poll':o + 'poll':o, + 'poll1':op } return render(request,'Tpolls.html',context) + +#PVS poll def CreatePoll(request,poll_id): poll=CreatPoll.objects.get(pk=poll_id) if request.method == 'POST': - poll=CreatPoll.objects.get(pk=poll_id) - on1=int(request.POST['on1']) - on2=int(request.POST['on2']) - on3=int(request.POST['on3']) - on4=int(request.POST['on4']) - - if on1==1: - poll.one_1+=1 - if on2==1: - poll.two_1+=1 - if on3==1: - poll.three_1+=1 - if on4==1: - poll.four_1+=1 - - poll.votes=poll.one_1+poll.two_1+poll.three_1+poll.four_1 - poll.on1+=int(request.POST['on1']) - poll.on2+=int(request.POST['on2']) - poll.on3+=int(request.POST['on3']) - poll.on4+=int(request.POST['on4']) - poll.save() - - return HttpResponseRedirect('/pollResult/%d/'%poll.id) + if request.POST['on1'] == 0: + return HttpResponseRedirect('/Createpoll/%d/'%poll.id) + else: + poll=CreatPoll.objects.get(pk=poll_id) + on1=int(request.POST['on1']) + on2=int(request.POST['on2']) + on3=int(request.POST['on3']) + on4=int(request.POST['on4']) + + if on1==1: + poll.one_1+=1 + if on2==1: + poll.two_1+=1 + if on3==1: + poll.three_1+=1 + if on4==1: + poll.four_1+=1 + + poll.votes=poll.one_1+poll.two_1+poll.three_1+poll.four_1 + poll.on1+=int(request.POST['on1']) + poll.on2+=int(request.POST['on2']) + poll.on3+=int(request.POST['on3']) + poll.on4+=int(request.POST['on4']) + poll.save() + + return HttpResponseRedirect('/pollResult/%d/'%poll.id) context={ 'poll':poll @@ -77,6 +99,8 @@ def CreatePoll(request,poll_id): return render(request,'poll.html',context) + +#polls results def pollResult(request,poll_id): poll=CreatPoll.objects.get(pk=poll_id) @@ -106,31 +130,44 @@ def pollResult(request,poll_id): return render(request,'pollresult.html',context) +#team def Teams(request): return render(request,'team.html') -def OpenPoll(request,poll_id): - # if request.method == 'POST': - - # poll=OpenPoll.objects.get(pk=poll_id) - # on1=int(request.POST['on1']) - # on2=int(request.POST['on2']) - # on3=int(request.POST['on3']) - # on4=int(request.POST['on4']) - - - # poll.on1+=int(request.POST['on1']) - # poll.on2+=int(request.POST['on2']) - # poll.on3+=int(request.POST['on3']) - # poll.on4+=int(request.POST['on4']) - # poll.save() +#open poll +def OpePoll(request,poll_id): + poll=OpenPoll.objects.get(pk=poll_id) + if request.method == 'POST': + win=request.POST['p'] + if win == poll.o1: + poll.on1+=1 + if win == poll.o2: + poll.on2+=1 + if win == poll.o3: + poll.on3+=1 + if win == poll.o4: + poll.on4+=1 + + poll.votes=poll.on1+poll.on2+poll.on3+poll.on4 + poll.save() - # return redirect('Tpolls') - # poll=CreatPoll.objects.get(pk=poll_id) - # context={ - # 'poll':poll - # } + return HttpResponseRedirect('/openResult/%d/'%poll.id) + context={ + 'poll':poll + } return render(request,'openpoll.html',context) +def OpenResult(request,poll_id): + poll=OpenPoll.objects.get(pk=poll_id) + ar=[poll.on1,poll.on2,poll.on3,poll.on4] + arr=[poll.o1,poll.o2,poll.o3,poll.o4] + imax=ar.index(max(ar)) + Max=arr[imax] + context={ + 'win':Max, + 'poll':poll + } + return render(request,'OpenResult.html',context) + diff --git a/static/index.css b/static/index.css index 4c7dfd7..d9fb153 100644 --- a/static/index.css +++ b/static/index.css @@ -17,11 +17,14 @@ /* css for nav bar start here*/ + .navbar{ + height: 48px; + } .navbar-brand { font-family: 'Lobster', cursive; font-size: 30px; - + background: #2f2e41; } @@ -58,15 +61,15 @@ display: flex; flex-wrap: wrap; - + } #content { - padding: 50px; - padding-top: 124px; - width: 600px; + + max-width: 500px; + margin: 50px; @@ -88,6 +91,7 @@ background: rgba(255, 184, 184, 0.4); backdrop-filter: blur(10px); padding-left: 40px; + padding-right: 40px; } @@ -110,17 +114,16 @@ #poll { border-bottom: 2px solid #2f2e41; - margin: 50px; - - padding: 0; + margin-top: 100px; + margin: auto; display: flex; align-items: flex-end; justify-items: center; justify-content: center; max-height: 500px; - max-width: 600px; - min-width: 300px; + max-width: 500px; + min-width: 100px; } @@ -183,7 +186,7 @@ @keyframes size { 50% { - height: 400px; + height: 300px; } } @@ -193,8 +196,9 @@ max-height: 500px; + max-width: 200px; - margin-left: 50px; + } @@ -224,7 +228,7 @@ margin: auto; overflow: hidden; position: relative; - top: 20%; + top: 10%; width: 80vw; @@ -237,7 +241,7 @@ flex-wrap: wrap; justify-content: center; margin-top: 80px; - margin-bottom: 80px; + margin-bottom: 40px; } @@ -328,7 +332,7 @@ line-height: 36px; padding: 10px; - text-decoration: none; + text-decoration: none; transition: 0.2s ease-out; } @@ -436,26 +440,26 @@ a:hover { color: white; } - @media (max-width:600px){ + @media screen and (max-width: 800px) { + left, .main, .right { + width: 100%; /* The width is 100%, when the viewport is 800px or smaller */ + } .content{ width: 100%; justify-content: center; } #head{ + font-size: 50px; } .poll{ - + display: none; width: 1vw; } .cont{ display: block; } - - - - - } + } diff --git a/templates/OpenResult.html b/templates/OpenResult.html new file mode 100644 index 0000000..f332633 --- /dev/null +++ b/templates/OpenResult.html @@ -0,0 +1,35 @@ +{% extends 'base.html' %} + +{% block content %} +

+

Winner of poll {{poll.title}} is {{win}}, voted by {{poll.votes}} voters

+
+
+ + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/Tpolls.html b/templates/Tpolls.html index 7be9823..b8df7c4 100644 --- a/templates/Tpolls.html +++ b/templates/Tpolls.html @@ -4,7 +4,7 @@


Vote your poll and see results here(latest created polls would be on top)



-

PVS POlls

+

PVS POlls

@@ -51,18 +51,20 @@
+


+ +
+

Open POlls

+
+

- + {% endblock %} diff --git a/templates/base.html b/templates/base.html index 9913258..5c18f9b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,21 +7,35 @@ Document - + {% comment %} {% endcomment %} - + + + + + + - + -