Exemplo n.º 1
0
    def index(self):
        c = TemplateContext()
        c.heading = _('Statistics')

        c.members = len(self.mf.getUserList())
        activeMembers = self.mf.getActiveMemberList()
        c.activeMembers = len(activeMembers)
        c.formerMembers = c.members - c.activeMembers

        c.paymentsOk = 0

        for uid in activeMembers:
            last_payment = None

            try:
                last_payment = self.db.query(Payment).filter(
                    and_(Payment.uid == uid, Payment.verified == 1)).order_by(
                        Payment.date.desc()).limit(1)[0]
            except Exception as e:
                ''' Don't care if there is no payment '''
                pass

            if last_payment:
                d = last_payment.date
                today = datetime.datetime.now().date()

                if d.year > today.year or (d.year == today.year
                                           and d.month >= today.month):
                    c.paymentsOk += 1

        c.paymentsNotOk = c.activeMembers - c.paymentsOk

        return self.render('/statistics/index.mako', template_context=c)
Exemplo n.º 2
0
    def index(self):
        c = TemplateContext()
        c.heading = _("Statistics")

        c.members = len(self.mf.getUserList())
        activeMembers = self.mf.getActiveMemberList()
        c.activeMembers = len(activeMembers)
        c.formerMembers = c.members - c.activeMembers

        c.paymentsOk = 0

        for uid in activeMembers:
            last_payment = None

            try:
                last_payment = (
                    self.db.query(Payment)
                    .filter(and_(Payment.uid == uid, Payment.verified == 1))
                    .order_by(Payment.date.desc())
                    .limit(1)[0]
                )
            except Exception as e:
                """ Don't care if there is no payment """
                pass

            if last_payment:
                d = last_payment.date
                today = datetime.datetime.now().date()

                if d.year > today.year or (d.year == today.year and d.month >= today.month):
                    c.paymentsOk += 1

        c.paymentsNotOk = c.activeMembers - c.paymentsOk

        return self.render("/statistics/index.mako", template_context=c)