Skip to content

Commit

Permalink
Fix: Remove limit on user's vote count
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-jy-park committed Dec 21, 2022
1 parent a41a9ba commit a5cb5ef
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 4 deletions.
151 changes: 151 additions & 0 deletions accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Generated by Django 4.1.3 on 2022-12-09 14:19

import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

dependencies = [
("auth", "0012_alter_user_first_name_max_length"),
]

operations = [
migrations.CreateModel(
name="User",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"last_login",
models.DateTimeField(
blank=True, null=True, verbose_name="last login"
),
),
(
"is_superuser",
models.BooleanField(
default=False,
help_text="Designates that this user has all permissions without explicitly assigning them.",
verbose_name="superuser status",
),
),
(
"username",
models.CharField(
error_messages={
"unique": "A user with that username already exists."
},
help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
max_length=150,
unique=True,
validators=[
django.contrib.auth.validators.UnicodeUsernameValidator()
],
verbose_name="username",
),
),
(
"first_name",
models.CharField(
blank=True, max_length=150, verbose_name="first name"
),
),
(
"last_name",
models.CharField(
blank=True, max_length=150, verbose_name="last name"
),
),
(
"is_staff",
models.BooleanField(
default=False,
help_text="Designates whether the user can log into this admin site.",
verbose_name="staff status",
),
),
(
"is_active",
models.BooleanField(
default=True,
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
verbose_name="active",
),
),
(
"date_joined",
models.DateTimeField(
default=django.utils.timezone.now, verbose_name="date joined"
),
),
("email", models.EmailField(max_length=20, unique=True)),
("password", models.CharField(max_length=100)),
("name", models.CharField(max_length=20)),
(
"part",
models.CharField(
choices=[
("Backend", "Backend"),
("Frontend", "Frontend"),
("Design", "Design"),
("PM", "PM"),
],
max_length=20,
),
),
(
"team",
models.CharField(
choices=[
("Recipeasy", "Recipeasy"),
("Forgetmenot", "Forgetmenot"),
("Prefolio", "Prefolio"),
("Diametes", "Diametes"),
("Teample", "Teample"),
],
max_length=20,
),
),
("vote_demoday", models.BooleanField(default=False)),
("vote_part", models.BooleanField(default=False)),
(
"groups",
models.ManyToManyField(
blank=True,
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
related_name="user_set",
related_query_name="user",
to="auth.group",
verbose_name="groups",
),
),
(
"user_permissions",
models.ManyToManyField(
blank=True,
help_text="Specific permissions for this user.",
related_name="user_set",
related_query_name="user",
to="auth.permission",
verbose_name="user permissions",
),
),
],
options={
"verbose_name": "user",
"verbose_name_plural": "users",
"abstract": False,
},
),
]
41 changes: 41 additions & 0 deletions demoday/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 4.1.3 on 2022-12-09 14:19

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="Team",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"team_name",
models.CharField(
choices=[
("RECIPEASY", "RECIPEASY"),
("TEAMPLE", "TEAMPLE"),
("FORGET_ME_NOT", "FORGET_ME_NOT"),
("PREFOLIO", "PREFOLIO"),
("DIAMETES", "DIAMETES"),
],
max_length=20,
),
),
("vote_count", models.IntegerField(default=0)),
],
),
]
27 changes: 27 additions & 0 deletions demoday/migrations/0002_alter_team_team_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.1.3 on 2022-12-21 14:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("demoday", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="team",
name="team_name",
field=models.CharField(
choices=[
("Recipeasy", "Recipeasy"),
("Forgetmenot", "Forgetmenot"),
("Prefolio", "Prefolio"),
("Diametes", "Diametes"),
("Teample", "Teample"),
],
max_length=20,
),
),
]
4 changes: 2 additions & 2 deletions demoday/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def get(self, request):
def post(self, request):
user = User.objects.filter(id=request.user.id)[0]

if user.vote_demoday:
return Response({'Message': 'No more vote count'}, status=status.HTTP_400_BAD_REQUEST)
# if user.vote_demoday:
# return Response({'Message': 'No more vote count'}, status=status.HTTP_400_BAD_REQUEST)

if(request.data['team_name'] == request.user.team):
return Response({'Message': 'You are not allowed to vote on your own team'}, status=status.HTTP_400_BAD_REQUEST)
Expand Down
35 changes: 35 additions & 0 deletions partleads/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 4.1.3 on 2022-12-09 14:19

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="Candidate",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=20)),
(
"position",
models.CharField(
choices=[("FE", "FRONTEND"), ("BE", "BACKEND")], max_length=2
),
),
("vote_count", models.IntegerField(default=0)),
],
),
]
18 changes: 18 additions & 0 deletions partleads/migrations/0002_alter_candidate_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.3 on 2022-12-20 10:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("partleads", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="candidate",
name="id",
field=models.AutoField(primary_key=True, serialize=False),
),
]
16 changes: 16 additions & 0 deletions partleads/migrations/0003_rename_id_candidate_candidate_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.1.3 on 2022-12-20 10:55

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("partleads", "0002_alter_candidate_id"),
]

operations = [
migrations.RenameField(
model_name="candidate", old_name="id", new_name="candidate_id",
),
]
16 changes: 16 additions & 0 deletions partleads/migrations/0004_rename_candidate_id_candidate_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.1.3 on 2022-12-20 11:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("partleads", "0003_rename_id_candidate_candidate_id"),
]

operations = [
migrations.RenameField(
model_name="candidate", old_name="candidate_id", new_name="id",
),
]
20 changes: 20 additions & 0 deletions partleads/migrations/0005_alter_candidate_position.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.1.3 on 2022-12-21 15:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("partleads", "0004_rename_candidate_id_candidate_id"),
]

operations = [
migrations.AlterField(
model_name="candidate",
name="position",
field=models.CharField(
choices=[("Frontend", "Frontend"), ("Backend", "Backend")], max_length=8
),
),
]
4 changes: 2 additions & 2 deletions partleads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def get(self, request):
def post(self, request):
user = User.objects.filter(id=request.user.id)[0]

if(user.vote_part):
return Response({'Message': 'No more vote count'}, status=status.HTTP_400_BAD_REQUEST)
# if(user.vote_part):
# return Response({'Message': 'No more vote count'}, status=status.HTTP_400_BAD_REQUEST)

serializer = CandidateSerializer(data=request.data)
if(serializer.is_valid()):
Expand Down

0 comments on commit a5cb5ef

Please sign in to comment.