Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed solo attribute being on project instead of projectuser #64

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading