1234567891011121314151617181920212223242526272829303132333435363738 |
- import config
- from django.conf import settings
- from django.utils.translation import gettext as _
-
- USERS_SELF_REGISTRATION = "USERS_SELF_REGISTRATION"
- USERS_MAIL_VALIDATION = "USERS_MAIL_VALIDATION"
- USERS_ADMIN_ACTIVATION = "USERS_ADMIN_ACTIVATION"
-
-
- DEFAULTS = {
- USERS_SELF_REGISTRATION: False,
- USERS_MAIL_VALIDATION: True,
- USERS_ADMIN_ACTIVATION: True,
- }
-
-
- def get(key):
- # take data from config, settings or defaults
- try:
- data = getattr(config, key)
- except AttributeError:
- try:
- data = getattr(settings, key)
- except AttributeError:
- data = DEFAULTS.get(key)
-
- return data
-
-
- def registration_flow_description(username):
- if not get(USERS_MAIL_VALIDATION) and not get(USERS_ADMIN_ACTIVATION):
- return _("Your account has been created. You are now able to Login as %s.") % username
- elif get(USERS_MAIL_VALIDATION) and get(USERS_ADMIN_ACTIVATION):
- return _("Your account has been created. You'll get an email to validate your account. Then you have to wait for the activation by an administrator.")
- elif get(USERS_MAIL_VALIDATION):
- return _("Your account has been created. You'll get an email to validate your account. After validation you are able to Login as %s.") % username
- else:
- return _("Your account has been created. You have to wait for the activation by an administrator.")
|