0001-python3-py2-unicode-compatible-__str__-magid-methods.patch
src/authentic2/a2_rbac/admin.py | ||
---|---|---|
36 | 36 |
readonly_fields = ('uuid',) |
37 | 37 |
prepopulated_fields = {"slug": ("name",)} |
38 | 38 |
filter_horizontal = ('members', 'permissions') |
39 |
list_display = ('__unicode__', 'slug', 'ou', 'service', 'admin_scope')
|
|
39 |
list_display = ('__str__', 'slug', 'ou', 'service', 'admin_scope')
|
|
40 | 40 |
list_select_related = True |
41 | 41 |
list_filter = ['ou', 'service'] |
42 | 42 |
inlines = [RoleAttributeInline] |
src/authentic2/a2_rbac/models.py | ||
---|---|---|
25 | 25 |
from . import managers, fields |
26 | 26 | |
27 | 27 | |
28 |
@six.python_2_unicode_compatible |
|
28 | 29 |
class OrganizationalUnit(OrganizationalUnitAbstractBase): |
29 | 30 | |
30 | 31 |
RESET_LINK_POLICY = 0 |
... | ... | |
134 | 135 |
'validate_emails': self.validate_emails |
135 | 136 |
} |
136 | 137 | |
138 |
def __str__(self): |
|
139 |
return self.name |
|
140 | ||
137 | 141 | |
138 | 142 |
OrganizationalUnit._meta.natural_key = [['uuid'], ['slug'], ['name']] |
139 | 143 | |
... | ... | |
293 | 297 |
] |
294 | 298 | |
295 | 299 | |
300 |
@six.python_2_unicode_compatible |
|
296 | 301 |
class RoleParenting(RoleParentingAbstractBase): |
297 | 302 |
class Meta(RoleParentingAbstractBase.Meta): |
298 | 303 |
verbose_name = _('role parenting relation') |
299 | 304 |
verbose_name_plural = _('role parenting relations') |
300 | 305 | |
306 |
def __str__(self): |
|
307 |
return self.name |
|
308 | ||
301 | 309 | |
302 | 310 |
class RoleAttribute(models.Model): |
303 | 311 |
KINDS = ( |
src/authentic2/admin.py | ||
---|---|---|
251 | 251 |
) |
252 | 252 |
readonly_fields = ('uuid',) |
253 | 253 |
list_filter = UserAdmin.list_filter + (UserRealmListFilter,ExternalUserListFilter) |
254 |
list_display = ['__unicode__', 'ou', 'first_name', 'last_name', 'email']
|
|
254 |
list_display = ['__str__', 'ou', 'first_name', 'last_name', 'email']
|
|
255 | 255 | |
256 | 256 |
def get_fieldsets(self, request, obj=None): |
257 | 257 |
fieldsets = deepcopy(super(AuthenticUserAdmin, self).get_fieldsets(request, obj)) |
src/authentic2/auth2_auth/auth2_ssl/models.py | ||
---|---|---|
1 | 1 |
from django.db import models |
2 | 2 |
from django.conf import settings |
3 |
from django.utils import six |
|
3 | 4 | |
4 | 5 |
from . import util |
5 | 6 | |
7 |
@six.python_2_unicode_compatible |
|
6 | 8 |
class ClientCertificate(models.Model): |
7 | 9 |
serial = models.CharField(max_length=255, blank=True) |
8 | 10 |
subject_dn = models.CharField(max_length=255) |
... | ... | |
10 | 12 |
cert = models.TextField() |
11 | 13 |
user = models.ForeignKey(settings.AUTH_USER_MODEL) |
12 | 14 | |
13 |
def __unicode__(self):
|
|
15 |
def __str__(self):
|
|
14 | 16 |
return self.subject_dn |
15 | 17 | |
16 | 18 |
def explode_subject_dn(self): |
src/authentic2/custom_user/models.py | ||
---|---|---|
95 | 95 |
return IsVerified(obj) |
96 | 96 | |
97 | 97 | |
98 |
@six.python_2_unicode_compatible |
|
98 | 99 |
class User(AbstractBaseUser, PermissionMixin): |
99 | 100 |
""" |
100 | 101 |
An abstract base class implementing a fully featured User model with |
... | ... | |
182 | 183 |
'members', queryset=self.__class__.objects.filter(pk=self.pk), to_attr='member')) |
183 | 184 |
return qs |
184 | 185 | |
185 |
def __unicode__(self):
|
|
186 |
def __str__(self):
|
|
186 | 187 |
human_name = self.username or self.email or self.get_full_name() |
187 | 188 |
short_id = self.uuid[:6] |
188 | 189 |
return u'%s (%s)' % (human_name, short_id) |
src/authentic2/models.py | ||
---|---|---|
42 | 42 |
verbose_name = _('user to delete') |
43 | 43 |
verbose_name_plural = _('users to delete') |
44 | 44 | |
45 |
@six.python_2_unicode_compatible |
|
45 | 46 |
class UserExternalId(models.Model): |
46 | 47 |
user = models.ForeignKey(settings.AUTH_USER_MODEL, |
47 | 48 |
verbose_name=_('user')) |
... | ... | |
54 | 55 |
updated = models.DateTimeField(auto_now=True, |
55 | 56 |
verbose_name=_('last update date')) |
56 | 57 | |
57 |
def __unicode__(self):
|
|
58 |
def __str__(self):
|
|
58 | 59 |
return u'{0} is {1} on {2}'.format( |
59 | 60 |
self.user, self.external_id, self.source) |
60 | 61 | |
... | ... | |
68 | 69 |
verbose_name = _('user external id') |
69 | 70 |
verbose_name_plural = _('user external ids') |
70 | 71 | |
72 |
@six.python_2_unicode_compatible |
|
71 | 73 |
class AuthenticationEvent(models.Model): |
72 | 74 |
'''Record authentication events whatever the source''' |
73 | 75 |
when = models.DateTimeField(auto_now=True, |
... | ... | |
85 | 87 |
verbose_name = _('authentication log') |
86 | 88 |
verbose_name_plural = _('authentication logs') |
87 | 89 | |
88 |
def __unicode__(self):
|
|
90 |
def __str__(self):
|
|
89 | 91 |
return _('Authentication of %(who)s by %(how)s at %(when)s') % \ |
90 | 92 |
self.__dict__ |
91 | 93 | |
... | ... | |
124 | 126 |
verbose_name_plural = _('logout URL') |
125 | 127 | |
126 | 128 | |
129 |
@six.python_2_unicode_compatible |
|
127 | 130 |
class Attribute(models.Model): |
128 | 131 |
label = models.CharField(verbose_name=_('label'), max_length=63, |
129 | 132 |
unique=True) |
... | ... | |
248 | 251 |
def natural_key(self): |
249 | 252 |
return (self.name,) |
250 | 253 | |
251 |
def __unicode__(self):
|
|
254 |
def __str__(self):
|
|
252 | 255 |
return self.label |
253 | 256 | |
254 | 257 |
class Meta: |
... | ... | |
292 | 295 |
) |
293 | 296 | |
294 | 297 | |
298 |
@six.python_2_unicode_compatible |
|
295 | 299 |
class PasswordReset(models.Model): |
296 | 300 |
user = models.OneToOneField(settings.AUTH_USER_MODEL, |
297 | 301 |
verbose_name=_('user')) |
... | ... | |
306 | 310 |
verbose_name = _('password reset') |
307 | 311 |
verbose_name_plural = _('password reset') |
308 | 312 | |
309 |
def __unicode__(self):
|
|
313 |
def __str__(self):
|
|
310 | 314 |
return six.text_type(self.user) |
311 | 315 | |
312 | 316 | |
317 |
@six.python_2_unicode_compatible |
|
313 | 318 |
class Service(models.Model): |
314 | 319 |
name = models.CharField( |
315 | 320 |
verbose_name=_('name'), |
... | ... | |
359 | 364 |
def natural_key(self): |
360 | 365 |
return [self.ou and self.ou.natural_key(), self.slug] |
361 | 366 | |
362 |
def __unicode__(self):
|
|
367 |
def __str__(self):
|
|
363 | 368 |
return self.name |
364 | 369 | |
365 | 370 |
def __repr__(self): |
src/authentic2/nonce/models.py | ||
---|---|---|
1 | 1 |
import datetime as dt |
2 | 2 | |
3 | 3 |
from django.db import models |
4 |
from django.utils import timezone |
|
4 |
from django.utils import timezone, six
|
|
5 | 5 | |
6 | 6 |
__all__ = ('Nonce',) |
7 | 7 | |
... | ... | |
12 | 12 |
now = now or timezone.now() |
13 | 13 |
self.filter(not_on_or_after__lt=now).delete() |
14 | 14 | |
15 |
@six.python_2_unicode_compatible |
|
15 | 16 |
class Nonce(models.Model): |
16 | 17 |
value = models.CharField(max_length=_NONCE_LENGTH_CONSTANT) |
17 | 18 |
context = models.CharField(max_length=_NONCE_LENGTH_CONSTANT, blank=True, |
... | ... | |
20 | 21 | |
21 | 22 |
objects = NonceManager() |
22 | 23 | |
23 |
def __unicode__(self):
|
|
24 |
def __str__(self):
|
|
24 | 25 |
return self.value |
src/authentic2/saml/models.py | ||
---|---|---|
161 | 161 |
) |
162 | 162 | |
163 | 163 | |
164 |
@six.python_2_unicode_compatible |
|
164 | 165 |
class SPOptionsIdPPolicy(models.Model): |
165 | 166 |
''' |
166 | 167 |
Policies configured as a SAML2 identity provider. |
... | ... | |
232 | 233 |
verbose_name = _('service provider options policy') |
233 | 234 |
verbose_name_plural = _('service provider options policies') |
234 | 235 | |
235 |
def __unicode__(self):
|
|
236 |
def __str__(self):
|
|
236 | 237 |
return self.name |
237 | 238 | |
239 |
@six.python_2_unicode_compatible |
|
238 | 240 |
class SAMLAttribute(models.Model): |
239 | 241 |
ATTRIBUTE_NAME_FORMATS = ( |
240 | 242 |
('basic', 'Basic'), |
... | ... | |
294 | 296 |
for text_value in normalize_attribute_values(values): |
295 | 297 |
yield (name, name_format, friendly_name, text_value) |
296 | 298 | |
297 |
def __unicode__(self):
|
|
299 |
def __str__(self):
|
|
298 | 300 |
return u'%s %s %s' % (self.name, self.name_format_uri(), self.attribute_name) |
299 | 301 | |
300 | 302 |
def natural_key(self): |
... | ... | |
307 | 309 |
'friendly_name', 'attribute_name'),) |
308 | 310 | |
309 | 311 | |
312 |
@six.python_2_unicode_compatible |
|
310 | 313 |
class LibertyProvider(Service): |
311 | 314 |
entity_id = models.URLField(max_length=256, unique=True, |
312 | 315 |
verbose_name=_('Entity ID')) |
... | ... | |
329 | 332 | |
330 | 333 |
objects = managers.LibertyProviderManager() |
331 | 334 | |
332 |
def __unicode__(self):
|
|
335 |
def __str__(self):
|
|
333 | 336 |
return self.name |
334 | 337 | |
335 | 338 |
def save(self, *args, **kwargs): |
... | ... | |
387 | 390 | |
388 | 391 |
# TODO: The IdP must look to the preferred binding order for sso in the SP metadata (AssertionConsumerService) |
389 | 392 |
# expect if the protocol for response is defined in the request (ProtocolBinding attribute) |
393 |
@six.python_2_unicode_compatible |
|
390 | 394 |
class LibertyServiceProvider(models.Model): |
391 | 395 |
liberty_provider = models.OneToOneField(LibertyProvider, |
392 | 396 |
primary_key = True, related_name = 'service_provider') |
... | ... | |
411 | 415 |
def natural_key(self): |
412 | 416 |
return (self.liberty_provider.slug,) |
413 | 417 | |
414 |
def __unicode__(self):
|
|
418 |
def __str__(self):
|
|
415 | 419 |
return six.text_type(self.liberty_provider) |
416 | 420 | |
417 | 421 |
class Meta: |
... | ... | |
463 | 467 |
# XXX: for retrocompatibility |
464 | 468 |
federation_delete = managers.federation_delete |
465 | 469 | |
470 |
@six.python_2_unicode_compatible |
|
466 | 471 |
class LibertyFederation(models.Model): |
467 | 472 |
"""Store a federation, i.e. an identifier shared with another provider, be |
468 | 473 |
it IdP or SP""" |
... | ... | |
519 | 524 |
verbose_name = _("SAML federation") |
520 | 525 |
verbose_name_plural = _("SAML federations") |
521 | 526 | |
522 |
def __unicode__(self):
|
|
527 |
def __str__(self):
|
|
523 | 528 |
return self.name_id_content |
524 | 529 | |
525 | 530 | |
531 |
@six.python_2_unicode_compatible |
|
526 | 532 |
class LibertySession(models.Model): |
527 | 533 |
"""Store the link between a Django session and a SAML session""" |
528 | 534 |
django_session_key = models.CharField(max_length = 128) |
... | ... | |
572 | 578 |
qs = qs.filter(Q(name_id_sp_name_qualifier__isnull=True)|Q(name_id_sp_name_qualifier=provider_id)) |
573 | 579 |
return qs |
574 | 580 | |
575 |
def __unicode__(self):
|
|
581 |
def __str__(self):
|
|
576 | 582 |
return '<LibertySession %s>' % self.__dict__ |
577 | 583 | |
578 | 584 |
class Meta: |
579 | 585 |
verbose_name = _("SAML session") |
580 | 586 |
verbose_name_plural = _("SAML sessions") |
581 | 587 | |
588 |
@six.python_2_unicode_compatible |
|
582 | 589 |
class KeyValue(models.Model): |
583 | 590 |
key = models.CharField(max_length=128, primary_key=True) |
584 | 591 |
value = PickledObjectField() |
... | ... | |
586 | 593 | |
587 | 594 |
objects = a2_managers.ExpireManager() |
588 | 595 | |
589 |
def __unicode__(self):
|
|
596 |
def __str__(self):
|
|
590 | 597 |
return self.key |
591 | 598 | |
592 | 599 |
class Meta: |
src/authentic2_auth_oidc/models.py | ||
---|---|---|
2 | 2 |
import json |
3 | 3 | |
4 | 4 |
from django.db import models |
5 |
from django.utils import six |
|
5 | 6 |
from django.utils.translation import ugettext_lazy as _ |
6 | 7 |
from django.conf import settings |
7 | 8 |
from django.core.exceptions import ValidationError |
... | ... | |
24 | 25 |
raise ValidationError(_('Invalid JWKSet: %s') % e) |
25 | 26 | |
26 | 27 | |
28 |
@six.python_2_unicode_compatible |
|
27 | 29 |
class OIDCProvider(models.Model): |
28 | 30 |
STRATEGY_CREATE = 'create' |
29 | 31 |
STRATEGY_FIND_UUID = 'find-uuid' |
... | ... | |
145 | 147 |
return JWK(kty='oct', k=base64url_encode(self.client_secret.encode('utf-8'))) |
146 | 148 |
return None |
147 | 149 | |
148 |
def __unicode__(self):
|
|
150 |
def __str__(self):
|
|
149 | 151 |
return self.name |
150 | 152 | |
151 | 153 |
def authorization_claims_parameter(self): |
... | ... | |
166 | 168 |
return '<OIDCProvider %r>' % self.issuer |
167 | 169 | |
168 | 170 | |
171 |
@six.python_2_unicode_compatible |
|
169 | 172 |
class OIDCClaimMapping(models.Model): |
170 | 173 |
NOT_VERIFIED = 0 |
171 | 174 |
VERIFIED_CLAIM = 1 |
... | ... | |
210 | 213 |
def natural_key(self): |
211 | 214 |
return (self.claim, self.attribute, self.verified, self.required) |
212 | 215 | |
213 |
def __unicode__(self):
|
|
216 |
def __str__(self):
|
|
214 | 217 |
s = u'{0} -> {1}'.format(self.claim, self.attribute) |
215 | 218 |
if self.verified: |
216 | 219 |
s += u', verified' |
... | ... | |
226 | 229 |
self.verified, self.required) |
227 | 230 | |
228 | 231 | |
232 |
@six.python_2_unicode_compatible |
|
229 | 233 |
class OIDCAccount(models.Model): |
230 | 234 |
created = models.DateTimeField( |
231 | 235 |
verbose_name=_('created'), |
... | ... | |
246 | 250 |
max_length=256, |
247 | 251 |
unique=True) |
248 | 252 | |
249 |
def __unicode__(self):
|
|
253 |
def __str__(self):
|
|
250 | 254 |
return u'{0} on {1} linked to {2}'.format(self.sub, self.provider and self.provider.issuer, |
251 | 255 |
self.user) |
252 | 256 |
src/authentic2_idp_cas/models.py | ||
---|---|---|
1 | 1 |
from django.db import models |
2 |
from django.utils import six |
|
2 | 3 |
from django.utils.translation import ugettext_lazy as _ |
3 | 4 |
from django.utils.timezone import now |
4 | 5 |
from django.core.validators import URLValidator |
... | ... | |
12 | 13 | |
13 | 14 |
url_validator = URLValidator(schemes=['http', 'https', 'ftp', 'ftps', 'imap', 'imaps', 'sieve', 'smtp', 'smtps', 'ssh']) |
14 | 15 | |
16 |
@six.python_2_unicode_compatible |
|
15 | 17 |
class Service(LogoutUrlAbstract, Service): |
16 | 18 |
urls = models.TextField(max_length=128, |
17 | 19 |
verbose_name=_('urls')) |
... | ... | |
53 | 55 |
wanted.add(attribute.attribute_name) |
54 | 56 |
return list(wanted) |
55 | 57 | |
56 |
def __unicode__(self):
|
|
58 |
def __str__(self):
|
|
57 | 59 |
return self.name |
58 | 60 | |
59 | 61 |
class Meta: |
... | ... | |
61 | 63 |
verbose_name_plural = _('services') |
62 | 64 | |
63 | 65 | |
66 |
@six.python_2_unicode_compatible |
|
64 | 67 |
class Attribute(models.Model): |
65 | 68 |
service = models.ForeignKey(Service, verbose_name=_('service')) |
66 | 69 |
slug = models.SlugField(verbose_name=_('slug')) |
... | ... | |
70 | 73 |
verbose_name=_('enabled'), |
71 | 74 |
default=True) |
72 | 75 | |
73 |
def __unicode__(self):
|
|
76 |
def __str__(self):
|
|
74 | 77 |
return u'%s <- %s' % (self.slug, self.attribute_name) |
75 | 78 | |
76 | 79 |
class Meta: |
... | ... | |
81 | 84 |
def make_uuid(): |
82 | 85 |
return utils.make_id(constants.SERVICE_TICKET_PREFIX) |
83 | 86 | |
87 |
@six.python_2_unicode_compatible |
|
84 | 88 |
class Ticket(models.Model): |
85 | 89 |
'''Session ticket with a CAS 1.0 or 2.0 consumer''' |
86 | 90 | |
... | ... | |
107 | 111 | |
108 | 112 |
objects = managers.TicketManager() |
109 | 113 | |
110 |
def __unicode__(self):
|
|
114 |
def __str__(self):
|
|
111 | 115 |
return self.ticket_id |
112 | 116 | |
113 | 117 |
def valid(self): |
src/authentic2_idp_oidc/models.py | ||
---|---|---|
312 | 312 |
OrganizationalUnit, 'oidc_authorizations') |
313 | 313 | |
314 | 314 | |
315 |
@six.python_2_unicode_compatible |
|
315 | 316 |
class OIDCClaim(models.Model): |
316 | 317 |
client = models.ForeignKey( |
317 | 318 |
to=OIDCClient, verbose_name=_('client')) |
... | ... | |
325 | 326 |
max_length=128, blank=True, |
326 | 327 |
verbose_name=_('attribute scopes')) |
327 | 328 | |
328 |
def __unicode__(self):
|
|
329 |
def __str__(self):
|
|
329 | 330 |
return u'%s - %s - %s' % (self.name, self.value, self.scopes) |
330 | 331 | |
331 | 332 |
def get_scopes(self): |
src/django_rbac/models.py | ||
---|---|---|
23 | 23 |
from . import utils, constants, managers, backends |
24 | 24 | |
25 | 25 | |
26 |
@six.python_2_unicode_compatible |
|
26 | 27 |
class AbstractBase(models.Model): |
27 | 28 |
'''Abstract base model for all models having a name and uuid and a |
28 | 29 |
slug |
... | ... | |
44 | 45 | |
45 | 46 |
objects = managers.AbstractBaseManager() |
46 | 47 | |
47 |
def __unicode__(self):
|
|
48 |
def __str__(self):
|
|
48 | 49 |
return self.name |
49 | 50 | |
50 | 51 |
def __repr__(self): |
... | ... | |
100 | 101 |
swappable = constants.RBAC_OU_MODEL_SETTING |
101 | 102 | |
102 | 103 | |
104 |
@six.python_2_unicode_compatible |
|
103 | 105 |
class Operation(models.Model): |
104 | 106 |
name = models.CharField( |
105 | 107 |
max_length=128, |
... | ... | |
112 | 114 |
def natural_key(self): |
113 | 115 |
return [self.slug] |
114 | 116 | |
115 |
def __unicode__(self):
|
|
117 |
def __str__(self):
|
|
116 | 118 |
return six.text_type(_(self.name)) |
117 | 119 | |
118 | 120 |
def export_json(self): |
... | ... | |
124 | 126 |
Operation._meta.natural_key = ['slug'] |
125 | 127 | |
126 | 128 | |
129 |
@six.python_2_unicode_compatible |
|
127 | 130 |
class PermissionAbstractBase(models.Model): |
128 | 131 |
operation = models.ForeignKey( |
129 | 132 |
to=Operation, |
... | ... | |
157 | 160 |
"target": self.target.natural_key_json() |
158 | 161 |
} |
159 | 162 | |
160 |
def __unicode__(self):
|
|
163 |
def __str__(self):
|
|
161 | 164 |
ct = ContentType.objects.get_for_id(self.target_ct_id) |
162 | 165 |
ct_ct = ContentType.objects.get_for_model(ContentType) |
163 | 166 |
if ct == ct_ct: |
164 |
- |