Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Imports
3from django.utils.translation import gettext_lazy as _
4from superdjango import ui
6# Exports
8__all__ = (
9 "HistoryUI",
10)
12# Models
15class HistoryUI(ui.ModelUI):
16 """Provide a UI for history entry."""
18 controls = {
19 'object_label': ui.controls.CharControl(label=_("record name")),
20 'object_id': ui.controls.CharControl(label=_("record ID")),
21 'verbose_name': ui.controls.CharControl(label=_("record type")),
22 }
24 detail_options = ui.DetailOptions(
25 "added_dt",
26 "verbose_name",
27 "object_label",
28 "action",
29 "performed_by",
30 "absolute_url",
31 "field_changes",
32 )
33 list_options = ui.ListOptions(
34 "object_label",
35 "object_id",
36 "verbose_name",
37 "action",
38 "performed_by",
39 "added_dt",
40 link_field="object_label"
41 )
43 def check_permission(self, request, verb, field=None, record=None):
44 """Only super users have delete access. All others are checked only for detail and list permissions."""
45 if verb == ui.VERB.DELETE:
46 return request.user.is_superuser
48 if verb in (ui.VERB.DETAIL, ui.VERB.LIST):
49 return super().check_permission(request, verb, field=field, record=record)
51 return False