def get(self, **kwargs): if not self.session.has_key('frontend.querystring'): show_extended_filter = self.request.GET.get('filtro_extendido', default=0) dict = {} for key in self.request.GET.keys(): value = self.request.GET.get(key) if value is not None: # and len(str(value))>0: dict[key] = value dict['prop_operation_id'] = str(Property._OPER_SELL) dict['show_extended_filter'] = show_extended_filter if self.session.has_key('map.filter.realestate'): dict['map.filter.realestate'] = self.session.pop( 'map.filter.realestate') else: dict = self.session.pop( 'frontend.querystring') #self.session.clear() return self.render_response('frontend/index.html', analytics_mark='mapa', config_arrayJSON=json.dumps(config_array), config_array=config_array, max_results=MAX_QUERY_RESULTS, preset=dict, presetJSON=json.dumps(dict), _OPER_SELL=Property._OPER_SELL, _OPER_RENT=Property._OPER_RENT)
def send_contact_mail(self): contacts = Contact.query(Contact.sent != True) count = contacts.count() if count: datetime_handler = lambda obj: obj.isoformat() \ if isinstance(obj, datetime) else None message = json.dumps( [contact.to_dict() for contact in contacts], default=datetime_handler, indent=4 ) mail.send_mail( sender="Getmewrite.com Support <*****@*****.**>", to="Mona <*****@*****.**>", subject="You have {0} new contact(s)".format(count), body=message ) self.response.write(message) logger.info( 'Send daily mail success, {0} new contacts'.format(count)) put_list = [] for contact in contacts: contact.sent = True put_list.append(contact) ndb.put_multi(put_list)
def send_message(cls, log_line, event): message = { 'event': event, 'date': datetime_filter(log_line.timestamp, format='%b %d, %Y'), 'time': datetime_filter(log_line.timestamp, format='%I:%M%p'), 'username': log_line.username, 'chat': log_line.chat, 'death_message': log_line.death_message, 'achievement_message': log_line.achievement_message } client_ids = cls.get_client_ids(log_line.server_key) if client_ids: for client_id in client_ids: try: user = cls.get_user_key(client_id).get() if user is not None: timezone = user.timezone message['date'] = datetime_filter(log_line.timestamp, format='%b %d, %Y', timezone=timezone) message['time'] = datetime_filter(log_line.timestamp, format='%I:%M%p', timezone=timezone) message_json = json.dumps(message) channel.send_message(client_id, message_json) except: pass
def get(self): contacts = Contact.query(Contact.sent != True) count = contacts.count() if count: datetime_handler = lambda obj: obj.isoformat() \ if isinstance(obj, datetime) else None message = json.dumps( [contact.to_dict() for contact in contacts], default=datetime_handler, indent=4 ) mail.send_mail( sender="Example.com Support <*****@*****.**>", to="Albert Johnson <*****@*****.**>", subject="You have {0} new contacts".format(count), body=message ) self.response.write(message) logger.info( 'Send daily mail success, {0} new contacts'.format(count)) for contact in contacts: contact.sent = True contact.put()
def get(self, **kwargs): bitly_hash = kwargs.get('bitly_hash', '') if len(bitly_hash)<1: return redirect('frontend/map') query_dict = expand_bitly_url(bitly_hash) dict = get_dict_from_querystring_dict(query_dict) return self.render_response('frontend/index.html' , config_arrayJSON=json.dumps(config_array) , config_array=config_array , max_results=MAX_QUERY_RESULTS , preset=dict , presetJSON=json.dumps(dict) , _OPER_SELL=Property._OPER_SELL , _OPER_RENT=Property._OPER_RENT)
def get(self, **kwargs): preset = {'prop_operation_id':str(Property._OPER_SELL)} direct_links = Link.all().filter('type = ', 'home').fetch(25) return self.render_response('frontend/home.html' , config_array = config_array , preset = preset , presetJSON = json.dumps(preset) , _OPER_SELL = Property._OPER_SELL , _OPER_RENT = Property._OPER_RENT , direct_links = direct_links)
def Delete(self,my_model): user_id = self.request_state.headers.get('clientId',None) ndb.delete_multi([my_model.key]) people=memcache.get("todo") if people: for person in people: if not person == user_id: channel.send_message("%s_%s"%(person,'todo'),json.dumps({'action':'delete','id':"%s"%my_model.id})) return my_model
def Insert(self, my_model): format = "%Y-%m-%d %H:%M:%S" user_id=self.request_state.headers.get('clientId',None) my_model.put() people=memcache.get("todo") if people: for person in people: if not person == user_id: channel.send_message("%s_%s"%(person,'todo'),json.dumps({'action':'update','id':"%s"%my_model.id,'text':my_model.text,'done':my_model.done,'created':my_model.created.strftime(format)})) return my_model
def slugged_link(self, **kwargs): key_name_or_id = kwargs['key_name_or_id'] if len(key_name_or_id) < 1: return self.redirect_to('frontend/map') mLink = Link.get_by_id(int(key_name_or_id)) query_dict = expand_link_url_ex(mLink) dict = get_dict_from_querystring_dict(query_dict) # ================================= BEGIN FROM SEARCH ========================================== # _searcher = Searcher(dict) result = _searcher.doSearch(cursor_key=None, **kwargs) #return self.response.write(result) if 'status' in result: return self.redirect_to('frontend/map') properties = db.get(result['properties']) price_data = result['price_data'] price_data_operation = price_data['operation'] price_data_price_field = price_data['price_field'] price_data_currency = price_data['currency'] html = self.render_template( 'frontend/templates/_properties.html', properties=properties, Property=Property, price_data_operation=price_data_operation, price_data_price_field=price_data_price_field, price_data_currency=price_data_currency, base_cursor_index=0) coords = [({ 'lat': prop.location.lat, 'lng': prop.location.lon, 'key': str(prop.key()), 'headline': prop.headline }) for prop in properties if prop is not None] markers_coords = json.dumps({ 'coords': coords, 'status': 'success', 'display_total_count': result['total_count'], 'display_viewing_count': result['viewing'], 'the_box': '', 'cursor': str(result['cursor_key']) }) # ================================= END FROM SEARCH ========================================== # return self.render_response( 'frontend/index.html', analytics_mark='mapa-sugerido' if mLink.type == 'home' else 'mapa-compartido', config_arrayJSON=json.dumps(config_array), config_array=config_array, max_results=MAX_QUERY_RESULTS, preset=dict, presetJSON=json.dumps(dict), _OPER_SELL=Property._OPER_SELL, _OPER_RENT=Property._OPER_RENT, markers_coords=markers_coords, html_property_list=html, title_description=mLink.description)