joeni

Add communication app to tracker

Author
Maarten 'Vngngdn' Vangeneugden
Date
Nov. 14, 2017, 8:45 p.m.
Hash
697d3594d74c3d7a19ad27b7f54e4b7a794c2176
Parent
791db7966d80d583c110575799cb3ac58707d91b
Modified files
communication/__init__.py
communication/admin.py
communication/apps.py
communication/migrations/__init__.py
communication/models.py
communication/tests.py
communication/views.py

communication/__init__.py

0 additions and 0 deletions.

View changes Hide changes

communication/admin.py

3 additions and 0 deletions.

View changes Hide changes
+
1
+
2
# Register your models here.
+
3

communication/apps.py

5 additions and 0 deletions.

View changes Hide changes
+
1
+
2
+
3
class CommunicationConfig(AppConfig):
+
4
    name = 'communication'
+
5

communication/migrations/__init__.py

0 additions and 0 deletions.

View changes Hide changes

communication/models.py

40 additions and 0 deletions.

View changes Hide changes
+
1
from django.utils.translation import ugettext_lazy as _
+
2
from joeni import constants
+
3
+
4
class Account(models.Model):
+
5
    user = models.OneToOneField(
+
6
        'joeni.User',
+
7
        on_delete=models.CASCADE,
+
8
        )
+
9
    alias = models.CharField(
+
10
        max_length=64,
+
11
        unique=True,
+
12
        default=username())  # TODO: Create function to extract username from foreign key
+
13
+
14
def account_user_directory(instance, filename):
+
15
    return '{0}/account/settings/{1}'.format(instace.account.alias, filename)
+
16
+
17
class AccountSettings(models.Model):
+
18
    account = models.OneToOneField(
+
19
        'Account',
+
20
        on_delete=models.CASCADE,
+
21
        )
+
22
    primary_color = models.CharField(
+
23
        max_length=6,
+
24
        help_text=_("The hexadecimal code of the primary color for this account."),
+
25
        default = constants.COLORS["UHasselt default"],
+
26
        )
+
27
    """secondary_color = models.CharField(
+
28
        max_length=6,
+
29
        help_text=_("The hexadecimal code of the secondary color for this account."),
+
30
        )"""
+
31
    # We're gonna leave the secondary color out for now.
+
32
    account_page_banner = models.ImageField(  # Requires the Pillow library!
+
33
        upload_to=account_user_directory,
+
34
        help_text=_("The banner image to be shown on this account's homepage."),
+
35
        )
+
36
    avatar = models.ImageField(
+
37
        upload_to=account_user_directory,
+
38
        help_text=_("The avatar image of this account."),
+
39
        )
+
40

communication/tests.py

3 additions and 0 deletions.

View changes Hide changes
+
1
+
2
# Create your tests here.
+
3

communication/views.py

3 additions and 0 deletions.

View changes Hide changes
+
1
+
2
# Create your views here.
+
3