Django Admin

Account admin.

class smarter.apps.secret.admin.CustomPasswordWidget(attrs=None)[source]

Bases: Widget

Custom widget for the password field in the UserChangeForm.

property media
render(name, value, attrs=None, renderer=None)[source]

use a placeholder and let the admin render the anchor correctly This works because the admin will replace __pk__ with the actual user id

class smarter.apps.secret.admin.SecretAdmin(model, admin_site)[source]

Bases: SmarterCustomerModelAdmin, SmarterHelperMixin

Secret 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]
changelist_view(request, extra_context=None)[source]

The ‘change list’ admin view for this model.

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 a Form class for use in the admin add view. This is used by add_view and change_view.

get_queryset(request)[source]

Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.

list_display = ('user_profile', 'name', 'description', 'created_at', 'updated_at', 'last_accessed', 'expires_at')
logger_prefix = '\x1b[1;31msmarter.apps.secret.admin.SecretAdmin()\x1b[0m'
property media
model

alias of Secret

readonly_fields = ('created_at', 'updated_at', 'last_accessed', 'display_value')
request: HttpRequest
save_model(request, obj, form, change)[source]

Given a model instance save it to the database.

user: User
user_profile: UserProfile
class smarter.apps.secret.admin.SecretAdminForm(*args, **kwargs)[source]

Bases: ModelForm

Custom form for SecretAdmin to handle the transient ‘value’ field.

Form fields:

__init__(*args, **kwargs)[source]
clean()[source]

Ensure the transient ‘value’ field is included in cleaned_data.

clean_value()[source]
list_display = ['name', 'user_profile', 'description', 'expires_at', 'value']
logger_prefix = '\x1b[1;31msmarter.apps.secret.admin.SecretAdminForm()\x1b[0m'
property media

Return all media required to render the widgets on this form.

model

alias of Secret