예제 #1
0
def view_entity(request, entity_id):
    """view"""

    try:
        preview = bool(request.GET.get('preview', False))
    except ValueError:
        preview = False

    entity = get_object_or_404(models.Entity, id=entity_id)
    contacts = entity.contact_set.all().order_by("has_left", "-main_contact", "lastname", "firstname")

    actions = models.Action.objects.filter(
        Q(entities=entity) | Q(contacts__entity=entity), Q(archived=False)
    ).distinct().order_by("planned_date", "priority")

    actions_by_set = get_actions_by_set(actions, 5)

    multi_user = True
    request.session["redirect_url"] = reverse('crm_view_entity', args=[entity_id])

    context = {
        "entity": entity,
        'contacts': contacts,
        'actions_by_set': actions_by_set,
        'multi_user': multi_user,
        'preview': preview,
        'template_base': "balafon/bs_base.html" if not preview else "balafon/bs_base_raw.html"
    }

    return render_to_response(
        'Crm/entity.html',
        context,
        context_instance=RequestContext(request)
    )
예제 #2
0
def view_opportunity(request, opportunity_id):
    """view"""
    opportunity = get_object_or_404(models.Opportunity, id=opportunity_id)
    actions = opportunity.action_set.filter(archived=False)
    actions_by_set = get_actions_by_set(actions)

    contacts = []
    for action in actions:
        contacts += [contact for contact in action.contacts.all()]
        for entity in action.entities.all():
            contacts += [contact for contact in entity.contact_set.filter(has_left=False)]
    contacts = list(set(contacts))
    contacts.sort(key=lambda contact_elt: contact_elt.lastname.lower())

    request.session["redirect_url"] = reverse('crm_view_opportunity', args=[opportunity.id])

    context = {
        'opportunity': opportunity,
        'actions_by_set': actions_by_set,
        'contacts': contacts,
    }

    return render(
        request,
        'Crm/view_opportunity.html',
        context,
    )
예제 #3
0
파일: contacts.py 프로젝트: ljean/balafon
def view_contact(request, contact_id):
    """view"""
    contact = get_object_or_404(models.Contact, id=contact_id)
    same_as_contact = None

    try:
        preview = bool(request.GET.get('preview', False))
    except ValueError:
        preview = False

    actions = contact.action_set.filter(archived=False)
    actions_by_set = get_actions_by_set(actions, 5)

    request.session["redirect_url"] = reverse('crm_view_contact', args=[contact_id])

    if contact.same_as:
        same_as_contact = models.Contact.objects.filter(
            same_as=contact.same_as
        ).exclude(id=contact.id).order_by('same_as_priority')

    return render(
        request,
        'Crm/view_contact.html',
        {
            'contact': contact,
            'actions_by_set': actions_by_set,
            'same_as': same_as_contact,
            'entity': contact.entity,
            'preview': preview,
            'template_base': "balafon/bs_base.html" if not preview else "balafon/bs_base_raw.html"
        }
    )
예제 #4
0
파일: entities.py 프로젝트: ljean/balafon
def view_entity(request, entity_id):
    """view"""

    try:
        preview = bool(request.GET.get('preview', False))
    except ValueError:
        preview = False

    entity = get_object_or_404(models.Entity, id=entity_id)
    contacts = entity.contact_set.all().order_by("has_left", "-main_contact", "lastname", "firstname")

    actions = models.Action.objects.filter(
        Q(entities=entity) | Q(contacts__entity=entity), Q(archived=False)
    ).distinct().order_by("planned_date", "priority")

    actions_by_set = get_actions_by_set(actions, 5)

    multi_user = True
    request.session["redirect_url"] = reverse('crm_view_entity', args=[entity_id])

    context = {
        "entity": entity,
        'contacts': contacts,
        'actions_by_set': actions_by_set,
        'multi_user': multi_user,
        'preview': preview,
        'template_base': "balafon/bs_base.html" if not preview else "balafon/bs_base_raw.html"
    }

    return render(
        request,
        'Crm/entity.html',
        context,
    )
예제 #5
0
def view_all_entity_actions(request, entity_id, action_set_id):
    """view"""
    entity = get_object_or_404(models.Entity, id=entity_id)
    if int(action_set_id):
        action_set_list = [
            get_object_or_404(models.ActionSet, id=action_set_id)
        ]
    else:
        action_set_list = [None]

    request.session["redirect_url"] = reverse('crm_view_entity_actions',
                                              args=[entity_id, action_set_id])

    actions = models.Action.objects.filter(
        Q(entities=entity) | Q(contacts__entity=entity),
        Q(archived=False)).distinct().order_by("planned_date", "priority")
    actions_by_set = get_actions_by_set(actions, 0, action_set_list)

    return render(request, 'Crm/view_entity_actions.html', {
        'actions_by_set': actions_by_set,
        'entity': entity
    })
예제 #6
0
def view_all_contact_actions(request, contact_id, action_set_id):
    """view"""
    contact = get_object_or_404(models.Contact, id=contact_id)
    if int(action_set_id):
        action_set_list = [get_object_or_404(models.ActionSet, id=action_set_id)]
    else:
        action_set_list = [None]

    request.session["redirect_url"] = reverse('crm_view_contact_actions', args=[contact_id, action_set_id])

    actions = contact.action_set.filter(archived=False).order_by("planned_date", "priority")
    actions_by_set = get_actions_by_set(actions, 0, action_set_list)

    return render_to_response(
        'Crm/view_contact_actions.html',
        {
            'contact': contact,
            'actions_by_set': actions_by_set,
            'entity': contact.entity
        },
        context_instance=RequestContext(request)
    )
예제 #7
0
def view_all_contact_actions(request, contact_id, action_set_id):
    """view"""
    contact = get_object_or_404(models.Contact, id=contact_id)
    if int(action_set_id):
        action_set_list = [
            get_object_or_404(models.ActionSet, id=action_set_id)
        ]
    else:
        action_set_list = [None]

    request.session["redirect_url"] = reverse('crm_view_contact_actions',
                                              args=[contact_id, action_set_id])

    actions = contact.action_set.filter(archived=False).order_by(
        "planned_date", "priority")
    actions_by_set = get_actions_by_set(actions, 0, action_set_list)

    return render(
        request, 'Crm/view_contact_actions.html', {
            'contact': contact,
            'actions_by_set': actions_by_set,
            'entity': contact.entity
        })
예제 #8
0
def view_all_entity_actions(request, entity_id, action_set_id):
    """view"""
    entity = get_object_or_404(models.Entity, id=entity_id)
    if int(action_set_id):
        action_set_list = [get_object_or_404(models.ActionSet, id=action_set_id)]
    else:
        action_set_list = [None]

    request.session["redirect_url"] = reverse('crm_view_entity_actions', args=[entity_id, action_set_id])

    actions = models.Action.objects.filter(
        Q(entities=entity) | Q(contacts__entity=entity),
        Q(archived=False)
    ).distinct().order_by("planned_date", "priority")
    actions_by_set = get_actions_by_set(actions, 0, action_set_list)

    return render_to_response(
        'Crm/view_entity_actions.html',
        {
            'actions_by_set': actions_by_set,
            'entity': entity
        },
        context_instance=RequestContext(request)
    )