websauna.system.admin.utils module

websauna.system.admin.utils.get_admin(request)[source]

Get hold of the default site admin interface root object.

Return type:<InterfaceClass websauna.system.admin.interfaces.IAdmin>
websauna.system.admin.utils.get_admin_for_model(admin, model)[source]

Return Admin resource for a model manager interface.

Return type:Resource
websauna.system.admin.utils.get_admin_resource_for_sqlalchemy_object(admin, instance)[source]

Return ModelAdmin.Resource for an SQLAlchemy object.

Example how to get an admin edit link for an SQLAlchemy object:

resource = get_admin_resource_for_sqlalchemy_object(request.admin, asset)
return request.resource_url(resource, "edit")
Parameters:
  • admin (<InterfaceClass websauna.system.admin.interfaces.IAdmin>) – request.admin
  • instance (object) – SQLAlchemy instance
Return type:

Resource

websauna.system.admin.utils.get_admin_url_for_sqlalchemy_object(admin, instance, view_name=None)[source]

Return direct URL to the admin view page of this object:

Example:

link = get_admin_url_for_sqlalchemy_object(request.admin, choice, view_name="edit")
Parameters:
  • admin (<InterfaceClass websauna.system.admin.interfaces.IAdmin>) – Admin root object
  • instance (object) – SQLAlchemy object
Return type:

str

websauna.system.admin.utils.get_model_admin_for_sqlalchemy_object(admin, instance)[source]

Return ModelAdmin resource for a SQLAlchemy object instance.

Return type:ModelAdmin