Browse Source
Module 'auditlog' - 'display_name' fields added for the user session and HTTP requests models
pull/1040/head
sebalix
9 years ago
committed by
Enric Tobella
No known key found for this signature in database
GPG Key ID: 1A2546A1B7BA2451
4 changed files with
27 additions and
7 deletions
-
auditlog/models/http_request.py
-
auditlog/models/http_session.py
-
auditlog/views/http_request_view.xml
-
auditlog/views/http_session_view.xml
|
|
@ -27,7 +27,9 @@ class AuditlogHTTPRequest(models.Model): |
|
|
|
_name = 'auditlog.http.request' |
|
|
|
_description = u"Auditlog - HTTP request log" |
|
|
|
_order = "create_date DESC" |
|
|
|
_rec_name = 'display_name' |
|
|
|
|
|
|
|
display_name = fields.Char(u"Name", compute="_display_name") |
|
|
|
name = fields.Char(u"Path") |
|
|
|
root_url = fields.Char(u"Root URL") |
|
|
|
user_id = fields.Many2one( |
|
|
@ -38,6 +40,16 @@ class AuditlogHTTPRequest(models.Model): |
|
|
|
log_ids = fields.One2many( |
|
|
|
'auditlog.log', 'http_request_id', string=u"Logs") |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def _display_name(self): |
|
|
|
for httprequest in self: |
|
|
|
create_date = fields.Datetime.from_string(httprequest.create_date) |
|
|
|
tz_create_date = fields.Datetime.context_timestamp( |
|
|
|
httprequest, create_date) |
|
|
|
httprequest.display_name = u"%s (%s)" % ( |
|
|
|
httprequest.name or '?', |
|
|
|
fields.Datetime.to_string(tz_create_date)) |
|
|
|
|
|
|
|
@api.model |
|
|
|
def current_http_request(self): |
|
|
|
"""Create a log corresponding to the current HTTP request, and returns |
|
|
|
|
|
@ -27,13 +27,25 @@ class AuditlogtHTTPSession(models.Model): |
|
|
|
_name = 'auditlog.http.session' |
|
|
|
_description = u"Auditlog - HTTP User session log" |
|
|
|
_order = "create_date DESC" |
|
|
|
_rec_name = 'display_name' |
|
|
|
|
|
|
|
display_name = fields.Char(u"Name", compute="_display_name") |
|
|
|
name = fields.Char(u"Session ID") |
|
|
|
user_id = fields.Many2one( |
|
|
|
'res.users', string=u"User") |
|
|
|
http_request_ids = fields.One2many( |
|
|
|
'auditlog.http.request', 'http_session_id', string=u"HTTP Requests") |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def _display_name(self): |
|
|
|
for httpsession in self: |
|
|
|
create_date = fields.Datetime.from_string(httpsession.create_date) |
|
|
|
tz_create_date = fields.Datetime.context_timestamp( |
|
|
|
httpsession, create_date) |
|
|
|
httpsession.display_name = u"%s (%s)" % ( |
|
|
|
httpsession.user_id and httpsession.user_id.name or '?', |
|
|
|
fields.Datetime.to_string(tz_create_date)) |
|
|
|
|
|
|
|
@api.model |
|
|
|
def current_http_session(self): |
|
|
|
"""Create a log corresponding to the current HTTP user session, and |
|
|
|
|
|
@ -12,11 +12,8 @@ |
|
|
|
<field name="root_url"/> |
|
|
|
<field name="name"/> |
|
|
|
<field name="create_date"/> |
|
|
|
</group> |
|
|
|
<group string="User session"> |
|
|
|
<field name="user_id"/> |
|
|
|
<field name="http_session_id"/> |
|
|
|
<field name="user_context"/> |
|
|
|
<field name="http_session_id"/> |
|
|
|
</group> |
|
|
|
<group string="Logs"> |
|
|
|
<field name="log_ids" nolabel="1"/> |
|
|
@ -33,7 +30,6 @@ |
|
|
|
<tree string="HTTP Requests"> |
|
|
|
<field name="name"/> |
|
|
|
<field name="create_date"/> |
|
|
|
<field name="user_id"/> |
|
|
|
<field name="http_session_id"/> |
|
|
|
</tree> |
|
|
|
</field> |
|
|
|
|
|
@ -10,8 +10,8 @@ |
|
|
|
<sheet> |
|
|
|
<group string="User session"> |
|
|
|
<field name="user_id"/> |
|
|
|
<field name="name"/> |
|
|
|
<field name="create_date"/> |
|
|
|
<field name="name"/> |
|
|
|
</group> |
|
|
|
<group string="HTTP Requests"> |
|
|
|
<field name="http_request_ids" nolabel="1"/> |
|
|
@ -27,8 +27,8 @@ |
|
|
|
<field name="arch" type="xml"> |
|
|
|
<tree string="User sessions"> |
|
|
|
<field name="user_id"/> |
|
|
|
<field name="name"/> |
|
|
|
<field name="create_date"/> |
|
|
|
<field name="name"/> |
|
|
|
</tree> |
|
|
|
</field> |
|
|
|
</record> |
|
|
|