Commit 5490aad0 authored by Jitka Novotna's avatar Jitka Novotna

Preferences

parent dae26b87
...@@ -217,7 +217,7 @@ class SubscriptionSettingsForm(forms.ModelForm): ...@@ -217,7 +217,7 @@ class SubscriptionSettingsForm(forms.ModelForm):
class UserSettingsForm(forms.ModelForm): class UserSettingsForm(forms.ModelForm):
''' '''
User subscription management. User settings form.
''' '''
class Meta(object): class Meta(object):
model = Profile model = Profile
...@@ -227,6 +227,25 @@ class UserSettingsForm(forms.ModelForm): ...@@ -227,6 +227,25 @@ class UserSettingsForm(forms.ModelForm):
'hide_source_secondary', 'hide_source_secondary',
) )
class DashboardSettingsForm(forms.ModelForm):
'''
Dashboard settings form.
'''
class Meta(object):
model = Profile
fields = (
'dashboard_view',
'dashboard_component_list',
)
def clean(self):
'''
Check if component list is selected when required.
'''
if self.cleaned_data['dashboard_view']==Profile.DASHBOARD_COMPONENT_LIST and \
self.cleaned_data['dashboard_component_list'] is None:
raise forms.ValidationError(
_("Componest list must be selected when used as default."))
class UserForm(forms.ModelForm): class UserForm(forms.ModelForm):
''' '''
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trans', '0059_auto_20160205_1349'),
('accounts', '0014_auto_20160205_1349'),
]
operations = [
migrations.AddField(
model_name='profile',
name='dashboard_component_list',
field=models.ForeignKey(verbose_name='Default component list', blank=True, to='trans.ComponentList', null=True),
),
migrations.AddField(
model_name='profile',
name='dashboard_view',
field=models.IntegerField(default=0, verbose_name='Default dashboard view'),
),
]
...@@ -496,6 +496,29 @@ class Profile(models.Model): ...@@ -496,6 +496,29 @@ class Profile(models.Model):
default=False default=False
) )
DASHBOARD_SUBSCRIPTIONS = 0
DASHBOARD_LANGUAGES = 1
DASHBOARD_ALL = 2
DASHBOARD_COMPONENT_LIST = 3
DASHBOARD_CHOICES = (
(DASHBOARD_SUBSCRIPTIONS, _('Your subscriptions')),
(DASHBOARD_LANGUAGES, _('Your languages')),
(DASHBOARD_ALL, _('All projects')),
(DASHBOARD_COMPONENT_LIST, _('Component list')),
)
dashboard_view = models.IntegerField(
choices=DASHBOARD_CHOICES,
verbose_name=_('Default dashboard view'),
default=DASHBOARD_SUBSCRIPTIONS,
)
dashboard_component_list = models.ForeignKey(
'trans.ComponentList',
verbose_name=_('Default component list'),
blank=True,
null=True,
)
subscriptions = models.ManyToManyField( subscriptions = models.ManyToManyField(
'trans.Project', 'trans.Project',
verbose_name=_('Subscribed projects'), verbose_name=_('Subscribed projects'),
......
...@@ -53,7 +53,7 @@ from weblate.accounts.models import set_lang, remove_user, Profile ...@@ -53,7 +53,7 @@ from weblate.accounts.models import set_lang, remove_user, Profile
from weblate.trans.models import Change, Project, SubProject from weblate.trans.models import Change, Project, SubProject
from weblate.accounts.forms import ( from weblate.accounts.forms import (
ProfileForm, SubscriptionForm, UserForm, ContactForm, ProfileForm, SubscriptionForm, UserForm, ContactForm,
SubscriptionSettingsForm, UserSettingsForm SubscriptionSettingsForm, UserSettingsForm, DashboardSettingsForm
) )
from weblate import appsettings from weblate import appsettings
...@@ -147,6 +147,7 @@ def user_profile(request): ...@@ -147,6 +147,7 @@ def user_profile(request):
SubscriptionForm, SubscriptionForm,
SubscriptionSettingsForm, SubscriptionSettingsForm,
UserSettingsForm, UserSettingsForm,
DashboardSettingsForm,
] ]
if request.method == 'POST': if request.method == 'POST':
...@@ -201,7 +202,8 @@ def user_profile(request): ...@@ -201,7 +202,8 @@ def user_profile(request):
'subscriptionform': forms[1], 'subscriptionform': forms[1],
'subscriptionsettingsform': forms[2], 'subscriptionsettingsform': forms[2],
'usersettingsform': forms[3], 'usersettingsform': forms[3],
'userform': forms[4], 'dashboardsettingsform': forms[4],
'userform': forms[5],
'profile': profile, 'profile': profile,
'title': _('User profile'), 'title': _('User profile'),
'licenses': license_projects, 'licenses': license_projects,
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
<div class="panel-heading"><h4 class="panel-title">{% trans "Preferences" %}</h4></div> <div class="panel-heading"><h4 class="panel-title">{% trans "Preferences" %}</h4></div>
<div class="panel-body"> <div class="panel-body">
{{ usersettingsform|crispy }} {{ usersettingsform|crispy }}
{{ dashboardsettingsform|crispy }}
</div> </div>
<div class="panel-footer"> <div class="panel-footer">
<input type="submit" value="{% trans "Save" %}" class="btn btn-default" /> <input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment