mirror of
https://github.com/Rushilwiz/spaceout.git
synced 2025-04-17 18:10:17 -04:00
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from django.contrib.auth.models import User
|
|
from django.db import models
|
|
from PIL import Image
|
|
|
|
|
|
class Profile(models.Model):
|
|
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
|
# profile_pic = models.ImageField(default='./api/media/default.jpg', upload_to='profile_pics')
|
|
|
|
def __str__(self):
|
|
return f"{self.user.username}'s Profile"
|
|
|
|
# def save(self, *args, **kwargs):
|
|
# super().save(*args, **kwargs)
|
|
#
|
|
# img = Image.open(self.profile_pic.path).convert('RGB')
|
|
#
|
|
# if img.height > 300 or img.width > 300:
|
|
# size = (300, 300)
|
|
# img.thumbnail(size)
|
|
# img.save(self.profile_pic.path)
|
|
|
|
|
|
class Classroom(models.Model):
|
|
student = models.ForeignKey(
|
|
Profile, related_name="classes", on_delete=models.CASCADE
|
|
)
|
|
name = models.CharField(max_length=30)
|
|
teacher = models.CharField(max_length=30)
|
|
link = models.CharField(max_length=100)
|
|
period = models.PositiveIntegerField(blank=True)
|
|
|
|
def __str__(self):
|
|
return f"{self.student.user.username}'s Class: {self.name}"
|
|
|
|
class Meta:
|
|
ordering = ["period"]
|