Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create activity optionally based on instance attribute values #86

Open
umair-tp opened this issue Nov 20, 2018 · 0 comments
Open

Create activity optionally based on instance attribute values #86

umair-tp opened this issue Nov 20, 2018 · 0 comments

Comments

@umair-tp
Copy link

umair-tp commented Nov 20, 2018

I have a model as following:

class UserMoodLog(TimeStampedModel, Activity):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE)
    is_happy = models.BooleanField(_("is happy"), default=False)

I want to create activity associated to this model on it's creation only when is_happy=True. I tried overriding create_activity() and call super create_activity() only when is_happy=True but a activity must be returned from that, otherwise this line

result = feed.add_activity(activity)
will throw error, as activity is None (because when is_happy=False I am not calling super create_activity() and thus None is returned by overridden create_activity())

Can someone please point me towards the right direction ?

@umair-tp umair-tp changed the title Create activity based on instance attribute values Create activity optionally based on instance attribute values Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant