Beispiel #1
0
def partner_library(request):
    company = get_company_or_404(request)

    if request.is_ajax():
        partners = filter_partners(request, True)
        paginator = add_pagination(request, partners)
        ctx = {
            'partners': paginator,
            'on_page': 'partner_library'
        }
        response = HttpResponse()
        html = render_to_response('mypartners/includes/partner_column.html',
                                  ctx, RequestContext(request))
        response.content = html.content
        return response

    partners = filter_partners(request, True)
    paginator = add_pagination(request, partners)

    ctx = {
        'company': company,
        'view_name': 'PRM',
        'partners': paginator
    }

    return render_to_response('mypartners/partner_library.html', ctx,
                              RequestContext(request))
Beispiel #2
0
def prm(request):
    """
    Partner Relationship Manager

    """
    company = get_company_or_404(request)

    partners = filter_partners(request)
    paginator = add_pagination(request, partners) if partners else None

    if request.is_ajax():
        ctx = {
            'partners': paginator,
            'on_page': 'prm',
            'ajax': 'true',
        }
        response = HttpResponse()
        html = render_to_response('mypartners/includes/partner_column.html',
                                  ctx, RequestContext(request))
        response.content = html.content
        return response

    ctx = {
        'has_partners': True if paginator else False,
        'partners': paginator,
        'company': company,
        'user': request.user,
        'partner_ct': ContentType.objects.get_for_model(Partner).id,
        'view_name': 'PRM',
    }

    return render_to_response('mypartners/prm.html', ctx,
                              RequestContext(request))
Beispiel #3
0
def prm_saved_searches(request):
    """
    View that lists the Partner's Saved Searches

    """
    company, partner, user = prm_worthy(request)
    saved_searches = partner.get_searches()
    saved_searches = add_pagination(request, saved_searches)
    if request.is_ajax():
        ctx = {
            'partner': partner,
            'searches': saved_searches
        }
        response = HttpResponse()
        html = render_to_response(
            'mypartners/includes/searches_column.html', ctx,
            RequestContext(request))
        response.content = html.content
        return response

    ctx = {
        'searches': saved_searches,
        'company': company,
        'partner': partner,
    }
    return render_to_response('mypartners/partner_searches.html', ctx,
                              RequestContext(request))
Beispiel #4
0
def prm(request):
    """
    Partner Relationship Manager

    """
    company = get_company_or_404(request)

    partners = filter_partners(request)
    paginator = add_pagination(request, partners) if partners else None

    if request.is_ajax():
        ctx = {"partners": paginator, "on_page": "prm", "ajax": "true"}
        response = HttpResponse()
        html = render_to_response("mypartners/includes/partner_column.html", ctx, RequestContext(request))
        response.content = html.content
        return response

    ctx = {
        "has_partners": True if paginator else False,
        "partners": paginator,
        "company": company,
        "user": request.user,
        "partner_ct": ContentType.objects.get_for_model(Partner).id,
        "view_name": "PRM",
    }

    return render_to_response("mypartners/prm.html", ctx, RequestContext(request))
Beispiel #5
0
def prm_records(request):
    """
    ContactRecord overview and ContactRecord overview from PRM reports.

    """
    company, partner, _ = prm_worthy(request)
    _, _, contact_records = get_records_from_request(request)
    paginated_records = add_pagination(request, contact_records)

    if request.is_ajax():
        ctx = {"partner": partner, "records": paginated_records}
        response = HttpResponse()
        html = render_to_response("mypartners/includes/contact_record_column.html", ctx, RequestContext(request))
        response.content = html.content
        return response

    contact_type_choices = (("all", "All"),) + CONTACT_TYPE_CHOICES

    contact_choices = [
        (c, c) for c in contact_records.order_by("contact__name").distinct().values_list("contact__name", flat=True)
    ]
    contact_choices.insert(0, ("all", "All"))

    ctx = {
        "admin_id": request.REQUEST.get("admin"),
        "company": company,
        "contact_choices": contact_choices,
        "contact_type_choices": contact_type_choices,
        "partner": partner,
        "records": paginated_records,
        "view_name": "PRM",
    }

    return render_to_response("mypartners/main_records.html", ctx, RequestContext(request))
Beispiel #6
0
def partner_library(request):
    company = get_company_or_404(request)

    if request.is_ajax():
        partners = filter_partners(request, True)
        paginator = add_pagination(request, partners)
        ctx = {"partners": paginator, "on_page": "partner_library"}
        response = HttpResponse()
        html = render_to_response("mypartners/includes/partner_column.html", ctx, RequestContext(request))
        response.content = html.content
        return response

    partners = filter_partners(request, True)
    paginator = add_pagination(request, partners)

    ctx = {"company": company, "view_name": "PRM", "partners": paginator}

    return render_to_response("mypartners/partner_library.html", ctx, RequestContext(request))
Beispiel #7
0
def prm_records(request):
    """
    ContactRecord overview and ContactRecord overview from PRM reports.

    """
    company, partner, _ = prm_worthy(request)
    _, _, contact_records = get_records_from_request(request)
    paginated_records = add_pagination(request, contact_records)

    if request.is_ajax():
        ctx = {
            'partner': partner,
            'records': paginated_records
        }
        response = HttpResponse()
        html = render_to_response(
            'mypartners/includes/contact_record_column.html', ctx,
            RequestContext(request))
        response.content = html.content
        return response

    contact_type_choices = (('all', 'All'),) + CONTACT_TYPE_CHOICES

    contact_choices = [
        (c, c) for c in contact_records.order_by(
            'contact__name').distinct().values_list('contact__name', flat=True)]
    contact_choices.insert(0, ('all', 'All'))

    ctx = {
        'admin_id': request.REQUEST.get('admin'),
        'company': company,
        'contact_choices': contact_choices,
        'contact_type_choices': contact_type_choices,
        'partner': partner,
        'records': paginated_records,
        'view_name': 'PRM',
    }

    return render_to_response('mypartners/main_records.html', ctx,
                              RequestContext(request))
Beispiel #8
0
def prm_view_records(request):
    """
    View an individual ContactRecord.

    """
    company, partner, _ = prm_worthy(request)
    _, _, contact_records = get_records_from_request(request)
    try:
        page = int(request.GET.get('page', 1))
    except ValueError:
        page = 1
    # change number of objects per page
    paginated_records = add_pagination(request, contact_records, 1)

    if len(paginated_records.object_list) > 1:
        record = paginated_records.object_list[page - 1]
    else:
        record = paginated_records.object_list[0]

    attachments = record.prmattachment_set.all()
    record_history = ContactLogEntry.objects.filter(
        object_id=record.pk, content_type_id=ContentType.objects.get_for_model(
            ContactRecord).pk)

    ctx = {
        'record': record,
        'records': paginated_records,
        'partner': partner,
        'company': company,
        'attachments': attachments,
        'record_history': record_history,
        'view_name': 'PRM',
        'page': page
    }

    return render_to_response('mypartners/view_record.html', ctx,
                              RequestContext(request))
Beispiel #9
0
def prm_view_records(request):
    """
    View an individual ContactRecord.

    """
    company, partner, _ = prm_worthy(request)
    _, _, contact_records = get_records_from_request(request)
    try:
        page = int(request.GET.get("page", 1))
    except ValueError:
        page = 1
    # change number of objects per page
    paginated_records = add_pagination(request, contact_records, 1)

    if len(paginated_records.object_list) > 1:
        record = paginated_records.object_list[page - 1]
    else:
        record = paginated_records.object_list[0]

    attachments = record.prmattachment_set.all()
    record_history = ContactLogEntry.objects.filter(
        object_id=record.pk, content_type_id=ContentType.objects.get_for_model(ContactRecord).pk
    )

    ctx = {
        "record": record,
        "records": paginated_records,
        "partner": partner,
        "company": company,
        "attachments": attachments,
        "record_history": record_history,
        "view_name": "PRM",
        "page": page,
    }

    return render_to_response("mypartners/view_record.html", ctx, RequestContext(request))