def summary(id):
    user = User.get_by_id(id)
    if current_user.id == user.id:
        images = Image.select().where(Image.user==id)
        donations = Donation.select().where(Donation.image.in_(images))
        ttl = Donation.select(fn.SUM(Donation.amount).alias('total')).where(Donation.image.in_(images))
        return render_template('checkouts/summary.html',donations=donations,ttl=ttl)
    return render_template('401.html'), 401     
Beispiel #2
0
 def total_donations(self):
     from models.donation import Donation
     total = 0
     for donation in Donation.select().where(Donation.image_id == self.id):
         # where user_id == self.id TO SEE TOTAL DONATIONS A USER HAS RECEIVED
         total = total + donation.amount
     return round(total)
Beispiel #3
0
    def total_donations(self):
        from models.donation import Donation
        total = 0
        for donation in Donation.select().where(Donation.image_id == self.id):
            total = total + donation.amount

        return round(total)
 def donation_received(self):
     from models.donation import Donation
     from models.image import Image
     donation_r = Donation.select().join(
         Image,
         on=(Donation.image_id == Image.id)).where(Image.user_id == self.id)
     donation_received = 0
     for d in donation_r:
         donation_received = donation_received + d.amount
     donation_received = round(donation_received, 2)
     return donation_received
Beispiel #5
0
def show_image(username, image_id):
    image = Image.get_by_id(image_id)
    donations = Donation.select().join(Image).join(User).where(
        Image.id == image_id)
    total_donation = 0
    for donation in donations:
        total_donation += donation.amount
    return render_template('users/image.html',
                           image=image,
                           donations=donations,
                           total_donation=total_donation)
Beispiel #6
0
    def top10(self):
        from models.donation import Donation

        return Donation.select().where(Donation.image == self.id).order_by(
            Donation.amount.desc()).limit(10)