university.py 762 Bytes
Newer Older
1
from django.db import models
2

3
from rex.utils.friendly_path import friendly_path
Florent Chehab's avatar
Florent Chehab committed
4
from rex.models.university.campus import MainCampus
5

Florent Chehab's avatar
Florent Chehab committed
6
7
path_and_rename = friendly_path("uploads/universities/logos/", 'name')

8
9

class University(models.Model):
10
11
12
    """
    Model storing information about universities
    """
13
    name = models.CharField(max_length=200)
14
    acronym = models.CharField(max_length=20)
Florent Chehab's avatar
linting  
Florent Chehab committed
15
16
    logo = models.ImageField(upload_to=path_and_rename, max_length=250,
                             default='path/to/my/default/image.jpg')  # TODO CHANGE !
17

Florent Chehab's avatar
Florent Chehab committed
18
19
    main_campus = models.OneToOneField(
        MainCampus, on_delete=models.PROTECT, related_name='main_campus_of')
20

21
22
    def location(self):
        return self.main_campus.location()  # pylint: disable=E1101