Skip to content

Create activity optionally based on instance attribute values #86

Open
@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 ?

Activity

changed the title [-]Create activity based on instance attribute values[/-] [+]Create activity optionally based on instance attribute values[/+] on Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @umair-tp

        Issue actions

          Create activity optionally based on instance attribute values · Issue #86 · GetStream/stream-django