コード例 #1
0
ファイル: models.py プロジェクト: yurivital/pydici
def leadSignalHandler(sender, **kwargs):
    """Signal handler for new/updated leads"""
    lead = kwargs["instance"]
    targetUser = None
    client = lead.client
    # If this was the last active mission of its client and not more active lead, flag client as inactive
    if len(client.getActiveMissions()) == 0 and len(
            client.getActiveLeads().exclude(state="WON")) == 0:
        client.active = False
        client.save()
    if lead.responsible:
        targetUser = lead.responsible.getUser()
    if not targetUser:
        # Default to admin
        targetUser = User.objects.filter(is_superuser=True)[0]

    if kwargs.get("created", False):  # New Lead
        launchTrigger("NEW_LEAD", [
            targetUser,
        ], lead)
        createProjectTree(lead)
        client.active = True
        client.save()
    if lead.state == "WON":
        # Ensure actionset has not already be fired for this lead and this user
        if not ActionState.objects.filter(
                user=targetUser,
                target_id=lead.id,
                target_type=ContentType.objects.get_for_model(Lead)).exists():
            launchTrigger("WON_LEAD", [
                targetUser,
            ], lead)
コード例 #2
0
ファイル: models.py プロジェクト: digitalfox/pydici
def leadSignalHandler(sender, **kwargs):
    """Signal handler for new/updated leads"""
    lead = kwargs["instance"]
    targetUser = None
    client = lead.client
    # If this was the last active mission of its client and not more active lead, flag client as inactive
    if len(client.getActiveMissions()) == 0 and len(client.getActiveLeads().exclude(state="WON")) == 0:
        client.active = False
        client.save()
    if lead.responsible:
        targetUser = lead.responsible.getUser()
    if not targetUser:
        # Default to admin
        targetUser = User.objects.filter(is_superuser=True)[0]

    if  kwargs.get("created", False):  # New Lead
        launchTrigger("NEW_LEAD", [targetUser, ], lead)
        createProjectTree(lead)
        client.active = True
        client.save()
    if lead.state == "WON":
        # Ensure actionset has not already be fired for this lead and this user
        if not ActionState.objects.filter(user=targetUser,
                                          target_id=lead.id,
                                          target_type=ContentType.objects.get_for_model(Lead)
                                          ).exists():
            launchTrigger("WON_LEAD", [targetUser, ], lead)
コード例 #3
0
ファイル: models.py プロジェクト: GeoffreyOnRails/pydici
def missionSignalHandler(sender, **kwargs):
    """Signal handler for new/updated missions"""
    mission = kwargs["instance"]
    targetUser = None
    if not mission.active:
        # Mission is archived. Remove all staffing
        for staffing in mission.staffing_set.all():
            staffing.delete()
        if mission.lead:
            # If this was the last active mission of its client and not more active lead, flag client as inactive
            client = mission.lead.client
            if len(client.getActiveMissions()) == 0 and len(client.getActiveLeads().exclude(state="WON")) == 0:
                client.active = False
                client.save()
    # Handle actionset stuff :
    if not mission.nature == "PROD":
        # Don't throw actions for non prod missions
        return
    if mission.lead and mission.lead.responsible:
        targetUser = mission.lead.responsible.getUser()
    else:
        # try to pick up one of staffee
        for consultant in mission.consultants():
            targetUser = consultant.getUser()
            if targetUser:
                break
    if not targetUser:
        # Default to admin
        targetUser = User.objects.filter(is_superuser=True)[0]

    if  kwargs.get("created", False):
        launchTrigger("NEW_MISSION", [targetUser, ], mission)
    if not mission.active and mission.lead and mission.lead.state == "WON":
        launchTrigger("ARCHIVED_MISSION", [targetUser, ], mission)
コード例 #4
0
ファイル: models.py プロジェクト: fbeziaud/pydici
def consultantSignalHandler(sender, **kwargs):
    """Signal handler for new consultant"""

    if  not kwargs.get("created", False):
        return

    consultant = kwargs["instance"]
    targetUser = None
    if consultant.manager:
        targetUser = consultant.manager.getUser()

    if not targetUser:
        # Default to admin
        targetUser = User.objects.filter(is_superuser=True)[0]

    launchTrigger("NEW_CONSULTANT", [targetUser, ], consultant)
コード例 #5
0
ファイル: models.py プロジェクト: agateau/pydici
def consultantSignalHandler(sender, **kwargs):
    """Signal handler for new consultant"""

    if  not kwargs.get("created", False):
        return

    consultant = kwargs["instance"]
    targetUser = None
    if consultant.manager:
        targetUser = consultant.manager.getUser()

    if not targetUser:
        # Default to admin
        targetUser = User.objects.filter(is_superuser=True)[0]

    launchTrigger("NEW_CONSULTANT", [targetUser, ], consultant)
コード例 #6
0
def missionSignalHandler(sender, **kwargs):
    """Signal handler for new/updated missions"""
    mission = kwargs["instance"]
    targetUser = None
    if mission.lead and mission.lead.responsible:
        targetUser = mission.lead.responsible.getUser()
    else:
        # try to pick up one of staffee
        for consultant in mission.consultants():
            targetUser = consultant.getUser()
            if targetUser:
                break
    if not targetUser:
        # Default to admin
        targetUser = User.objects.filter(is_superuser=True)[0]

    if not mission.active:
        # Mission is archived. Remove all staffing
        if not mission.archived_date:
            mission.archived_date = datetime.now()
            mission.save()
            if mission.lead and mission.lead.state == "WON":
                launchTrigger("ARCHIVED_MISSION", [
                    targetUser,
                ], mission)

        for staffing in mission.staffing_set.all():
            staffing.delete()
        if mission.lead:
            # If this was the last active mission of its client and not more active lead, flag client as inactive
            client = mission.lead.client
            if len(client.getActiveMissions()) == 0 and len(
                    client.getActiveLeads().exclude(state="WON")) == 0:
                client.active = False
                client.save()
    # Handle actionset stuff :
    if not mission.nature == "PROD":
        # Don't throw actions for non prod missions
        return

    if kwargs.get("created", False):
        launchTrigger("NEW_MISSION", [
            targetUser,
        ], mission)