Beispiel #1
0
    def get(self):
        date = datetime.datetime.strptime(self.request.GET.get('date'), '%d.%m.%Y')
        start_date = datetime.datetime.combine(date, day_start)
        end_date = datetime.datetime.combine(date, day_end)
        entries_p = self.session.query(User.id, User.name, func.min(PresenceEntry.ts), func.max(PresenceEntry.ts))\
                              .filter(User.id==PresenceEntry.user_id)\
                              .filter((User.location=="poznan") | (User.location==None))\
                              .filter(PresenceEntry.ts>=start_date)\
                              .filter(PresenceEntry.ts<=end_date)\
                              .group_by(User.id, User.name)\
                              .order_by(User.name)

        entries_w = self.session.query(User.id, User.name, func.min(PresenceEntry.ts), func.max(PresenceEntry.ts))\
                              .filter(User.id==PresenceEntry.user_id)\
                              .filter(User.location=="wroclaw")\
                              .filter(PresenceEntry.ts>=start_date)\
                              .filter(PresenceEntry.ts<=end_date)\
                              .group_by(User.id, User.name)\
                              .order_by(User.name)

        return dict(
            entries_p=((user_id, user_name, start, stop, start.time() > hour_9) for (user_id, user_name, start, stop) in entries_p),
            entries_w=((user_id, user_name, start, stop, start.time() > hour_9) for (user_id, user_name, start, stop) in entries_w),
            date=date,
            prev_date=previous_day(date),
            next_date=next_day(date),
            excuses=excuses.presence(),
            justification=excuses.presence_status(date, self.request.user.id),
        )
Beispiel #2
0
    def get(self):
        date = self.request.GET.get('date')
        if date:
            date = datetime.datetime.strptime(date, '%d.%m.%Y')
        else:
            date = datetime.date.today()
        start_date = datetime.datetime.combine(date, day_start)
        end_date = datetime.datetime.combine(date, day_end)

        def get_entries(city):
            if city in ['wroclaw', 'poznan']:
                return self.session.query(User.id, User.name, func.min(PresenceEntry.ts), func.max(PresenceEntry.ts))\
                              .filter(User.id == PresenceEntry.user_id)\
                              .filter((User.location == city) | (User.location == None))\
                              .filter(PresenceEntry.ts >= start_date)\
                              .filter(PresenceEntry.ts <= end_date)\
                              .group_by(User.id, User.name)\
                              .order_by(User.name)

        def get_lates(city):
            if city in ['wroclaw', 'poznan']:
                return self.session.query(User.id, User.name, Late.late_start, Late.late_end)\
                            .filter(User.id == Late.user_id)\
                            .filter(User.location == city)\
                            .filter(Late.date == date)\
                            .order_by(User.name)

        def get_absence(city):
            if city in ['wroclaw', 'poznan']:
                return self.session.query(User.id, User.name)\
                            .filter(User.id == Absence.user_id)\
                            .filter(User.location == city)\
                            .filter(Absence.date_start <= date)\
                            .filter(Absence.date_end >= date)\
                            .order_by(User.name)

        return dict(
            date=date,
            prev_date=h.previous_day(date),
            next_date=h.next_day(date),
            excuses=excuses.presence(),
            justification=excuses.presence_status(date, self.request.user.id),
            city=[
                dict(
                    name=u'Poznań',
                    entries=((user_id, user_name, start, stop, start.time() > hour_9) for (user_id, user_name, start, stop) in get_entries('poznan')),
                    late=get_lates('poznan'),
                    absence=get_absence('poznan'),
                ),
                dict(
                    name=u'Wrocław',
                    entries=((user_id, user_name, start, stop, start.time() > hour_9) for (user_id, user_name, start, stop) in get_entries('wroclaw')),
                    late=get_lates('wroclaw'),
                    absence=get_absence('wroclaw'),
                 ),
            ],
        )
Beispiel #3
0
    def get(self):
        date = self.request.GET.get('date')
        if date:
            date = datetime.datetime.strptime(date, '%d.%m.%Y')
        else:
            date = datetime.date.today()
        start_date = datetime.datetime.combine(date, day_start)
        end_date = datetime.datetime.combine(date, day_end)

        def get_entries(city):
            return DBSession.query(User.id, User.name, func.min(PresenceEntry.ts), func.max(PresenceEntry.ts))\
                          .filter(User.id == PresenceEntry.user_id)\
                          .filter((User.location == city) | (User.location == None))\
                          .filter(PresenceEntry.ts >= start_date)\
                          .filter(PresenceEntry.ts <= end_date)\
                          .group_by(User.id, User.name)\
                          .order_by(User.name)

        def get_lates(city):
            return DBSession.query(User.id, User.name, Late.late_start, Late.late_end)\
                        .filter(User.id == Late.user_id)\
                        .filter(User.location == city)\
                        .filter(Late.date == date)\
                        .order_by(User.name)

        def get_absence(city):
            return DBSession.query(User.id, User.name)\
                        .filter(User.id == Absence.user_id)\
                        .filter(User.location == city)\
                        .filter(Absence.date_start <= date)\
                        .filter(Absence.date_end >= date)\
                        .order_by(User.name)

        locations = []
        for name, (fullname, shortcut) in self.request.user.get_locations():
            presences = dict(
                shortcut=shortcut,
                name=fullname,
                entries=((user_id, user_name, start, stop,
                          start.time() > hour_9)
                         for (user_id, user_name, start,
                              stop) in get_entries(name)),
                late=get_lates(name),
                absence=get_absence(name),
            )
            locations.append(presences)

        return dict(
            date=date,
            prev_date=h.previous_day(date),
            next_date=h.next_day(date),
            excuses=excuses.presence(),
            justification=excuses.presence_status(date, self.request.user.id),
            locations=locations,
        )
Beispiel #4
0
    def get(self):
        date = self.request.GET.get('date')
        if date:
            date = datetime.datetime.strptime(date, '%d.%m.%Y')
        else:
            date = datetime.date.today()
        start_date = datetime.datetime.combine(date, day_start)
        end_date = datetime.datetime.combine(date, day_end)

        def get_entries(city):
            return DBSession.query(User.id, User.name, func.min(PresenceEntry.ts), func.max(PresenceEntry.ts))\
                          .filter(User.id == PresenceEntry.user_id)\
                          .filter((User.location == city) | (User.location == None))\
                          .filter(PresenceEntry.ts >= start_date)\
                          .filter(PresenceEntry.ts <= end_date)\
                          .group_by(User.id, User.name)\
                          .order_by(User.name)

        def get_lates(city):
            return DBSession.query(User.id, User.name, Late.late_start, Late.late_end)\
                        .filter(User.id == Late.user_id)\
                        .filter(User.location == city)\
                        .filter(Late.date == date)\
                        .order_by(User.name)

        def get_absence(city):
            return DBSession.query(User.id, User.name)\
                        .filter(User.id == Absence.user_id)\
                        .filter(User.location == city)\
                        .filter(Absence.date_start <= date)\
                        .filter(Absence.date_end >= date)\
                        .order_by(User.name)

        locations = []
        for name, (fullname, shortcut) in self.request.user.get_locations():
            presences = dict(
                shortcut=shortcut,
                name=fullname,
                entries=((user_id, user_name, start, stop, start.time() > hour_9) for (user_id, user_name, start, stop) in get_entries(name)),
                late=get_lates(name),
                absence=get_absence(name),
            )
            locations.append(presences)

        return dict(
            date=date,
            prev_date=h.previous_day(date),
            next_date=h.next_day(date),
            excuses=excuses.presence(),
            justification=excuses.presence_status(date, self.request.user.id),
            locations=locations,
        )