Example #1
0
    def get_user_profiles(cls):
        """Yield a series of all user profiles on this site which satisfy this
        role.

        """
        from lino.modlib.users.choicelists import UserTypes
        for p in UserTypes.items():
            if p.has_required_roles([cls]):
                yield p
Example #2
0
    def get_user_profiles(cls):
        """Yield a series of all user profiles on this site which satisfy this
        role.

        """
        from lino.modlib.users.choicelists import UserTypes
        for p in UserTypes.items():
            if p.has_required_roles([cls]):
                yield p
Example #3
0
def objects():

    from lino_welfare.modlib.newcomers.models import Broker, Faculty, Competence
    pcsw = dd.resolve_app('pcsw')
    Person = dd.resolve_model('contacts.Person')

    I = Instantiator(Broker).build
    #~ yield I(**babel_values('name',
        #~ de=u"Polizei", fr=u"Police",en=u"Police"))
    #~ yield I(**babel_values('name',
        #~ de=u"Jugendgericht", fr=u"Jugendgericht",en=u"Jugendgericht"))
    yield I(name="Police")
    yield I(name="Other PCSW")

    I = Instantiator(Faculty).build
    yield I(weight=10, **babel_values('name', de=u"Eingliederungseinkommen (EiEi)", fr=u"Revenu d'intégration sociale (RIS)",  en=u"EiEi"))
    yield I(weight=5, **babel_values('name', de=u"DSBE",                    fr=u"Service d'insertion socio-professionnelle",   en=u"DSBE"))
    yield I(weight=4, **babel_values('name', de=u"Ausländerbeihilfe",       fr=u"Aide sociale équivalente (pour étrangers)", en=u"Ausländerbeihilfe"))
    yield I(weight=6, **babel_values('name', de=u"Finanzielle Begleitung",  fr=u"Accompagnement budgétaire",     en=u"Finanzielle Begleitung"))
    yield I(weight=2, **babel_values('name', de=u"Laufende Beihilfe",       fr=u"Aide complémenataire",       en=u"Laufende Beihilfe"))

    #~ User = resolve_model('users.User')
    #~ yield User(username="******",
        #~ first_name="Caroline",last_name="Carnol",
        # ~ profile='200') # UserTypes.caroline)
    #~ FACULTIES = Cycler(Faculty.objects.all())
    #~ profiles = [p for p in UserTypes.items() if p.integ_level]
    #~ USERS = Cycler(User.objects.filter(profile__in=profiles))
    #~ for i in range(7):
        #~ yield Competence(user=USERS.pop(),faculty=FACULTIES.pop())
    #~ for p in pcsw.Client.objects.filter(client_state=pcsw.ClientStates.new):
        #~ p.faculty = FACULTIES.pop()
        #~ p.save()
    newcomers = dd.resolve_app('newcomers')
    users = dd.resolve_app('users')

    QUOTAS = Cycler(100, 60, 50, 20)
    FACULTIES = Cycler(newcomers.Faculty.objects.all())

    profiles = [
        p for p in UserTypes.items()
        if isinstance(p.role, IntegrationAgent)
        and not isinstance(p.role, dd.SiteStaff)]
    qs = users.User.objects.filter(profile__in=profiles)
    for u in qs:
        u.newcomer_quota = QUOTAS.pop()
        yield u

    USERS = Cycler(qs)
    for i in range(7):
        yield newcomers.Competence(user=USERS.pop(), faculty=FACULTIES.pop())

        for p in pcsw.Client.objects.exclude(
                client_state=pcsw.ClientStates.former):
            p.faculty = FACULTIES.pop()
            p.save()
Example #4
0
    def save(self, *args, **kwargs):
        super(Room, self). save(*args, **kwargs)

        if not self.calendar:
            return

        if not settings.SITE.loading_from_dump:

            user_types = set()
            for p in UserTypes.items():
                if p.has_required_roles([OfficeUser]):
                    user_types.add(p)
            User = settings.SITE.user_model
            for u in User.objects.filter(user_type__in=user_types):
                check_subscription(u, self.calendar)
Example #5
0
 def instance(cls):
     if cls._instance is None:
         # Call startup() to fill UserTypes also in a
         # multi-threaded environment:
         settings.SITE.startup()
         cls._instance = AnonymousUser()
         from lino.modlib.users.choicelists import UserTypes
         cls._instance.profile = UserTypes.get_by_value(
             settings.SITE.anonymous_user_type, None)
         if cls._instance.profile is None:
             raise Exception(
                 "Invalid value %r for `SITE.anonymous_user_type`. "
                 "Must be one of %s" % (
                     settings.SITE.anonymous_user_type,
                     [i.value for i in list(UserTypes.items())]))
     return cls._instance
Example #6
0
 def get_request_queryset(self, ar):
     profiles = [p for p in UserTypes.items()
                 if isinstance(p.role, SocialAgent)]
     return super(AvailableCoaches, self, ar).filter(
         models.Q(profile__in=profiles))