From 6dc52e0ca5e5dc21eef6b923e93dd1818243e483 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Wed, 6 Jul 2016 19:43:09 +0200 Subject: [PATCH] Update some help_text dans docstrings --- .../migrations/0006_auto_20160706_1727.py | 40 +++++++++++++++++++ cas_server/models.py | 40 ++++++++++++++----- 2 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 cas_server/migrations/0006_auto_20160706_1727.py diff --git a/cas_server/migrations/0006_auto_20160706_1727.py b/cas_server/migrations/0006_auto_20160706_1727.py new file mode 100644 index 0000000..0a30642 --- /dev/null +++ b/cas_server/migrations/0006_auto_20160706_1727.py @@ -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'), + ), + ] diff --git a/cas_server/models.py b/cas_server/models.py index 2314c4f..d741bf2 100644 --- a/cas_server/models.py +++ b/cas_server/models.py @@ -37,15 +37,20 @@ logger = logging.getLogger(__name__) @python_2_unicode_compatible class FederatedIendityProvider(models.Model): - """An identity provider for the federated mode""" + """ + An identity provider for the federated mode + """ class Meta: - verbose_name = _("identity provider") - verbose_name_plural = _("identity providers") + verbose_name = _(u"identity provider") + verbose_name_plural = _(u"identity providers") suffix = models.CharField( max_length=30, unique=True, 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")) cas_protocol_version = models.CharField( @@ -57,28 +62,31 @@ class FederatedIendityProvider(models.Model): ("CAS_2_SAML_1_0", "SAML 1.1") ], 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" ) verbose_name = models.CharField( max_length=255, 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( default=100, verbose_name=_(u"position"), help_text=_( ( + u"Position of the identity provider on the login page. " u"Identity provider are sorted using the " - u"(position, verbose name, suffix) attributes" + u"(position, verbose name, suffix) attributes." ) ) ) display = models.BooleanField( default=True, 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): @@ -86,7 +94,12 @@ class FederatedIendityProvider(models.Model): @staticmethod 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) def build_username(self, username): @@ -238,7 +251,7 @@ class User(models.Model): """ Generate a ticket using `ticket_class` for the service `service` matching `service_pattern` and asking or not for - authentication renewal with `renew + authentication renewal with `renew` """ attributs = dict( (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) 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): logger.warning("Username %s not allowed on service %s" % (user.username, self.name)) raise BadUsername()