def resource_can_edit(resource, user):
    if user.is_staff or user == resource.create_user or user == resource.update_user:
        return True
    else:
        return TagOwner.objects.filter(user__pk=user.id, tag__resourcetag__resource=resource).exists()