<commit_before># -*- coding: utf-8 -*-
# (c) 2016 <NAME> - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, api, exceptions, _


class CalendarEvent(models.Model):
    _inherit = 'calendar.event'

    @api.multi
    def write(self, vals):
        if (self.env.uid != self.env.ref('base.user_root').id and
                self.filtered(lambda x: x.create_uid.id != self.env.uid)):
            raise exceptions.Warning(
                _("You can not change this meeting, because you are not the "
                  "user who created it"))
        return super(CalendarEvent, self).write(vals)


class CalendarAttendee(models.Model):
    _inherit = 'calendar.attendee'

    @api.multi
    def do_tentative(self, *args):
        self._user_control()
        return super(CalendarAttendee, self).do_tentative(*args)

    @api.multi
    def do_accept(self, *args):
        self._user_control()
        return super(CalendarAttendee, self).do_accept(*args)

    @api.multi
    def do_decline(self, *args):
        self._user_control()
        return super(CalendarAttendee, self).do_decline(*args)

    def _user_control(self):
        if (self.env.uid != self.env.ref('base.user_root').id and
                self.filtered(lambda x: x.event_id.create_uid.id !=
                              self.env.uid)):
            raise exceptions.Warning(
                _("You can not change this meeting, because you are not the "<commit_msg>[IMP] calendar_event_without_group: If a user has not created a meeting, he can not accept invitations, or cancel.<commit_after># -*- coding: utf-8 -*-
# (c) 2016 <NAME> - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, api, exceptions, _
from openerp import SUPERUSER_ID


class CalendarEvent(models.Model):
    _inherit = 'calendar.event'

    @api.multi
    def write(self, vals):
        if (self.env.uid != SUPERUSER_ID and
                self.filtered(lambda x: x.create_uid.id != self.env.uid)):
            raise exceptions.Warning(
                _("You can not change this meeting, because you are not the "
                  "user who created it"))
        return super(CalendarEvent, self).write(vals)


class CalendarAttendee(models.Model):
    _inherit = 'calendar.attendee'

    @api.multi
    def do_tentative(self, *args):
        self._user_control()
        return super(CalendarAttendee, self).do_tentative(*args)

    @api.multi
    def do_accept(self, *args):
        self._user_control()
        return super(CalendarAttendee, self).do_accept(*args)

    @api.multi
    def do_decline(self, *args):
        self._user_control()
        return super(CalendarAttendee, self).do_decline(*args)

    def _user_control(self):
        if (self.env.uid != SUPERUSER_ID and
                self.filtered(lambda x: x.event_id.create_uid.id !=
                              self.env.uid)):
            raise exceptions.Warning(
                _("You can not change this meeting, because you are not the "
{'fraction_non_alphanumeric': 0.11649214659685864, 'fraction_numerical': 0.005235602094240838, 'mean_word_length': 2.450338600451467, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2394302', 'n_tokens_mistral': 964, 'n_tokens_neox': 918, 'n_words': 228}