Update some help_text dans docstrings

This commit is contained in:
Valentin Samir 2016-07-06 19:43:09 +02:00
parent 4ad4d13baa
commit 6dc52e0ca5
2 changed files with 69 additions and 11 deletions

View file

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-07-06 17:27
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0005_auto_20160616_1018'),
]
operations = [
migrations.AlterField(
model_name='federatediendityprovider',
name='cas_protocol_version',
field=models.CharField(choices=[(b'1', b'CAS 1.0'), (b'2', b'CAS 2.0'), (b'3', b'CAS 3.0'), (b'CAS_2_SAML_1_0', b'SAML 1.1')], default=b'3', help_text='Version of the CAS protocol to use when sending requests the the backend CAS.', max_length=30, verbose_name='CAS protocol version'),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='display',
field=models.BooleanField(default=True, help_text='Display the provider on the login page.', verbose_name='display'),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='pos',
field=models.IntegerField(default=100, help_text='Position of the identity provider on the login page. Identity provider are sorted using the (position, verbose name, suffix) attributes.', verbose_name='position'),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='suffix',
field=models.CharField(help_text='Suffix append to backend CAS returner username: ``returned_username`` @ ``suffix``.', max_length=30, unique=True, verbose_name='suffix'),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='verbose_name',
field=models.CharField(help_text='Name for this identity provider displayed on the login page.', max_length=255, verbose_name='verbose name'),
),
]

View file

@ -37,15 +37,20 @@ logger = logging.getLogger(__name__)
@python_2_unicode_compatible @python_2_unicode_compatible
class FederatedIendityProvider(models.Model): class FederatedIendityProvider(models.Model):
"""An identity provider for the federated mode""" """
An identity provider for the federated mode
"""
class Meta: class Meta:
verbose_name = _("identity provider") verbose_name = _(u"identity provider")
verbose_name_plural = _("identity providers") verbose_name_plural = _(u"identity providers")
suffix = models.CharField( suffix = models.CharField(
max_length=30, max_length=30,
unique=True, unique=True,
verbose_name=_(u"suffix"), verbose_name=_(u"suffix"),
help_text=_("Suffix append to backend CAS returner username: `returned_username`@`suffix`") help_text=_(
u"Suffix append to backend CAS returner "
u"username: ``returned_username`` @ ``suffix``."
)
) )
server_url = models.CharField(max_length=255, verbose_name=_(u"server url")) server_url = models.CharField(max_length=255, verbose_name=_(u"server url"))
cas_protocol_version = models.CharField( cas_protocol_version = models.CharField(
@ -57,28 +62,31 @@ class FederatedIendityProvider(models.Model):
("CAS_2_SAML_1_0", "SAML 1.1") ("CAS_2_SAML_1_0", "SAML 1.1")
], ],
verbose_name=_(u"CAS protocol version"), verbose_name=_(u"CAS protocol version"),
help_text=_("Version of the CAS protocol to use when sending requests the the backend CAS"), help_text=_(
u"Version of the CAS protocol to use when sending requests the the backend CAS."
),
default="3" default="3"
) )
verbose_name = models.CharField( verbose_name = models.CharField(
max_length=255, max_length=255,
verbose_name=_(u"verbose name"), verbose_name=_(u"verbose name"),
help_text=_("Name for this identity provider displayed on the login page") help_text=_(u"Name for this identity provider displayed on the login page.")
) )
pos = models.IntegerField( pos = models.IntegerField(
default=100, default=100,
verbose_name=_(u"position"), verbose_name=_(u"position"),
help_text=_( help_text=_(
( (
u"Position of the identity provider on the login page. "
u"Identity provider are sorted using the " u"Identity provider are sorted using the "
u"(position, verbose name, suffix) attributes" u"(position, verbose name, suffix) attributes."
) )
) )
) )
display = models.BooleanField( display = models.BooleanField(
default=True, default=True,
verbose_name=_(u"display"), verbose_name=_(u"display"),
help_text=_("Display the provider on the login page") help_text=_("Display the provider on the login page.")
) )
def __str__(self): def __str__(self):
@ -86,7 +94,12 @@ class FederatedIendityProvider(models.Model):
@staticmethod @staticmethod
def build_username_from_suffix(username, suffix): def build_username_from_suffix(username, suffix):
"""Transform backend username into federated username using `suffix`""" """
Transform backend username into federated username using ``suffix``
:param unicode username: A CAS backend returned username
:param unicode suffix: A suffix identifying the CAS backend
"""
return u'%s@%s' % (username, suffix) return u'%s@%s' % (username, suffix)
def build_username(self, username): def build_username(self, username):
@ -238,7 +251,7 @@ class User(models.Model):
""" """
Generate a ticket using `ticket_class` for the service Generate a ticket using `ticket_class` for the service
`service` matching `service_pattern` and asking or not for `service` matching `service_pattern` and asking or not for
authentication renewal with `renew authentication renewal with `renew`
""" """
attributs = dict( attributs = dict(
(a.name, a.replace if a.replace else a.name) for a in service_pattern.attributs.all() (a.name, a.replace if a.replace else a.name) for a in service_pattern.attributs.all()
@ -376,7 +389,12 @@ class ServicePattern(models.Model):
return u"%s: %s" % (self.pos, self.pattern) return u"%s: %s" % (self.pos, self.pattern)
def check_user(self, user): def check_user(self, user):
"""Check if `user` if allowed to use theses services""" """
Check if ``user`` if allowed to use theses services. If ``user`` is not allowed,
raises one of :class:`BadFilter`, :class:`UserFieldNotDefined`, :class:`BadUsername`
:param user: a :class:`User` object
"""
if self.restrict_users and not self.usernames.filter(value=user.username): if self.restrict_users and not self.usernames.filter(value=user.username):
logger.warning("Username %s not allowed on service %s" % (user.username, self.name)) logger.warning("Username %s not allowed on service %s" % (user.username, self.name))
raise BadUsername() raise BadUsername()