[profiles] Add user profile context override

This commit is contained in:
2025-04-02 22:13:43 -04:00
parent 23d3e19db9
commit 0cc87a2dbe
4 changed files with 636 additions and 2 deletions

View File

@ -1,8 +1,8 @@
from datetime import timedelta
import pytz
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models
from django.utils.functional import cached_property
from django_extensions.db.models import TimeStampedModel
from encrypted_field import EncryptedField
from profiles.constants import PRETTY_TIMEZONE_CHOICES
@ -29,6 +29,8 @@ class UserProfile(TimeStampedModel):
archivebox_password = EncryptedField(**BNULL)
archivebox_url = models.CharField(max_length=255, **BNULL)
task_context_tags_str = models.CharField(max_length=255, **BNULL)
bgg_username = models.CharField(max_length=255, **BNULL)
lichess_username = models.CharField(max_length=255, **BNULL)
@ -52,3 +54,15 @@ class UserProfile(TimeStampedModel):
@property
def tzinfo(self):
return pytz.timezone(self.timezone)
@cached_property
def task_context_tags(self) -> list:
tag_list = [
t.strip().capitalize()
for t in self.task_context_tags_str.split(",")
]
if not tag_list:
tag_list = settings.DEFAULT_TASK_CONTEXT_TAG_LIST
return tag_list