all: add more helpful help_text to models

This commit is contained in:
Jens Langhammer 2020-02-21 15:12:16 +01:00
parent e2f836feae
commit 26bf6fd22f
7 changed files with 127 additions and 12 deletions

View File

@ -0,0 +1,52 @@
# Generated by Django 3.0.3 on 2020-02-21 14:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_core", "0008_auto_20200220_1242"),
]
operations = [
migrations.AlterField(
model_name="application",
name="name",
field=models.TextField(help_text="Application's display Name."),
),
migrations.AlterField(
model_name="application",
name="slug",
field=models.SlugField(
help_text="Internal application name, used in URLs."
),
),
migrations.AlterField(
model_name="factor",
name="name",
field=models.TextField(help_text="Factor's display Name."),
),
migrations.AlterField(
model_name="factor",
name="slug",
field=models.SlugField(
help_text="Internal factor name, used in URLs.", unique=True
),
),
migrations.AlterField(
model_name="source",
name="name",
field=models.TextField(help_text="Source's display Name."),
),
migrations.AlterField(
model_name="source",
name="slug",
field=models.SlugField(help_text="Internal source name, used in URLs."),
),
migrations.AlterField(
model_name="user",
name="name",
field=models.TextField(help_text="User's display name."),
),
]

View File

@ -62,7 +62,7 @@ class User(ExportModelOperationsMixin("user"), GuardianUserMixin, AbstractUser):
"""Custom User model to allow easier adding o f user-based settings""" """Custom User model to allow easier adding o f user-based settings"""
uuid = models.UUIDField(default=uuid4, editable=False) uuid = models.UUIDField(default=uuid4, editable=False)
name = models.TextField() name = models.TextField(help_text=_("User's display name."))
sources = models.ManyToManyField("Source", through="UserSourceConnection") sources = models.ManyToManyField("Source", through="UserSourceConnection")
groups = models.ManyToManyField("Group") groups = models.ManyToManyField("Group")
@ -106,8 +106,10 @@ class PolicyModel(UUIDModel, CreatedUpdatedModel):
class Factor(ExportModelOperationsMixin("factor"), PolicyModel): class Factor(ExportModelOperationsMixin("factor"), PolicyModel):
"""Authentication factor, multiple instances of the same Factor can be used""" """Authentication factor, multiple instances of the same Factor can be used"""
name = models.TextField() name = models.TextField(help_text=_("Factor's display Name."))
slug = models.SlugField(unique=True) slug = models.SlugField(
unique=True, help_text=_("Internal factor name, used in URLs.")
)
order = models.IntegerField() order = models.IntegerField()
enabled = models.BooleanField(default=True) enabled = models.BooleanField(default=True)
@ -130,8 +132,8 @@ class Application(ExportModelOperationsMixin("application"), PolicyModel):
needs an Application record. Other authentication types can subclass this Model to needs an Application record. Other authentication types can subclass this Model to
add custom fields and other properties""" add custom fields and other properties"""
name = models.TextField() name = models.TextField(help_text=_("Application's display Name."))
slug = models.SlugField() slug = models.SlugField(help_text=_("Internal application name, used in URLs."))
skip_authorization = models.BooleanField(default=False) skip_authorization = models.BooleanField(default=False)
provider = models.OneToOneField( provider = models.OneToOneField(
"Provider", null=True, blank=True, default=None, on_delete=models.SET_DEFAULT "Provider", null=True, blank=True, default=None, on_delete=models.SET_DEFAULT
@ -157,8 +159,8 @@ class Application(ExportModelOperationsMixin("application"), PolicyModel):
class Source(ExportModelOperationsMixin("source"), PolicyModel): class Source(ExportModelOperationsMixin("source"), PolicyModel):
"""Base Authentication source, i.e. an OAuth Provider, SAML Remote or LDAP Server""" """Base Authentication source, i.e. an OAuth Provider, SAML Remote or LDAP Server"""
name = models.TextField() name = models.TextField(help_text=_("Source's display Name."))
slug = models.SlugField() slug = models.SlugField(help_text=_("Internal source name, used in URLs."))
enabled = models.BooleanField(default=True) enabled = models.BooleanField(default=True)
property_mappings = models.ManyToManyField( property_mappings = models.ManyToManyField(

View File

@ -0,0 +1,27 @@
# Generated by Django 3.0.3 on 2020-02-21 14:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_factors_captcha", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="captchafactor",
name="private_key",
field=models.TextField(
help_text="Private key, acquired from https://www.google.com/recaptcha/intro/v3.html"
),
),
migrations.AlterField(
model_name="captchafactor",
name="public_key",
field=models.TextField(
help_text="Public key, acquired from https://www.google.com/recaptcha/intro/v3.html"
),
),
]

View File

@ -1,6 +1,6 @@
"""passbook captcha factor""" """passbook captcha factor"""
from django.db import models from django.db import models
from django.utils.translation import gettext as _ from django.utils.translation import gettext_lazy as _
from passbook.core.models import Factor from passbook.core.models import Factor
@ -8,8 +8,16 @@ from passbook.core.models import Factor
class CaptchaFactor(Factor): class CaptchaFactor(Factor):
"""Captcha Factor instance""" """Captcha Factor instance"""
public_key = models.TextField() public_key = models.TextField(
private_key = models.TextField() help_text=_(
"Public key, acquired from https://www.google.com/recaptcha/intro/v3.html"
)
)
private_key = models.TextField(
help_text=_(
"Private key, acquired from https://www.google.com/recaptcha/intro/v3.html"
)
)
type = "passbook.factors.captcha.factor.CaptchaFactor" type = "passbook.factors.captcha.factor.CaptchaFactor"
form = "passbook.factors.captcha.forms.CaptchaFactorForm" form = "passbook.factors.captcha.forms.CaptchaFactorForm"

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.3 on 2020-02-21 14:10
import django.contrib.postgres.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_factors_password", "0003_passwordfactor_reset_factors"),
]
operations = [
migrations.AlterField(
model_name="passwordfactor",
name="backends",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.TextField(),
help_text="Selection of backends to test the password against.",
size=None,
),
),
]

View File

@ -10,7 +10,10 @@ from passbook.core.types import UIUserSettings
class PasswordFactor(Factor): class PasswordFactor(Factor):
"""Password-based Django-backend Authentication Factor""" """Password-based Django-backend Authentication Factor"""
backends = ArrayField(models.TextField()) backends = ArrayField(
models.TextField(),
help_text=_("Selection of backends to test the password against."),
)
password_policies = models.ManyToManyField(Policy, blank=True) password_policies = models.ManyToManyField(Policy, blank=True)
reset_factors = models.ManyToManyField( reset_factors = models.ManyToManyField(
Factor, blank=True, related_name="reset_factors" Factor, blank=True, related_name="reset_factors"

View File

@ -4,7 +4,7 @@ from typing import List, Optional, Tuple
from django.contrib.auth import login from django.contrib.auth import login
from django.contrib.auth.mixins import UserPassesTestMixin from django.contrib.auth.mixins import UserPassesTestMixin
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404, redirect, render, reverse from django.shortcuts import get_object_or_404, redirect, reverse
from django.utils.http import urlencode from django.utils.http import urlencode
from django.views.generic import View from django.views.generic import View
from structlog import get_logger from structlog import get_logger