Example #1
0
 def foxAlert():        
     companyid = request.environ.get('COMPANY_ID')
     username = request.environ.get('REMOTE_USER')
     propertyids = Property.get_property_ids_of_username(username)
     
     mc = Memcache()
     key = 'foxalert:{0}'.format(username)
     fox_alert = mc.get(key)
     if fox_alert == 'Saved': return False
     
     if len(propertyids) == 0:
         return {
                 'title': "Welcome!",
                 'message':"I'm here to help you. Let's get started by creating a property!",
                 'button':"Let's get started!",
                 'link':'/property/setup'
                 }
     
     if Property.totalUnitsInProperties(propertyids) == 0:
         return {
                 'title': "Create a unit!",
                 'message':"I just realized you don't have any units... let's create one!",
                 'button':"Okay!",
                 'link':'/property/setup/{0}'.format(propertyids[0])
                 }
         
     units_with_floorplans = Company.getUnitsWithFloorplans(propertyids)
     if len(units_with_floorplans) == 0:
         units = Unit.get_units_of_properties(propertyids)
         unitid = units[0].id
         propertyid = units[0].propertyid
         return {
                 'title': "No floorplans yet?",
                 'message': "Your units need floorplans. Floorplans are cool because you can apply them to other units in the same building.",
                 "button": "Add Floorplans",
                 'link': '/property/setup/{0}/{1}'.format(propertyid,unitid)
                 }
     
     lease = Lease.get_earliest(propertyids)
     if not lease:
         unitid = units_with_floorplans[0].id
         return {
                 'title': "Got leases?",
                 'message': "Are you ready to add a lease to one of your units?",
                 "button": "Yes, take me there!",
                 'link': '/unit/view/{0}'.format(unitid)
                 }
     
     mc.set(key, 'Saved', time=86400)
     
     return False