<commit_before>
from sqlalchemy import ForeignKey
from sqlalchemy.sql import select, func
from sqlalchemy.orm import relationship
# from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.dialects.postgresql import UUID

from geonature.utils.utilssqlalchemy import (
    serializableModel, serializableGeoModel
)


from geonature.utils.env import DB
from geonature.utils.errors import InsufficientRightsError
from geonature.core.users.models import TRoles
from geonature.core.gn_meta.models import TDatasets

from geoalchemy2 import Geometry


class ReleveModel():
    __abstract__ = True
    def user_is_observer_or_digitiser(self, user):
        observers = [d.id_role for d in self.observers]
        return user.id_role == self.id_digitiser or user.id_role in observers

    def user_is_in_dataset_actor(self, user):
        return self.id_dataset in TDatasets.get_user_datasets(user)

    def get_releve_if_allowed(self, user):
        """Return the releve if the user is allowed
          -params:
          user: object from TRole
        """
        if user.tag_object_code == '2':<commit_msg>correction bug ReleveModel<commit_after>
from sqlalchemy import ForeignKey
from sqlalchemy.sql import select, func
from sqlalchemy.orm import relationship
# from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.dialects.postgresql import UUID

from geonature.utils.utilssqlalchemy import (
    serializableModel, serializableGeoModel
)


from geonature.utils.env import DB
from geonature.utils.errors import InsufficientRightsError
from geonature.core.users.models import TRoles
from geonature.core.gn_meta.models import TDatasets

from geoalchemy2 import Geometry


class ReleveModel(DB.Model):
    __abstract__ = True
    def user_is_observer_or_digitiser(self, user):
        observers = [d.id_role for d in self.observers]
        return user.id_role == self.id_digitiser or user.id_role in observers

    def user_is_in_dataset_actor(self, user):
        return self.id_dataset in TDatasets.get_user_datasets(user)

    def get_releve_if_allowed(self, user):
        """Return the releve if the user is allowed
          -params:
          user: object from TRole
        """
        if user.tag_object_code == '2':
{'fraction_non_alphanumeric': 0.06403940886699508, 'fraction_numerical': 0.0017913121361397223, 'mean_word_length': 3.9644444444444447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6711239', 'n_tokens_mistral': 717, 'n_tokens_neox': 687, 'n_words': 187}