Comment by Django GetStream and Django

How can I keep activity from Django GetStream using django_comments and how can I get this data? Thanks!

I implemented a Django comment using render_comment_form, something like https://django.readthedocs.org/en/1.4.X/ref/contrib/comments/ , and I want to know how I can keep activity in GetStream and how I I can do for consultation after saving thanks. Thank you, man, but I have something like this:

from django.db import models
from fluent_comments.compat import CommentManager, Comment #, signals
from fluent_comments.models import FluentComment
from stream_django.activity import Activity
from stream_django import feed_manager
from django.db.models import signals
from publications.models import Ad

class ActivityComments(FluentComment, Activity):
    pass

    def __unicode__(self):
        #return "%s COMENTA-->> %s" % (self.user.first_name, self.object_content.item)
        return "%s COMENTA-->> %s" % (self.user.first_name, self.object_pk)

    @property
    def activity_object_attr(self):
        return self

    @property
    def activity_actor_attr(self):
        return self.user

    @property
    def activity_time(self):
        return self.created

    @property
    def extra_activity_data(self):
        return {'a': self.item}

    @property
    def activity_notify(self):
        if self.object_content.item.seller.user != self.user:
            target_feed = feed_manager.get_notification_feed(
                self.object_content.item.seller.user.id)
            return [target_feed]

    @classmethod
    def apply_activity_notify(cls, sender, instance, using, **kwargs):

        ad=Ad.objects.get(id=instance.object_pk)
        comment = FluentComment.objects.get(id=instance.id)
        comment.object_content = ad
        comment.activity_notify


"""
signals
"""

signals.post_save.connect(ActivityComments.apply_activity_notify, sender=Comment)

With this, I can register activity, but when I go to the getstram administrator, I can not understand anything. Also, another question when the registry is entered in alredy, can I get activity with this ?:

enricher = Enrich()
feed = feed_manager.get_feed('flat', user.id)
activities = feed.get(limit=3)['results']
I hope your answer, Thanks.
+4
1

Django , .

Django Comment settings.py

INSTALLED_APPS = [
    ...
    'my_comment_app',
]

COMMENTS_APP = 'my_comment_app'

my_comment_app/models.py .

from django.db import models
from django.contrib.comments.models import Comment
from stream_django.activity import Activity

class ActivityComment(Comment, Activity):
    pass

Django, my_comment_app/__ init__.py

from my_comment_app.models import ActivityComment


def get_model():
    return ActivityComment
0

Source: https://habr.com/ru/post/1620631/


All Articles