Esempio n. 1
0
 def obj_get(self, bundle, **kwargs):
     event_id = int(kwargs.get('pk'))
     try:
         event = Event.objects.get(pk=event_id)
     except Event.DoesNotExist:
         raise NotFound("Organizer not found")
     if event.organizer:
         event_organizer = event.organizer
         match_user = MatchQuerySet.between(
             user_id1=bundle.request.user.id, user_id2=event_organizer.id
         )
         if match_user:
             match_user = match_user[0]
             match_user.id = event_id
         else:
             match_user = NonMatchUser(
                 bundle.request.user.id, event_organizer.id
             )
         match_user.event_type = event.event_type
     else:
         fb_event = FacebookEvent.objects.filter(
             facebook_id=event.eid).first()
         obj = A()
         obj.id = event.id
         obj.first_name = fb_event.owner_info.get('name')
         obj.link = 'https://www.facebook.com/{}/'.format(
             fb_event.owner_info.get('id')
         )
         obj.event_type = event.event_type
         return obj
     return match_user
Esempio n. 2
0
 def get_object_list(self, request):
     username = request.GET.get('username')
     user = FacebookCustomUserActive.objects.filter(username=username)
     match_users = []
     if user:
         match_users = MatchQuerySet.between(request.user.id, user[0].id)
     return match_users
Esempio n. 3
0
 def test_simple_match_between(self):
     Goal.objects.create(user=self.user, goal=self.subject11)
     Goal.objects.create(user=self.user1, goal=self.subject10)
     Goal.objects.create(user=self.user2, goal=self.subject10)
     Goal.objects.create(user=self.user3, goal=self.subject10)
     update_index.Command().handle(interactive=False)
     users = MatchQuerySet.between(self.user.id, self.user1.id)
     self.assertEqual(len(users), 1)
     self.assertEqual(users[0].score, 1)