Skip to content

Create activity optionally based on instance attribute values #86

@umair-tp

Description

@umair-tp

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions