24 lines
684 B
Python
24 lines
684 B
Python
|
from django.conf import settings
|
||
|
from django.contrib.auth.models import User
|
||
|
from django.db import models
|
||
|
import pytz
|
||
|
|
||
|
|
||
|
# GENERAL Methods and Classes
|
||
|
#
|
||
|
def get_userprofile(user):
|
||
|
try:
|
||
|
profile = user.userprofile
|
||
|
except UserProfile.DoesNotExist:
|
||
|
profile = UserProfile(user=user)
|
||
|
profile.save()
|
||
|
return profile
|
||
|
|
||
|
|
||
|
# USERPROFILE Model
|
||
|
#
|
||
|
class UserProfile(models.Model):
|
||
|
user = models.OneToOneField(User, unique=True, on_delete=models.CASCADE)
|
||
|
timezone = models.CharField(max_length=150, default='UTC', choices=[(t, t) for t in pytz.common_timezones])
|
||
|
language_code = models.CharField(max_length=150, default='en', choices=settings.LANGUAGES)
|