Implement profiles
This commit is contained in:
parent
26e5773271
commit
2e4099f16f
@ -1,10 +1,25 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.signals import user_logged_in
|
||||
from django.dispatch import receiver
|
||||
from django.contrib.auth.models import User
|
||||
from django.conf import settings
|
||||
from django.db.models.signals import post_save, pre_save
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from lang.models import Language
|
||||
|
||||
class Profile(models.Model):
|
||||
user = models.ForeignKey(User, unique = True)
|
||||
language = models.CharField(verbose_name=_(u"Interface Language"),
|
||||
max_length=10, choices=settings.LANGUAGES)
|
||||
languages = models.ManyToManyField(Language)
|
||||
secondary_languages = models.ManyToManyField(Language, related_name = 'secondary_profile_set')
|
||||
|
||||
|
||||
@receiver(user_logged_in)
|
||||
def set_lang(sender, **kwargs):
|
||||
lang_code = kwargs['user'].get_profile().language
|
||||
kwargs['request'].session['django_language'] = lang_code
|
||||
|
||||
def create_profile_callback(sender, **kwargs):
|
||||
'''
|
||||
|
@ -126,6 +126,7 @@ INSTALLED_APPS = (
|
||||
'registration',
|
||||
'trans',
|
||||
'lang',
|
||||
'accounts',
|
||||
)
|
||||
|
||||
|
||||
@ -193,3 +194,5 @@ SITE_TITLE = 'Weblate'
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
|
||||
ACCOUNT_ACTIVATION_DAYS = 7
|
||||
|
||||
AUTH_PROFILE_MODULE = 'accounts.Profile'
|
||||
|
Loading…
Reference in New Issue
Block a user