Django Admin
Account admin.
- class smarter.apps.secret.admin.CustomPasswordWidget(attrs=None)[source]
Bases:
WidgetCustom widget for the password field in the UserChangeForm.
- property media
- class smarter.apps.secret.admin.SecretAdmin(model, admin_site)[source]
Bases:
SmarterCustomerModelAdmin,SmarterHelperMixinSecret model admin.
This is a primary Smarter resource, that descends directly from MetaDataWithOwnershipModel. Visibility of Secrets is determined by ownership and role.
- change_view(request, object_id, form_url='', extra_context=None)[source]
Remember the request, for
display_value(), then render the change form.- Parameters:
request – The admin request.
object_id – The Secret’s id.
form_url – The form’s action url.
extra_context – Extra template context.
- Returns:
The rendered change form.
- changelist_view(request, extra_context=None)[source]
Remember the request, for
display_value(), then render the list.- Parameters:
request – The admin request.
extra_context – Extra template context.
- Returns:
The rendered list.
- display_value(obj)[source]
Display the secret value as ‘****’ for users who do not have permission to view it.
- fields = ('name', 'user_profile', 'description', 'expires_at', 'display_value')
- form
alias of
SecretAdminForm
- get_form(request, obj=None, change=False, **kwargs)[source]
Return the admin form class, subclassed to pass the requesting user to the form.
- Parameters:
request – The admin request.
obj – The Secret being changed, or None when adding one.
change – True when changing an existing Secret.
- Returns:
The form class.
- get_queryset(request)[source]
Restrict the admin list to the Secrets that the requesting user has ownership permission for.
- Parameters:
request (
HttpRequest) – The admin request.- Returns:
The Secrets, or an empty queryset if the request has no resolved user.
- list_display = ('user_profile', 'name', 'description', 'created_at', 'updated_at', 'last_accessed', 'expires_at')
- logger_prefix = '\x1b[1;31msmarter.apps.secret.admin\x1b[0m.SecretAdmin()'
- property media
- readonly_fields = ('created_at', 'updated_at', 'last_accessed', 'display_value')
- request: HttpRequest
- save_model(request, obj, form, change)[source]
Encrypt the submitted value, if any, into the Secret, then save it.
A blank value leaves the stored encrypted value as it is.
- Parameters:
request (
HttpRequest) – The admin request.obj (
Secret) – The Secret.form (
SecretAdminForm) – The submitted form.change – True when changing an existing Secret.
- user_profile: UserProfile
- class smarter.apps.secret.admin.SecretAdminForm(*args, **kwargs)[source]
Bases:
ModelFormCustom form for SecretAdmin to handle the transient ‘value’ field.
Form fields:
value: Value (CharField)
- clean_value()[source]
Check that the submitted secret value, if any, is a string.
- Returns:
The value.
- Raises:
forms.ValidationError – when the value is not a string.
- list_display = ['name', 'user_profile', 'description', 'expires_at', 'value']
- logger_prefix = '\x1b[1;31msmarter.apps.secret.admin\x1b[0m.SecretAdminForm()'
- property media
Return all media required to render the widgets on this form.