mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-26 08:39:08 +01:00
Addresses issue 20: when creating a new user, the signal that creates a UserSettings entry now creates some default settings. These are driven by settings.py so can be overridden per-install.
This commit is contained in:
parent
107ec742b1
commit
b3c53f1bc8
@ -933,9 +933,10 @@ def create_usersettings(sender, created_models=[], instance=None, created=False,
|
||||
If we end up with users with no UserSettings, then we get horrible
|
||||
'DoesNotExist: UserSettings matching query does not exist.' errors.
|
||||
"""
|
||||
from helpdesk.settings import DEFAULT_USER_SETTINGS
|
||||
if sender == User and created:
|
||||
# This is a new user, so lets create their settings entry.
|
||||
s, created = UserSettings.objects.get_or_create(user=instance)
|
||||
s, created = UserSettings.objects.get_or_create(user=instance, defaults={'settings': DEFAULT_USER_SETTINGS})
|
||||
s.save()
|
||||
elif UserSettings in created_models:
|
||||
# We just created the UserSettings model, lets create a UserSettings
|
||||
@ -946,7 +947,7 @@ def create_usersettings(sender, created_models=[], instance=None, created=False,
|
||||
try:
|
||||
s = UserSettings.objects.get(user=u)
|
||||
except UserSettings.DoesNotExist:
|
||||
s = UserSettings(user=u)
|
||||
s = UserSettings(user=u, settings=DEFAULT_USER_SETTINGS)
|
||||
s.save()
|
||||
|
||||
models.signals.post_syncdb.connect(create_usersettings)
|
||||
|
@ -12,3 +12,18 @@ try:
|
||||
import tagging
|
||||
except ImportError:
|
||||
HAS_TAG_SUPPORT = False
|
||||
|
||||
try:
|
||||
DEFAULT_USER_SETTINGS = settings.HELPDESK_DEFAULT_SETTINGS
|
||||
except:
|
||||
DEFAULT_USER_SETTINGS = None
|
||||
|
||||
if type(DEFAULT_USER_SETTINGS) != type(dict()):
|
||||
DEFAULT_USER_SETTINGS = {
|
||||
'use_email_as_submitter': True,
|
||||
'email_on_ticket_assign': True,
|
||||
'email_on_ticket_change': True,
|
||||
'login_view_ticketlist': True,
|
||||
'email_on_ticket_apichange': True,
|
||||
'tickets_per_page': 25
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user