def post(self, request, entity, dimension=None):
        form = forms.DateTweetForm(request.POST, entity=entity, reputation_dimension=dimension)

        if form.is_valid():
            entity = form.cleaned_data['entity']
            reputation_dimension = form.cleaned_data['reputation_dimension']
            date = form.cleaned_data['date']

            if dimension is not None:
                tweets = Tweet.objects.filter(tweet__related_entity=entity,
                                              tweet__reputation_dimension=reputation_dimension,
                                              created_at__year=str(date.year),
                                              created_at__month=str(date.month),
                                              created_at__day=str(date.day)).order_by('-created_at')
            else:
                tweets = Tweet.objects.filter(tweet__related_entity=entity,
                                              created_at__year=str(date.year),
                                              created_at__month=str(date.month),
                                              created_at__day=str(date.day)).order_by('-created_at')

            context = {
                'form': form,
                'entity': entity,
                'entities_list': utility.entities_list,
                'dimension_list': utility.dimension_list,
                'Dimension': reputation_dimension,
            }
            context.update(utility.get_view_content(request, tweets))

            return render(request, 'twitter_services/tweets_filter.html', context)
        else:
            return user_util.json_response(-1, msg=form.errors)
    def get(self, request, entity, dimension=None):
        form = forms.DateTweetForm(entity=entity, reputation_dimension=dimension)
        time_threshold = datetime.now(pytz.utc) - timedelta(days=5)
        if dimension is not None:
            tweets = Tweet.objects.filter(tweet__related_entity=entity,
                                          tweet__reputation_dimension=dimension,
                                          created_at__gt=time_threshold).order_by('-created_at')
        else:
            tweets = Tweet.objects.filter(tweet__related_entity=entity,
                                          created_at__gt=time_threshold).order_by('-created_at')

        context = {
            'form': form,
            'entity': entity,
            'entities_list': utility.entities_list,
            'dimension_list': utility.dimension_list,
            'Dimension': dimension,
        }
        context.update(utility.get_view_content(request, tweets))

        return render(request, 'twitter_services/tweets_filter.html', context)
    def post(self, request, entity, dimension=None):
        form = forms.DateTweetForm(request.POST,
                                   entity=entity,
                                   reputation_dimension=dimension)

        if form.is_valid():
            entity = form.cleaned_data['entity']
            reputation_dimension = form.cleaned_data['reputation_dimension']
            date = form.cleaned_data['date']

            if dimension is not None:
                tweets = Tweet.objects.filter(
                    tweet__related_entity=entity,
                    tweet__reputation_dimension=reputation_dimension,
                    created_at__year=str(date.year),
                    created_at__month=str(date.month),
                    created_at__day=str(date.day)).order_by('-created_at')
            else:
                tweets = Tweet.objects.filter(
                    tweet__related_entity=entity,
                    created_at__year=str(date.year),
                    created_at__month=str(date.month),
                    created_at__day=str(date.day)).order_by('-created_at')

            context = {
                'form': form,
                'entity': entity,
                'entities_list': utility.entities_list,
                'dimension_list': utility.dimension_list,
                'Dimension': reputation_dimension,
            }
            context.update(utility.get_view_content(request, tweets))

            return render(request, 'twitter_services/tweets_filter.html',
                          context)
        else:
            return user_util.json_response(-1, msg=form.errors)
    def get(self, request, entity, dimension=None):
        form = forms.DateTweetForm(entity=entity,
                                   reputation_dimension=dimension)
        time_threshold = datetime.now(pytz.utc) - timedelta(days=5)
        if dimension is not None:
            tweets = Tweet.objects.filter(
                tweet__related_entity=entity,
                tweet__reputation_dimension=dimension,
                created_at__gt=time_threshold).order_by('-created_at')
        else:
            tweets = Tweet.objects.filter(
                tweet__related_entity=entity,
                created_at__gt=time_threshold).order_by('-created_at')

        context = {
            'form': form,
            'entity': entity,
            'entities_list': utility.entities_list,
            'dimension_list': utility.dimension_list,
            'Dimension': dimension,
        }
        context.update(utility.get_view_content(request, tweets))

        return render(request, 'twitter_services/tweets_filter.html', context)