Example #1
0
 def __init__(self, current_user_id, event_object, matched_users):
     self.event = MatchEvent.get_event_info(event_object)
     self.current_user_id = current_user_id
     self.matched_users = matched_users
     self.organizer = build_organizer(self.event)
     self.names = self.highlight(event_object, 'name')
     self.descriptions = self.highlight(event_object, 'description')
     self.id = self.event.id
     self.name = self.event.name
     self.city = self.event.city
     self.country = self.event.country
     self.state = self.event.state
     self.street = self.event.street
     self.repeat = self.event.repeat
     self.zipcode = self.event.zipcode
     self.full_address = self.event.full_address
     self.location_name = self.event.location_name
     self.location = self.event.location
     self.max_attendees = self.event.max_attendees
     self.attendees_yes = MatchEvent.get_attendees(current_user_id,
                                                   self.event,
                                                   matched_users,
                                                   rsvp='yes')
     self.attendees_no = MatchEvent.get_attendees(current_user_id,
                                                  self.event,
                                                  matched_users,
                                                  rsvp='no')
     self.attendees_maybe = MatchEvent.get_attendees(current_user_id,
                                                     self.event,
                                                     matched_users,
                                                     rsvp='maybe')
     self.recommended_event_score = self.match_score()
     self.cumulative_match_score = MatchEvent.get_cum_score(
         current_user_id, self.event, matched_users)
     self.friend_attendees_count = MatchEvent.get_friends_attendees(
         current_user_id, self.id).count()
     self.description = self.event.description
     self.starts_on = self.event.starts_on
     self.ends_on = self.event.ends_on
     self.distance = calculate_distance_es(current_user_id, event_object)
     self.event_photo = self.event.event_photo.url \
         if self.event.event_photo else None
Example #2
0
 def __init__(self,
              current_user_id,
              user_object,
              include_top_interests=True):
     self.user = self.get_user_info(user_object)
     self.current_user_id = current_user_id
     self.goals = self.highlight(user_object, 'goals')
     self.offers = self.highlight(user_object, 'offers')
     self.interests = self.highlight(user_object, 'interests')
     self.likes = self.likes_images(user_object)
     self.id = self.user.id
     self.user_id = self.user.id
     self.username = self.user.username
     self.first_name = self.user.first_name
     self.last_name = self.user.last_name
     self.facebook_id = self.user.facebook_id
     self.image = self.get_profile_image(user_object) or \
         '/media/{}'.format(self.user.image)
     self.age = calculate_age(self.user.date_of_birth)
     self.gender = self.user.gender or 'm,f'
     self.about = self.user.about_me
     self.photos = []
     self.distance = calculate_distance_es(current_user_id, user_object)
     self.seen = self.get_seen(current_user_id, user_object)
     # Scores
     self.score = self.match_score(current_user_id, self.user_id)
     self.es_score = user_object.get('_score', 0)
     self.mutual_likes_count = self.fb_likes_match_score(
         current_user_id, self.user_id)
     self.total_likes_count = self.total_fb_likes_count(self.user_id)
     self.friends_score = self.get_friends_score(current_user_id,
                                                 user_object)
     self.top_interests = \
         self.get_top_interests(user_object) if include_top_interests else []
     self.last_login = self.user.last_login
     self.keywords = None  # self.get_keywords(user_object)
     self.position = get_current_position(self.user)
     self.lives_in = get_lives_in(self.user)
     self.linkedin_provider = self.get_linkedin_data()
     self.twitter_username, self.twitter_provider = self.get_twitter_data()
     self.connected = self.is_connected(current_user_id, self.user_id)
Example #3
0
 def test_gte_1_mi(self):
     user_object = {'sort': [1.7]}
     d = calculate_distance_es(self.user.id, user_object)
     self.assertEqual(d, [1, 'miles'])
Example #4
0
 def test_m_gte_50(self):
     user_object = {'sort': [0.9]}
     d = calculate_distance_es(self.user.id, user_object)
     self.assertEqual(d, [1448, 'meters'])
Example #5
0
 def test_mi(self):
     user_object = {'sort': [5.323]}
     d = calculate_distance_es(self.user.id, user_object)
     self.assertEqual(d, [5, 'miles'])
Example #6
0
 def test_gte_1_km(self):
     user_object = {'sort': [1.1]}
     d = calculate_distance_es(self.user.id, user_object)
     self.assertEqual(d, [1099, 'meters'])