示例#1
0
def trust_given(sender, instance, created, **kwargs):
    if not created:
        return

    membership = instance.membership
    relevant_trust = Trust.objects.filter(membership=membership)
    trust_threshold = membership.group.trust_threshold_for_newcomer()

    if relevant_trust.count() >= trust_threshold and roles.GROUP_EDITOR not in membership.roles:
        membership.add_roles([roles.GROUP_EDITOR])
        membership.save()

        History.objects.create(
            typus=HistoryTypus.MEMBER_BECAME_EDITOR,
            group=membership.group,
            users=[membership.user],
            payload={
                'threshold': trust_threshold,
            },
        )

        prepare_user_became_editor_email(user=membership.user, group=membership.group).send()

        stats.member_became_editor(membership.group)

    stats.trust_given(membership.group)
示例#2
0
def trust_given(sender, instance, created, **kwargs):
    if not created:
        return

    membership = instance.membership
    relevant_trust = Trust.objects.filter(membership=membership)
    trust_threshold = membership.group.trust_threshold_for_newcomer()

    if relevant_trust.count(
    ) >= trust_threshold and roles.GROUP_EDITOR not in membership.roles:
        membership.add_roles([roles.GROUP_EDITOR])
        History.objects.create(
            typus=HistoryTypus.MEMBER_BECAME_EDITOR,
            group=membership.group,
            users=[membership.user],
            payload={
                'threshold': trust_threshold,
            },
        )

        # new editors should also get informed about new applications
        # TODO: really? maybe ask them beforehand...
        membership.add_notification_types(
            [GroupNotificationType.NEW_APPLICATION])
        membership.save()
        prepare_user_became_editor_email(user=membership.user,
                                         group=membership.group).send()

        stats.member_became_editor(membership.group)

    stats.trust_given(membership.group)