def can_edit(self, user=None, request=None):
can = False<EOL>if request and not self.owner:<EOL><INDENT>if (getattr(settings, "<STR_LIT>", False)<EOL>and self.is_anonymous_owner(request)):<EOL><INDENT>can = True<EOL>if user and user.is_authenticated():<EOL><INDENT>self.owner = user<EOL>self.save()<EOL>msg = _("<STR_LIT>" % user)<EOL>messages.info(request, msg)<EOL><DEDENT><DEDENT><DEDENT>if self.edit_status == self.ANONYMOUS:<EOL><INDENT>can = True<EOL><DEDENT>elif not user.is_authenticated():<EOL><INDENT>pass<EOL><DEDENT>elif user == self.owner:<EOL><INDENT>can = True<EOL><DEDENT>elif self.edit_status == self.EDITORS and user in self.editors.all():<EOL><INDENT>can = True<EOL><DEDENT>return can<EOL>
Define if a user can edit or not the instance, according to his account
or the request.