Exemplo n.º 1
0
    def get(self, request):
        filter, _ = PostSearch.objects.get_or_create(
            user=self.me, organization=self.me.default)

        form = forms.PostSearchForm(instance=filter)
        q0 = Q(ancestor__organization=self.me.default)
        q1 = Q(ancestor__users=self.me)
        posts = models.Post.objects.filter(q0 & q1)

        posts = posts.distinct()
        total = posts.count()
        sqlike = SqPost()
        posts = filter.get_partial(posts)

        sqlike.feed(filter.pattern)

        posts = sqlike.run(posts)
        count = posts.count()
        posts = posts.only('done', 'label', 'id').order_by('id')
        elems = JScroll(self.me.id, 'post_app/find-scroll.html', posts)

        return render(request, 'post_app/find.html', {
            'form': form,
            'elems': elems.as_div(),
            'total': total,
            'count': count
        })
Exemplo n.º 2
0
    def post(self, request):
        filter, _ = CardSearch.objects.get_or_create(
        user=self.me, organization=self.me.default)

        sqlike = SqCard()
        form   = forms.CardSearchForm(request.POST, 
        sqlike=sqlike, instance=filter)

        query0 = Q(ancestor__ancestor__organization=self.me.default)
        query1 = Q(ancestor__ancestor__members=self.me)
        query2 = Q(workers=self.me)
        query3 = query0 & (query1 | query2)
        cards  = Card.objects.filter(query3).distinct()
        total  = cards.count()

        if not form.is_valid():
            return render(request, 'card_app/find.html', 
                {'form': form, 'total': total, 'count': 0}, status=400)
        form.save()

        cards  = filter.get_partial(cards)
        cards = sqlike.run(cards)

        count =  cards.count()
        cards = cards.only('done', 'label', 'id').order_by('id')
        elems = JScroll(self.me.id, 'card_app/find-scroll.html', cards)

        return render(request, 'card_app/find.html', 
        {'form': form, 'elems':  elems.as_div(), 'total': total, 'count': count})
Exemplo n.º 3
0
    def get(self, request):
        filter, _ = EventFilter.objects.get_or_create(
            user=self.me, organization=self.me.default)

        form = forms.EventFilterForm(instance=filter)

        events = self.me.seen_events.filter(organization=self.me.default)
        total = events.count()

        events = events.filter(created__lt=filter.end + timedelta(days=1),
                               created__gte=filter.start)

        # events = events.filter(created__date__lte=filter.end,
        # created__date__gte=filter.start)

        count = events.count()
        events = events.values('html').order_by('-created')

        events = JScroll(self.me.id, 'core_app/list-logs-scroll.html', events)

        return render(
            request, 'core_app/list-logs.html', {
                'user': self.me,
                'form': form,
                'events': events.as_div(),
                'events': events.as_div(),
                'count': count,
                'total': total,
                'organization': self.me.default
            })
Exemplo n.º 4
0
    def post(self, request):
        filter, _ = CommentSearch.objects.get_or_create(
        user=self.me, organization=self.me.default)

        sqlike = models.Comment.from_sqlike()
        form  = forms.CommentSearchForm(request.POST, sqlike=sqlike, instance=filter)

        comments = models.Comment.objects.filter(
        Q(post__ancestor__users=self.me) &
        Q(post__ancestor__organization=self.me.default)).distinct()

        total = comments.count()

        if not form.is_valid():
            return render(request, 'comment_app/find.html', 
                {'form': form, 'total': total, 'count': 0}, status=400)
        form.save()

        comments = sqlike.run(comments)

        count =  comments.count()
        comments = comments.only('post__label', 'post__id', 'data', 'id').order_by('id')
        elems = JScroll(self.me.id, 'comment_app/find-scroll.html', comments)

        return render(request, 'comment_app/find.html', 
        {'form': form, 'elems':  elems.as_div(), 'total': total, 'count': count})
Exemplo n.º 5
0
    def get(self, request):
        filter, _ = CommentSearch.objects.get_or_create(
            user=self.me, organization=self.me.default)

        form = forms.CommentSearchForm(instance=filter)

        comments = models.Comment.objects.filter(
        Q(post__ancestor__users=self.me) &
        Q(post__ancestor__organization=self.me.default) |\
        Q(post__workers=self.me)).distinct()

        total = comments.count()

        sqlike = models.Comment.from_sqlike()

        sqlike.feed(filter.pattern)

        comments = sqlike.run(comments)
        count = comments.count()

        comments = comments.only('post__label', 'post__id', 'data',
                                 'id').order_by('id')
        elems = JScroll(self.me.id, 'comment_app/find-scroll.html', comments)

        return render(request, 'comment_app/find.html', {
            'form': form,
            'elems': elems.as_div(),
            'total': total,
            'count': count
        })
Exemplo n.º 6
0
    def get(self, request):
        filter, _ = NoteSearch.objects.get_or_create(
            user=self.me, organization=self.me.default)

        form = forms.NoteSearchForm(instance=filter)

        notes = models.Note.objects.filter(
        Q(card__ancestor__ancestor__members=self.me) &
        Q(card__ancestor__ancestor__organization=self.me.default) |\
        Q(card__workers=self.me)).distinct()

        total = notes.count()

        sqlike = models.Note.from_sqlike()

        sqlike.feed(filter.pattern)

        notes = sqlike.run(notes)
        count = notes.count()

        notes = notes.only('card__label', 'card__id', 'data',
                           'id').order_by('id')
        elems = JScroll(self.me.id, 'note_app/find-scroll.html', notes)

        return render(request, 'note_app/find.html', {
            'form': form,
            'elems': elems.as_div(),
            'total': total,
            'count': count
        })
Exemplo n.º 7
0
    def get(self, request):
        events = self.me.events.filter(organization=self.me.default)
        count = events.count()
        events = events.values('html', 'id').order_by('-created')

        elems = JScroll(self.me.id, 'core_app/list-events-scroll.html', events)

        return render(
            request, 'core_app/list-events.html', {
                'elems': elems.as_div(),
                'user': self.me,
                'organization': self.me.default,
                'count': count
            })
Exemplo n.º 8
0
    def get(self, request, group_id):
        # Make sure i belong to the group and my default
        # organization contains the group.
        group = self.me.groups.get(id=group_id, organization=self.me.default)

        filter, _ = PostFilter.objects.get_or_create(user=self.me, group=group)

        posts = group.posts.all()
        total = posts.count()

        listpins = self.me.listpin_set.filter(organization=self.me.default)
        cardpins = self.me.cardpin_set.filter(organization=self.me.default)
        postpins = self.me.postpin_set.filter(organization=self.me.default)
        boardpins = self.me.boardpin_set.filter(organization=self.me.default)
        grouppins = self.me.grouppin_set.filter(organization=self.me.default)

        posts = posts.filter(done=False)
        posts = filter.from_sqpost(posts) if filter.status else posts

        posts = posts.order_by('-priority')

        likers = User.objects.filter(id=self.me.pk, post_likes=OuterRef('id'))
        posts = posts.annotate(in_likers=Exists(likers))

        count = posts.count()

        # I'm having to evaluate the whole queryset into a list so it can be
        # cached with jscroll. I'm not sure about the implications of it at all.
        elems = JScroll(self.me.id, 'group_app/list-posts-scroll.html',
                        list(posts.all()))

        env = {
            'group': group,
            'count': count,
            'total': total,
            'grouppins': grouppins,
            'elems': elems.as_window(),
            'postpins': postpins,
            'filter': filter,
            'boardpins': boardpins,
            'listpins': listpins,
            'cardpins': cardpins
        }

        return render(request, 'group_app/list-posts.html', env)