def alter_reputation_for_changed_vote(
    sender,
    instance,
    old_vote,
    new_vote,
    **kwargs
):
    """Alter reputation for a changed vote on a piece of content."""
    upvote = getattr(
        config,
        'TINE_REP_FOR_%s_UPVOTE' %
        get_post_type_for_config(instance.voted_on)
    )
    downvote = getattr(
        config,
        'TINE_REP_FOR_%s_DOWNVOTE' %
        get_post_type_for_config(instance.voted_on)
    )

    # Remove the reputation change for the old vote.
    if old_vote == 1:
        instance.voted_on.author.reputation -= upvote
    elif old_vote == -1:
        instance.voted_on.author.reputation -= downvote

    # Add the reputation change for the new vote.
    if new_vote == 1:
        instance.voted_on.author.reputation += upvote
    elif new_vote == -1:
        instance.voted_on.author.reputation += downvote

    instance.voted_on.author.save()
Example #2
0
def remove_reputation_for_unpublished_post(sender, instance, **kwargs):
    """Remove reputation for an unpublished Post."""
    if issubclass(sender, Post):
        instance.author.reputation -= getattr(
            config,
            'TINE_REP_FOR_%s' % get_post_type_for_config(instance)
        )
        instance.author.save()
Example #3
0
def award_reputation_for_published_post(sender, instance, **kwargs):
    """Award reputation for publishing a Post."""
    if issubclass(sender, Post):
        instance.author.reputation += getattr(
            config,
            'TINE_REP_FOR_%s' % get_post_type_for_config(instance)
        )
        instance.author.save()