Exemple #1
0
	def get(self, request, *args, **kwargs):
		blocked_by_list, blocking_list = get_blocking_lists(request)
		starred = self.request.user.starred_by.all().order_by('-time_created') \
									.exclude(user__profile__in=blocked_by_list) \
									.exclude(user__in=blocking_list)
		starred_serialized = PartyModelSerializer(starred, many=True, context={'request': request}).data
		context = {'starred' : starred_serialized}
		return render(request, 'parties/starred_list.html', context)
Exemple #2
0
 def get_queryset(self, *args, **kwargs):
     # these lists get the users you block and the users that block you
     # blocked by returns profile objects and blocking returns users
     blocked_by_list, blocking_list = get_blocking_lists(self.request)
     qs = self.request.user.joined_by.all().order_by('-time_created')
     # this stops you from seeing blocked or blocking events
     qs = qs.exclude(user__profile__in=blocked_by_list)
     qs = qs.exclude(user__in=blocking_list)
     return qs
Exemple #3
0
	def get(self, request, *args, **kwargs):
		im_following = self.request.user.profile.get_following()
		blocked_by_list, blocking_list = get_blocking_lists(request)
		following =  Party.objects.filter(user__in=im_following).order_by('-time_created') \
									.exclude(user__profile__in=blocked_by_list) \
									.exclude(user__in=blocking_list)
		following_serialized = PartyModelSerializer(following, many=True, context={'request': request}).data
		context = {'following' : following_serialized}
		return render(request, 'parties/following_list.html', context)
Exemple #4
0
    def get_queryset(self, *args, **kwargs):
        qs = Party.objects.filter(is_open=True).order_by('-popularity')
        # these lists get the users you block and the users that block you
        # blocked by returns profile objects and blocking returns users
        blocked_by_list, blocking_list = get_blocking_lists(self.request)
        # trending is all the open events, ordered by their popularity, descending

        qs = qs.exclude(user__profile__in=blocked_by_list)
        qs = qs.exclude(user__in=blocking_list)
        return qs
Exemple #5
0
 def get_queryset(self, *args, **kwargs):
     # these lists get the users you block and the users that block you
     # blocked by returns profile objects and blocking returns users
     blocked_by_list, blocking_list = get_blocking_lists(self.request)
     blocked_by_list = self.request.user.blocked_by.all()
     party_id = self.kwargs.get('pk')
     qs = Party.objects.filter(pk=party_id)
     # this stops you from seeing blocked or blocking events
     qs = qs.exclude(user__profile__in=blocked_by_list)
     return qs
Exemple #6
0
    def get(self, request, *args, **kwargs):
        # Maybe put this in middleware later
        trending = None
        closing = None
        following = None
        serialized_following = None
        blocked_by_list, blocking_list = get_blocking_lists(request)

        # Trending
        trending = Party.objects.filter(
            is_open=True).order_by('-popularity')[:6]
        serialized_trending = PartyModelSerializer(trending,
                                                   many=True,
                                                   context={
                                                       'request': request
                                                   }).data

        # Closing
        soon_time = timezone.now() + timedelta(minutes=15)
        closing = Party.objects.filter(is_open=True) \
             .filter(party_time__lte=soon_time) \
             .exclude(user__profile__in=blocked_by_list) \
             .exclude(user__in=blocking_list) \
             .order_by('-popularity')[:6]
        serialized_closing = PartyModelSerializer(closing,
                                                  many=True,
                                                  context={
                                                      'request': request
                                                  }).data
        # Following
        if request.user.is_authenticated:
            im_following = self.request.user.profile.get_following()
            if im_following:
                following = Party.objects.filter(user__in=im_following) \
                     .filter(is_open=True) \
                     .exclude(user__profile__in=blocked_by_list) \
                     .exclude(user__in=blocking_list) \
                     .order_by('-time_created')
                serialized_following = PartyModelSerializer(following,
                                                            many=True,
                                                            context={
                                                                'request':
                                                                request
                                                            }).data
            else:
                serialized_following = None

        context = {
            'trending': serialized_trending,
            'closing': serialized_closing,
            'following': serialized_following,
            'username': self.request.user.username
        }
        return render(request, 'home.html', context)
Exemple #7
0
 def get_queryset(self, *args, **kwargs):
     soon_time = timezone.now() + timedelta(minutes=15)
     qs = Party.objects.filter(is_open=True)
     qs = qs.filter(party_time__lte=soon_time)
     qs = qs.order_by('-popularity')
     # these lists get the users you block and the users that block you
     # blocked by returns profile objects and blocking returns users
     blocked_by_list, blocking_list = get_blocking_lists(self.request)
     # closing soon is events closing in 5 mins (delta is 10)
     # that are open, ordered by popularity, descending
     qs = qs.exclude(user__profile__in=blocked_by_list)
     qs = qs.exclude(user__in=blocking_list)
     return qs
Exemple #8
0
 def get_queryset(self, *args, **kwargs):
     # this return the string form of the search passed into the url
     qs = self.queryset
     query = self.request.GET.get('q', None)
     if query is not None:
         # these lists get the users you block and the users that block you
         # blocked by returns profile objects and blocking returns users
         blocked_by_list, blocking_list = get_blocking_lists(self.request)
         # Q is a lookup function
         qs = qs.filter(
             Q(description__icontains=query)
             | Q(user__username__icontains=query)
             | Q(title__icontains=query))
         # this stops you from seeing blocked or blocking events
         qs = qs.exclude(user__profile__in=blocked_by_list)
         qs = qs.exclude(user__in=blocking_list)
         qs = qs.filter(is_open=True).order_by('-popularity')
         return qs
Exemple #9
0
	def get(self, request, *args, **kwargs):
		blocked_by_list, blocking_list = get_blocking_lists(request)
		joined = self.request.user.joined_by.all().order_by('-time_created') \
												.exclude(user__profile__in=blocked_by_list) \
												.exclude(user__in=blocking_list)
		joined_serialized = PartyModelSerializer(joined, many=True, context={'request': request}).data
		context = {'joined' : joined_serialized}
		return render(request, 'parties/joined_list.html', context)

		
# these are the inner workings of how the class based views actually render
# def party_detail_view(request, id=1):
# 	obj = Party.objects.get(id=id) # gets from database
# 	print(obj)
# 	context = {
# 		'object': obj
# 	}
# 	return render(request, 'parties/detail_view.html', context)
Exemple #10
0
    def get_queryset(self, *args, **kwargs):
        # gets user for if we have a user detail view
        qs = Party.objects.none()
        requested_user = self.kwargs.get('username')
        if self.request.user.is_authenticated:
            # these lists get the users you block and the users that block you
            # blocked by returns profile objects and blocking returns users
            blocked_by_list, blocking_list = get_blocking_lists(self.request)
        if requested_user:
            # includes only the requested users events in the feed
            # sets the ordering. party_time would be soonest expiration at the top
            qs = Party.objects.filter(
                user__username=requested_user).order_by('-time_created')
            if self.request.user.is_authenticated:
                # this stops you from seeing blocked or blocking events
                qs = qs.exclude(user__profile__in=blocked_by_list)
                qs = qs.exclude(user__in=blocking_list)
        else:
            if self.request.user.is_authenticated:
                # uses methods form the userprofile model
                im_following = self.request.user.profile.get_following()
                qs = Party.objects.filter(user__in=im_following)
                qs = qs.filter(is_open=True).order_by('-time_created')
                # this stops you from seeing blocked or blocking events
                qs = qs.exclude(user__profile__in=blocked_by_list)
                qs = qs.exclude(user__in=blocking_list)
            # includes our own events in our feed
            # qs2 = Party.objects.filter(user=self.request.user)
            # sets the ordering. party_time would be soonest expiration at the top
            # qs = (qs1 | qs2).distinct().order_by('-time_created')

        # this return the string form of the search passed into the url
        # currentyl all search goes to the search api view, not this
        # query = self.request.GET.get('q', None)
        # if query is not None:
        # 	# Q is a lookup function
        # 	qs = qs.filter(
        # 		Q(description__icontains=query) |
        # 		Q(user__username__icontains=query) |
        # 		Q(title__icontains=query)
        # 		)
        return qs