def get(self, request, message_id): message = Message.objects.get(pk=message_id) tweets = [tweet_orm.tweet for tweet_orm in message.tweet.all().order_by('-created_at')] message.read = True message.save() interest_list = [ue_orm.entity for ue_orm in UserEntity.objects.filter(user=get_user(request))] topic_list = message.topic_str.split('\n') keywords = [] weights = [] for topic_tuple in topic_list: keyword = topic_tuple.split(',')[0] weight = float(topic_tuple.split(',')[1]) keywords.append(str(keyword)) weights.append(weight) geocoder = LocalGeocoder() coordinates = geocoder.geocode_many(tweets) latitudes = [coordinate[0] for coordinate in coordinates] longitudes = [coordinate[1] for coordinate in coordinates] return render(request, 'user_handle/message.html', {'tweets': tweets[:100], 'message': message, 'interest_list': interest_list, 'topic_keywords': keywords, 'keywords_weight': weights, 'latitudes': latitudes, 'longitudes': longitudes })
def get_view_content(request, tweets_orms): tweets_filtered = [tweet_orm.tweet for tweet_orm in tweets_orms] geocoder = LocalGeocoder() coordinates = geocoder.geocode_many(tweets_filtered) latitudes = [coordinate[0] for coordinate in coordinates] longitudes = [coordinate[1] for coordinate in coordinates] user = User.objects.get(username=request.user.username) interest_list = [ue_orm.entity for ue_orm in UserEntity.objects.filter(user=user)] return { 'tweets': tweets_filtered[:100], 'latitudes': latitudes, 'longitudes': longitudes, 'interest_list': interest_list }
def get_view_content(request, tweets_orms): tweets_filtered = [tweet_orm.tweet for tweet_orm in tweets_orms] geocoder = LocalGeocoder() coordinates = geocoder.geocode_many(tweets_filtered) latitudes = [coordinate[0] for coordinate in coordinates] longitudes = [coordinate[1] for coordinate in coordinates] user = User.objects.get(username=request.user.username) interest_list = [ ue_orm.entity for ue_orm in UserEntity.objects.filter(user=user) ] return { 'tweets': tweets_filtered[:100], 'latitudes': latitudes, 'longitudes': longitudes, 'interest_list': interest_list }