Beispiel #1
0
    def find_by_username(cls, username):
        key = 'csr_detail_%s' % username
        if cache.get(key):
            return cache.get(key)

        csr = CSR.query.filter(CSR.deleted.is_(None)).filter_by(username=username.split("idir/")[-1]).first()
        cache.set(key, csr)
        return csr
Beispiel #2
0
    def find_by_userid(cls, userid):
        csr = CSR.query.filter(
            CSR.deleted.is_(None)).filter_by(csr_id=userid).first()
        key = (CSR.format_string % csr.username).lower()
        if cache.get(key):
            return cache.get(key)

        cache.set(key, csr)
        return csr
Beispiel #3
0
    def find_by_username(cls, username):
        idir_id = username.split("idir/")[-1]
        key = (CSR.format_string % idir_id).lower()
        if cache.get(key):
            return cache.get(key)

        csr = CSR.query.filter(
            CSR.deleted.is_(None)).filter_by(username=idir_id).first()
        cache.set(key, csr)
        return csr
Beispiel #4
0
    def find_by_username(cls, username):
        #   Possible keycloak->TheQ id values are user@idir->user, idir/user->user or user@bceid->user@bceid
        idir_id = username.split("idir/")[-1].lower()
        if "@idir" in username:
            idir_id = username.split("@idir")[0].lower()
        key = CSR.format_string % idir_id
        if cache.get(key):
            return cache.get(key)

        csr = CSR.query.filter(
            CSR.deleted.is_(None)).filter(CSR.username == idir_id).first()

        cache.set(key, csr)
        return csr
Beispiel #5
0
 def find_by_id(cls, office_id: int):
     """Return a Office by office_id."""
     key = Office.format_string % office_id
     office = cache.get(key)
     if not office:
         office = cls.query.get(office_id)
         office.timeslots
         office.timezone
     return office
Beispiel #6
0
    def get_all_active_offices(cls):
        """Return all active offices."""
        from app.schemas.theq import OfficeSchema

        active_offices = cache.get(Office.offices_cache_key)
        if not active_offices:
            office_schema = OfficeSchema(many=True)
            active_offices = office_schema.dump(
                Office.query.filter(Office.deleted.is_(None)))
            cache.set(Office.offices_cache_key, active_offices)
        return active_offices