diff --git a/README.md b/README.md index 865fbf9..c0c51cb 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,23 @@ An application to conduct online polls and surveys based on the [Django Tutorial project](https://docs.djangoproject.com/en/4.2/intro/tutorial01/), with additional features. ## Install and Run +### Run Setup.py Method -1. Install [Python 3.11.4 or later](https://www.python.org/downloads/) +Clone this repository and Run `setup.py` to install and run the project + +**Don't forget to answer the question from `setup.py` to setup the project** +```bash +git clone https://github.com/Sosokker/ku-polls +cd ku-polls +python setup.py +``` + +or run `setup.ps1` (For Windows User) + +---- + +### Manual +1. Install [Python 3.11 or later](https://www.python.org/downloads/) 2. Run these commands to clone and install requirements.txt ```bash git clone https://github.com/Sosokker/ku-polls @@ -33,8 +48,8 @@ or 4. Run these commands ```bash python manage.py migrate -python manage.py loaddata data/polls.json python manage.py loaddata data/users.json +python manage.py loaddata data/polls.json python manage.py runserver ``` @@ -83,6 +98,7 @@ python -m virtualenv .venv |tester2|aa12345678aa| |tester3|aa12345678aa| |tester4|aa12345678aa| +|novote |aa12345678aa| ## Project Documents @@ -92,5 +108,6 @@ All project documents are in the [Project Wiki](https://github.com/Sosokker/ku-p - [Requirements](https://github.com/Sosokker/ku-polls/wiki/Requirements) - [Iteration1](https://github.com/Sosokker/ku-polls/wiki/Iteration-1-Plan) - [Iteration2](https://github.com/Sosokker/ku-polls/wiki/Iteration-2-Plan) +- [Iteration3](https://github.com/Sosokker/ku-polls/wiki/Iteration-3-Plan) [django-tutorial](https://docs.djangoproject.com/en/4.2/intro/tutorial01/) diff --git a/data/polls.json b/data/polls.json index 4935eaa..d4dcbcd 100644 --- a/data/polls.json +++ b/data/polls.json @@ -4,7 +4,7 @@ "pk": 1, "fields": { "question_text": "Python vs C++, which one is better in your opinion?", - "pub_date": "2023-09-05T06:31:14Z", + "pub_date": "2023-09-11T06:31:14Z", "end_date": "2023-09-29T20:31:49Z", "short_description": "Cool kids have polls", "long_description": "No description provide for this poll.", @@ -20,7 +20,7 @@ "fields": { "question_text": "The chicken and the egg, which came first?", "pub_date": "2023-09-11T02:50:04Z", - "end_date": "2023-09-19T23:50:19Z", + "end_date": "2023-10-18T23:50:19Z", "short_description": "Cool kids have polls", "long_description": "No description provide for this poll.", "up_vote_count": 1, @@ -35,7 +35,7 @@ "fields": { "question_text": "So far so good?", "pub_date": "2023-08-03T06:50:43Z", - "end_date": "2023-11-15T19:50:53Z", + "end_date": "2023-11-28T19:50:53Z", "short_description": "Cool kids have polls", "long_description": "No description provide for this poll.", "up_vote_count": 1, @@ -50,7 +50,7 @@ "fields": { "question_text": "Do you love Django?", "pub_date": "2023-09-11T19:51:12Z", - "end_date": "2023-09-13T17:51:18Z", + "end_date": "2023-09-29T17:51:18Z", "short_description": "Cool kids have polls", "long_description": "No description provide for this poll.", "up_vote_count": 10, @@ -180,7 +180,7 @@ "model": "polls.vote", "pk": 6, "fields": { - "choice": 4, + "choice": 3, "user": 2, "question": 2 } @@ -238,5 +238,23 @@ "user": 3, "question": 2 } +}, +{ + "model": "polls.vote", + "pk": 13, + "fields": { + "choice": 6, + "user": 6, + "question": 3 + } +}, +{ + "model": "polls.sentimentvote", + "pk": 1, + "fields": { + "user": 1, + "question": 1, + "vote_types": false + } } ] diff --git a/data/users.json b/data/users.json index cc88812..5f4166d 100644 --- a/data/users.json +++ b/data/users.json @@ -4,7 +4,7 @@ "pk": 1, "fields": { "password": "pbkdf2_sha256$600000$aDh9a1PXxcXAb8z3YIjAPX$NVH24kt/wMad+0fZcCii738dfojI4vL2ffXOwNRuLz4=", - "last_login": "2023-09-12T04:02:42.758Z", + "last_login": "2023-09-14T16:45:03.576Z", "is_superuser": true, "username": "admin", "first_name": "", @@ -22,7 +22,7 @@ "pk": 2, "fields": { "password": "pbkdf2_sha256$600000$quZKLKT8Ec3TQgpdqlCkpX$o+VOOnRDLGf64qjHb239Yvsre74tPkC8hw1qH1un/hk=", - "last_login": "2023-09-12T04:22:38.555Z", + "last_login": "2023-09-14T13:22:50.921Z", "is_superuser": false, "username": "tester1", "first_name": "", @@ -40,7 +40,7 @@ "pk": 3, "fields": { "password": "pbkdf2_sha256$600000$1xGp6EDCoaljdTlSdVT1Mn$UID0Woeh8hwW7LtchH+hKzqdKTDeITTxQ/0DGvfG3CY=", - "last_login": "2023-09-11T19:57:39.303Z", + "last_login": "2023-09-12T07:09:55.381Z", "is_superuser": false, "username": "tester3", "first_name": "", @@ -58,7 +58,7 @@ "pk": 4, "fields": { "password": "pbkdf2_sha256$600000$fJJcIwAuIESYwZDBOqBv8t$YEDVCgg/xJOqAOiAdvGvvqgi1jgn1YfYHJE9yx2JWTA=", - "last_login": "2023-09-11T19:55:41.583Z", + "last_login": "2023-09-14T11:23:08.948Z", "is_superuser": false, "username": "tester2", "first_name": "", @@ -76,7 +76,7 @@ "pk": 5, "fields": { "password": "pbkdf2_sha256$600000$aHyU2gjOR6Vfsh3DBMIvQy$PZwRu+rOLc+N15DDguvy29dks6GUiN5YN/4io8b390o=", - "last_login": null, + "last_login": "2023-09-14T14:49:50.765Z", "is_superuser": false, "username": "novote", "first_name": "", @@ -88,5 +88,23 @@ "groups": [], "user_permissions": [] } +}, +{ + "model": "auth.user", + "pk": 6, + "fields": { + "password": "pbkdf2_sha256$600000$5rNKsClojvcsBqzrEmAzy5$XpeAUCrzeLG42H+8o4HBVqifKd0cQuWcEhFax/dxS5M=", + "last_login": "2023-09-14T16:44:29.087Z", + "is_superuser": false, + "username": "tester4", + "first_name": "", + "last_name": "", + "email": "", + "is_staff": false, + "is_active": true, + "date_joined": "2023-09-14T11:37:58.740Z", + "groups": [], + "user_permissions": [] + } } ] diff --git a/polls/migrations/0011_remove_vote_question.py b/polls/migrations/0011_remove_vote_question.py new file mode 100644 index 0000000..ab6c9e9 --- /dev/null +++ b/polls/migrations/0011_remove_vote_question.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.4 on 2023-09-14 12:47 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('polls', '0010_sentimentvote'), + ] + + operations = [ + migrations.RemoveField( + model_name='vote', + name='question', + ), + ] diff --git a/polls/migrations/0012_vote_question.py b/polls/migrations/0012_vote_question.py new file mode 100644 index 0000000..4b4c620 --- /dev/null +++ b/polls/migrations/0012_vote_question.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.4 on 2023-09-14 13:15 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('polls', '0011_remove_vote_question'), + ] + + operations = [ + migrations.AddField( + model_name='vote', + name='question', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='polls.question'), + ), + ] diff --git a/polls/migrations/0013_alter_vote_question.py b/polls/migrations/0013_alter_vote_question.py new file mode 100644 index 0000000..9bb9277 --- /dev/null +++ b/polls/migrations/0013_alter_vote_question.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.4 on 2023-09-14 13:15 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('polls', '0012_vote_question'), + ] + + operations = [ + migrations.AlterField( + model_name='vote', + name='question', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.question'), + ), + ] diff --git a/polls/models.py b/polls/models.py index a9c0508..10be79f 100644 --- a/polls/models.py +++ b/polls/models.py @@ -172,8 +172,8 @@ class Question(models.Model): vote.update(vote_types=True) self.save() else: - return 'already_upvoted' - return 'ok' + return False + return True def downvote(self, user): @@ -187,8 +187,8 @@ class Question(models.Model): vote.update(vote_types=False) self.save() else: - return 'already_downvoted' - return 'ok' + return False + return True class Choice(models.Model): diff --git a/polls/templates/polls/base.html b/polls/templates/polls/base.html index fc6124b..fa30709 100644 --- a/polls/templates/polls/base.html +++ b/polls/templates/polls/base.html @@ -6,10 +6,6 @@ - diff --git a/polls/templates/polls/index.html b/polls/templates/polls/index.html index d870900..fb8fdb2 100644 --- a/polls/templates/polls/index.html +++ b/polls/templates/polls/index.html @@ -3,8 +3,13 @@