Skip to content

Commit

Permalink
[IMP] improve error message
Browse files Browse the repository at this point in the history
and add an error log when access is refused
  • Loading branch information
gurneyalex committed Mar 30, 2021
1 parent d827554 commit 90f9eb0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions connector_office_365/models/calendar_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,14 @@ def office_365_push(self):
record._office_365_push_create()
else:
if record.user_id.id != self.env.user.id:
_logger.error(
'office_365_push: attempt by user %s to push '
'record %s owned by user %s',
self.env.user, record, record.user_id)
raise exceptions.UserError(
_('You are not the organizer of the event "{}"'
_('You are not the organizer of the event "{}" ({})'
' please try to edit this event in Office 365.')
.format(record.name)
.format(record.name, record.user_id.name)
)
record._office_365_push_update()

Expand Down Expand Up @@ -239,9 +243,14 @@ def unlink(self):
for event in self:
if event.office_365_id and not self.env.context.get('office_365_force', False):
if event.user_id.id != user.id:
_logger.error(
'calendar event unlink: attempt by user %s to unlink '
'record %s owned by user %s',
self.env.user, event, event.user_id)
raise exceptions.UserError(
_('You are not the organizer of this '
'event please try delete this event in Office 365.')
_('You are not the organizer of the '
'event {} ({}) please try delete this event in Office 365.').format(
event.name, event.user_id.name)
)
try:
user.office_365_delete(
Expand Down

0 comments on commit 90f9eb0

Please sign in to comment.