mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-27 09:08:53 +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
|
If we end up with users with no UserSettings, then we get horrible
|
||||||
'DoesNotExist: UserSettings matching query does not exist.' errors.
|
'DoesNotExist: UserSettings matching query does not exist.' errors.
|
||||||
"""
|
"""
|
||||||
|
from helpdesk.settings import DEFAULT_USER_SETTINGS
|
||||||
if sender == User and created:
|
if sender == User and created:
|
||||||
# This is a new user, so lets create their settings entry.
|
# 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()
|
s.save()
|
||||||
elif UserSettings in created_models:
|
elif UserSettings in created_models:
|
||||||
# We just created the UserSettings model, lets create a UserSettings
|
# 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:
|
try:
|
||||||
s = UserSettings.objects.get(user=u)
|
s = UserSettings.objects.get(user=u)
|
||||||
except UserSettings.DoesNotExist:
|
except UserSettings.DoesNotExist:
|
||||||
s = UserSettings(user=u)
|
s = UserSettings(user=u, settings=DEFAULT_USER_SETTINGS)
|
||||||
s.save()
|
s.save()
|
||||||
|
|
||||||
models.signals.post_syncdb.connect(create_usersettings)
|
models.signals.post_syncdb.connect(create_usersettings)
|
||||||
|
@ -12,3 +12,18 @@ try:
|
|||||||
import tagging
|
import tagging
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_TAG_SUPPORT = False
|
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