0001-auth_saml-improve-journal-message-for-related-object.patch
src/authentic2_auth_saml/journal_event_types.py | ||
---|---|---|
26 | 26 |
@classmethod |
27 | 27 |
def record(cls, *, user, session, related_object, data=None): |
28 | 28 |
data = data or {} |
29 |
data.update({'related_object': repr(related_object)})
|
|
29 |
data.update({'related_object': related_object.get_journal_text()})
|
|
30 | 30 |
super().record(user=user, session=session, references=[related_object.authenticator], data=data) |
31 | 31 | |
32 | 32 | |
... | ... | |
39 | 39 |
(authenticator,) = event.get_typed_references(SAMLAuthenticator) |
40 | 40 |
related_object = event.get_data('related_object') |
41 | 41 |
if context != authenticator: |
42 |
return _('creation of {related_object} in authenticator "{authenticator}"').format(
|
|
42 |
return _('creation of object "{related_object}" in authenticator "{authenticator}"').format(
|
|
43 | 43 |
related_object=related_object, authenticator=authenticator |
44 | 44 |
) |
45 | 45 |
else: |
46 |
return _('creation of %s') % related_object
|
|
46 |
return _('creation of object "%s"') % related_object
|
|
47 | 47 | |
48 | 48 | |
49 | 49 |
class SAMLAuthenticatorRelatedObjectEdit(SAMLAuthenticatorEvents): |
... | ... | |
66 | 66 |
new = event.get_data('new') or {} |
67 | 67 |
edited_attributes = ', '.join(new) or '' |
68 | 68 |
if context != authenticator: |
69 |
return _('edit {related_object} in authenticator "{authenticator}" ({change})').format( |
|
69 |
return _( |
|
70 |
'edit of object "{related_object}" in authenticator "{authenticator}" ({change})' |
|
71 |
).format( |
|
70 | 72 |
related_object=related_object, |
71 | 73 |
authenticator=authenticator, |
72 | 74 |
change=edited_attributes, |
73 | 75 |
) |
74 | 76 |
else: |
75 |
return _('edit {related_object} ({change})').format(
|
|
77 |
return _('edit of object "{related_object}" ({change})').format(
|
|
76 | 78 |
related_object=related_object, change=edited_attributes |
77 | 79 |
) |
78 | 80 | |
... | ... | |
86 | 88 |
(authenticator,) = event.get_typed_references(SAMLAuthenticator) |
87 | 89 |
related_object = event.get_data('related_object') |
88 | 90 |
if context != authenticator: |
89 |
return _('deletion of {related_object} in authenticator "{authenticator}"').format(
|
|
91 |
return _('deletion of object "{related_object}" in authenticator "{authenticator}"').format(
|
|
90 | 92 |
related_object=related_object, authenticator=authenticator |
91 | 93 |
) |
92 | 94 |
else: |
93 |
return _('deletion of %s') % related_object |
|
95 |
return _('deletion of object "%s"') % related_object |
src/authentic2_auth_saml/models.py | ||
---|---|---|
205 | 205 |
class Meta: |
206 | 206 |
abstract = True |
207 | 207 | |
208 |
def __repr__(self):
|
|
209 |
return '%s (%s)' % (self._meta.object_name, self.pk)
|
|
208 |
def get_journal_text(self):
|
|
209 |
return '%s (%s)' % (self._meta.verbose_name, self.pk)
|
|
210 | 210 | |
211 | 211 |
def get_user_field_display(self): |
212 | 212 |
from authentic2.forms.widgets import SelectAttributeWidget |
tests/test_manager_journal.py | ||
---|---|---|
727 | 727 |
'user': 'agent', |
728 | 728 |
}, |
729 | 729 |
{ |
730 |
'message': 'creation of SetAttributeAction (%s) in authenticator "SAML"'
|
|
730 |
'message': 'creation of object "Set an attribute (%s)" in authenticator "SAML"'
|
|
731 | 731 |
% set_attribute_action.pk, |
732 | 732 |
'timestamp': 'Jan. 3, 2020, 8 a.m.', |
733 | 733 |
'type': 'authenticator.saml.related_object.creation', |
734 | 734 |
'user': 'agent', |
735 | 735 |
}, |
736 | 736 |
{ |
737 |
'message': 'edit SetAttributeAction (%s) in authenticator "SAML" (from_name)'
|
|
737 |
'message': 'edit of object "Set an attribute (%s)" in authenticator "SAML" (from_name)'
|
|
738 | 738 |
% set_attribute_action.pk, |
739 | 739 |
'timestamp': 'Jan. 3, 2020, 9 a.m.', |
740 | 740 |
'type': 'authenticator.saml.related_object.edit', |
741 | 741 |
'user': 'agent', |
742 | 742 |
}, |
743 | 743 |
{ |
744 |
'message': 'deletion of SetAttributeAction (%s) in authenticator "SAML"'
|
|
744 |
'message': 'deletion of object "Set an attribute (%s)" in authenticator "SAML"'
|
|
745 | 745 |
% set_attribute_action.pk, |
746 | 746 |
'timestamp': 'Jan. 3, 2020, 10 a.m.', |
747 | 747 |
'type': 'authenticator.saml.related_object.deletion', |
748 |
- |