Skip to content

Commit

Permalink
Removed text utils module, using textwrap instead
Browse files Browse the repository at this point in the history
  • Loading branch information
apragacz committed Feb 22, 2019
1 parent e86d47d commit e9990a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 77 deletions.
4 changes: 2 additions & 2 deletions docs/detailed_configuration/settings_fields.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Default:
{% else %}
Default: ``{{ f.default|pprint }}``
{% endif %}
{% if f.sphinx_docstring %}
{{ f.sphinx_docstring }}
{% if f.help %}
{{ f.help }}
{% else %}
No description available, please add it!
{% endif %}
Expand Down
37 changes: 15 additions & 22 deletions rest_registration/settings_fields.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import datetime
from collections import OrderedDict, namedtuple

from rest_registration.utils.text import deindent, detect_indent_num
from textwrap import dedent

_Field = namedtuple('_Field', [
'name',
Expand All @@ -18,12 +17,6 @@ def __new__(cls, name, *, default=None, help=None, import_string=False):
cls, name=name, default=default,
help=help, import_string=import_string)

@property
def sphinx_docstring(self):
docstring = self.help if self.help else ''
indent_num = detect_indent_num(docstring)
return deindent(docstring, indent_num)


USER_SETTINGS_FIELDS = [
Field('USER_LOGIN_FIELDS'),
Expand All @@ -49,74 +42,74 @@ def sphinx_docstring(self):
'REGISTER_SERIALIZER_CLASS',
default='rest_registration.api.serializers.DefaultRegisterUserSerializer', # noqa: E501,
import_string=True,
help="""
help=dedent("""\
The default serializer used by register endpoint.
It is used to validate the input data and save (create)
the newly registered user. You can use your custom serializer
to customise validation logic and the way the user is created
in the database.
""",
"""),
),
Field(
'REGISTER_SERIALIZER_PASSWORD_CONFIRM',
default=True,
help="""
help=dedent("""\
Used by ``DefaultRegisterUserSerializer``.
If ``True``, the serializer requires
additional field ``password_confirm`` which value should be
the same as the value of ``password`` field.
It may be useful to disable it if you perform password confirmation
at the frontend level.
""",
"""),
),

Field(
'REGISTER_OUTPUT_SERIALIZER_CLASS',
default='rest_registration.api.serializers.DefaultUserProfileSerializer', # noqa: E501,
import_string=True,
help="""
help=dedent("""\
The default serializer used by register endpoint.
It is used output the data associated with
the newly registered user. You can use your custom serializer
to customise the output representation of the user.
""",
"""),
),

Field(
'REGISTER_VERIFICATION_ENABLED',
default=True,
help="""
help=dedent("""\
If enabled, then newly registered user will not
be verified (user field specified by
``USER_VERIFICATION_FLAG_FIELD`` will be false),
and verification e-mail with activation link
will be sent to the user email (specified by ``USER_EMAIL_FIELD``).
""",
"""),
),
Field(
'REGISTER_VERIFICATION_PERIOD',
default=datetime.timedelta(days=7),
help="""
help=dedent("""\
Specifies how long the activation link will be valid.
""",
"""),
),
Field(
'REGISTER_VERIFICATION_URL',
help="""
help=dedent("""\
Frontend URL to which the query parameters will be appended
to create the activation link for newly registered user.
""",
"""),
),
Field(
'REGISTER_VERIFICATION_EMAIL_TEMPLATES',
default={
'subject': 'rest_registration/register/subject.txt',
'body': 'rest_registration/register/body.txt',
},
help="""
help=dedent("""\
Directory of templates used to generate the verification email.
""",
"""),
),
]

Expand Down
53 changes: 0 additions & 53 deletions rest_registration/utils/text.py

This file was deleted.

0 comments on commit e9990a4

Please sign in to comment.