Skip to content

Commit

Permalink
fix: makeTeacher command
Browse files Browse the repository at this point in the history
  • Loading branch information
BramMeir authored and EwoutV committed Apr 9, 2024
1 parent 00a9254 commit c7e2452
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/api/management/commands/makeTeacher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.core.management.base import BaseCommand
from api.models.student import Student
from authentication.models import User
from api.models.teacher import Teacher


Expand All @@ -12,10 +12,10 @@ def add_arguments(self, parser):

def handle(self, *args, **options):
username = options['username']
student = Student.objects.filter(username=username)
if student.count() == 0:
user = User.objects.filter(username=username)
if user.count() == 0:
self.stdout.write(self.style.ERROR('User not found, first log in !'))
return
student = student.get()
Teacher.objects.create(id=student.id, create_time=student.create_time)
user = user.get()
Teacher(user_ptr=user).save_base(raw=True)
self.stdout.write(self.style.SUCCESS('Successfully made the user teacher!'))

0 comments on commit c7e2452

Please sign in to comment.