Skip to content

Commit

Permalink
Merge pull request #406 from CosmosTUe/feature/update
Browse files Browse the repository at this point in the history
Update python packages
  • Loading branch information
bcvandendool authored Jun 27, 2023
2 parents 829fb0c + b99ddeb commit f490ed2
Show file tree
Hide file tree
Showing 11 changed files with 340 additions and 203 deletions.
475 changes: 303 additions & 172 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/core/forms/gmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class FileObjectForm(forms.ModelForm):
class Meta:
model = FileObject
exclude = ()
fields = ["name", "file"]


GMMFormSet = inlineformset_factory(
Expand Down
4 changes: 2 additions & 2 deletions apps/core/forms/photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class PhotoAlbumForm(forms.ModelForm):
photos = forms.ImageField(widget=forms.ClearableFileInput(attrs={"multiple": True}), required=False)
photos = forms.ImageField(widget=forms.ClearableFileInput(attrs={"allow_multiple_selected": True}), required=False)

class Meta:
model = PhotoAlbum
Expand Down Expand Up @@ -53,7 +53,7 @@ def __init__(self, *args, **kwargs):


class PhotoObjectForm(forms.ModelForm):
photo = forms.ImageField(widget=forms.ClearableFileInput(attrs={"multiple": True}), required=True)
photo = forms.ImageField(widget=forms.ClearableFileInput(attrs={"allow_multiple_selected": True}), required=True)

class Meta:
model = PhotoObject
Expand Down
6 changes: 3 additions & 3 deletions apps/core/models/gmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class FileObject(models.Model):

container = models.ForeignKey(GMM, on_delete=models.CASCADE, related_name="has_files")

def __str__(self):
return "FileObjectGMM: {" + self.name + ", " + str(self.date) + "}"

def save(self, *args, **kwargs):
user = get_current_user()
if user and not user.pk:
Expand All @@ -44,6 +47,3 @@ def save(self, *args, **kwargs):
self.created_by = user
self.modified_by = user
super(FileObject, self).save(*args, **kwargs)

def __str__(self):
return "FileObjectGMM: {" + self.name + ", " + str(self.date) + "}"
6 changes: 3 additions & 3 deletions apps/core/models/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class InternalDocument(models.Model):

file = models.FileField(null=False, blank=False, upload_to="internal/")

def __str__(self):
return "InternalDocument: {" + self.name + ", " + str(self.modified) + "}"

def save(self, *args, **kwargs):
user = get_current_user()
if user and not user.pk:
Expand All @@ -36,6 +39,3 @@ def save(self, *args, **kwargs):
self.created_by = user
self.modified_by = user
super(InternalDocument, self).save(*args, **kwargs)

def __str__(self):
return "InternalDocument: {" + self.name + ", " + str(self.modified) + "}"
14 changes: 7 additions & 7 deletions apps/core/models/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ class News(models.Model):
User, blank=True, null=True, default=None, on_delete=models.SET_NULL, related_name="author"
)

def published(self):
if self.publish_date > datetime.date.today():
return False
else:
return True
def __str__(self):
return "News: {" + self.title + ", " + str(self.publish_date) + "}"

def save(self, *args, **kwargs):
user = get_current_user()
Expand All @@ -33,5 +30,8 @@ def save(self, *args, **kwargs):
def get_absolute_url(self):
return reverse("cosmos_core:news-list")

def __str__(self):
return "News: {" + self.title + ", " + str(self.publish_date) + "}"
def published(self):
if self.publish_date > datetime.date.today():
return False
else:
return True
6 changes: 3 additions & 3 deletions apps/core/models/photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ class PhotoAlbum(models.Model):
date = models.DateField()
album_cover = models.ImageField(upload_to="photos")

def get_absolute_url(self):
return reverse("cosmos_core:photo_album-list")

def __str__(self):
return "PhotoAlbum: {" + self.title + "}"

def get_absolute_url(self):
return reverse("cosmos_core:photo_album-list")


class PhotoObject(models.Model):
photo = models.ImageField(upload_to="photos")
Expand Down
6 changes: 3 additions & 3 deletions apps/users/models/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ class Board(models.Model):
validators=[AspectRatioValidator(1.5)],
)

def __str__(self):
return f"{self.name}: {self.description}"

@property
def name(self):
return self.group.name

@property
def permissions(self):
return self.group.permissions

def __str__(self):
return f"{self.name}: {self.description}"
6 changes: 3 additions & 3 deletions apps/users/models/committee.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class Committee(models.Model):
validators=[FileExtensionValidator(["svg", "jpg", "jpeg", "png"])],
)

def __str__(self):
return f"{self.name}: {self.description}"

@property
def name(self):
return self.group.name

@property
def permissions(self):
return self.group.permissions

def __str__(self):
return f"{self.name}: {self.description}"
12 changes: 9 additions & 3 deletions apps/users/models/institution.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class Institution(models.Model):
class Meta:
abstract = True

def __str__(self):
return f"{self.username}"

@property
def username(self):
return self.profile.user.username

def __str__(self):
return f"{self.username}"


class InstitutionTue(Institution):
department = models.CharField(max_length=100, blank=False, choices=list(zip(TUE_DEPARTMENTS, TUE_DEPARTMENTS)))
Expand All @@ -29,6 +29,9 @@ class Meta:
verbose_name = "Member of TU/e"
verbose_name_plural = "Members of TU/e"

def __str__(self):
return "Institute - TU/e"


class InstitutionFontys(Institution):
study = models.CharField(max_length=100, blank=False, choices=list(zip(FONTYS_STUDIES, FONTYS_STUDIES)))
Expand All @@ -37,6 +40,9 @@ class Meta:
verbose_name = "Member of Fontys"
verbose_name_plural = "Members of Fontys"

def __str__(self):
return "Institute - Fontys"


@receiver(post_save, sender=Profile)
def profile_post_save(sender, instance: Profile, created, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions apps/users/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class Profile(models.Model):
max_length=3, verbose_name="Emails are sent to", default="TUE", choices=NEWSLETTER_RECIPIENTS
)

def __str__(self):
return f"{self.username}"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand All @@ -59,6 +62,3 @@ def institution_name(self):
elif is_fontys_email(self.username):
return "fontys"
return None

def __str__(self):
return f"{self.username}"

0 comments on commit f490ed2

Please sign in to comment.