Skip to content

Commit

Permalink
Fixed solo attribute being on project instead of projectuser
Browse files Browse the repository at this point in the history
  • Loading branch information
PukieDiederik committed Dec 17, 2023
1 parent 68e7c03 commit d732461
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2023-12-17 04:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('portfolio42_api', '0009_remove_user_intra_username'),
]

operations = [
migrations.RemoveField(
model_name='project',
name='solo',
),
migrations.AddField(
model_name='projectuser',
name='solo',
field=models.BooleanField(default=True),
),
]
4 changes: 2 additions & 2 deletions backend/portfolio42_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class Project(IntraBaseModel):
name = models.CharField(max_length=50)
description = models.TextField(max_length=2000)
exam = models.BooleanField(default=False)
solo = models.BooleanField(default=True)

users = models.ManyToManyField('User', through='ProjectUser', related_name='projects')
cursus = models.ManyToManyField('cursus', through='ProjectCursus', related_name='projects')
Expand All @@ -110,7 +109,6 @@ def update(project):
p.description = project['slug']

p.exam = project['exam']
p.solo = False # todo: REMOVE THIS
p.save()

log_update(p, created)
Expand Down Expand Up @@ -146,6 +144,7 @@ class ProjectUser(IntraBaseModel):
grade = models.IntegerField()
finished = models.BooleanField(default=False)
finished_at = models.DateTimeField()
solo = models.BooleanField(default=True)

def __str__(self):
return f"(user: {self.id_user}, project: {self.id_project})"
Expand All @@ -164,6 +163,7 @@ def update(user, projectuser):
'grade': 0})

pu.finished = projectuser['validated?'] if projectuser['validated?'] is not None else False
pu.solo = True if len(projectuser['teams'][0]['users']) == 1 else False
if pu.finished:
d = timezone.make_aware(datetime.strptime(projectuser['updated_at'], '%Y-%m-%dT%H:%M:%S.%fZ'), timezone.utc)
pu.finished_at = d
Expand Down

0 comments on commit d732461

Please sign in to comment.