Beispiel #1
0
 def get(self):
     if self.user:
         if self.user.has_transfers() or self.request.get("dashboard") == "true":
             self.render("transfer_dashboard",
                 user_transfer=self.user.transfers(),
                 show_graph=True,
                 total_transfers=Application.app().total_transfers or 0,
             )
         else:
             self.render("transfer_step1", email=self.user.email, location=self.user.location())
     else:
         self.render("authorize", redirect_uri="%s/auth" % settings.APP_ENGINE_PATH, app_id=settings.FACEBOOK_APP_ID)
Beispiel #2
0
 def process_transfer_form(self, user):
     current_month_transfer = float(self.request.get("current_month"))
     
     if self.request.get("last_month"):
         last_month_transfer = float(self.request.get("last_month"))
     else:
         last_month_transfer = None
     
     if self.request.get("start_date"):
         from datetime import datetime
         start_date = datetime.strptime(self.request.get("start_date"), "%Y-%m-%d").date()
     else:
         start_date = None
             
     user_id = user.user_id
     parent = user.key()
     
     try:
         if start_date:
             # if we're here, it means that this is the first time the user has submitted the form
             # at this point, user has no transfers yet
             transfer = Transfer(
                 user_id=user_id, key_name=user_id, parent=parent, start_date=start_date, monthly_transfers=[current_month_transfer]
             )
         else:
             # user is updating or entering new transfer
             transfer = user.transfers()
         
             if last_month_transfer:
                 # update last month's transfer
                 transfer.monthly_transfers[-1] = last_month_transfer
             
             transfer.monthly_transfers.append(current_month_transfer)
                 
         transfer.put()
         self.render(
             'transfer_dashboard',
             message="Your transfer has been saved.",
             success=True,
             total_transfers=Application.app().total_transfers or 0,
             show_graph=True
         )
     except:
         self.render(
             "transfer_dashboard",
             message="Data not saved. Please ensure that you've entered the correct information.", 
             success=False
         )
Beispiel #3
0
import datetime

from models.transfer import Transfer
from models.application import Application

active_transfers = 0.0
total_transfers = 0.0
today = datetime.date.today()

for transfer in Transfer.all():
    if transfer.start_date <= today:
        total_transfers += sum(transfer.monthly_transfers)
        
app = Application.app()
app.total_transfers = total_transfers
app.put()