def get_businesses(owner = cousers.get_current_user(), limit = None): results = Business.all() results.filter("owner =", owner) if limit: results.filter("limit", limit) return results
def check_auth(self, *args, **kwargs): user = cousers.get_current_user() if user: return fn(self, user=user, *args, **kwargs) elif required: forward_to = self.request.url self.redirect(clean_redirect(AUTH_LOGIN_URI + "?forward_to=" + forward_to)) return False else: return fn(self, user=None, *args, **kwargs)
def receive_from_google(self): """Page called after logging in through Google""" forward_to = self.request.get("forward_to") if not forward_to: forward_to = DEFAULT_PAGE user = cousers.get_current_user() if not user: self.redirect(AUTH_LOGIN_URI) self.redirect(clean_redirect(forward_to))
def get_messages(to = cousers.get_current_user(), limit = None, send_date_start = None, send_date_end = None, unread_only = False): results = Messages.all() results.filter("to =", to) #TODO return to fill out filters once messages are being sent. if limit: pass if send_date_start: pass if send_date_end: pass if unread_only == True: results.filter("read =", not unread_only) return results
def create_business(): owner = cousers.get_current_user() new_business = Business(owner = owner, registered_date = int(time.time())) new_business.put() return new_business
def send_message(to, body, send_date = time.time(), sender = cousers.get_current_user(), subject = None): #msg = Messages(to, sender, body, send_date, subject) #msg.put() return ""#msg
def get_current_user(self): """AJAX request to get the current user details""" user = cousers.get_current_user() self.response.out.write(cousers.to_json(user))