Exemplo n.º 1
0
def delete_prm_item(request):
    """
    Deletes Partners and Contacts

    """
    company = get_company_or_404(request)
    partner_id = request.REQUEST.get('partner')
    partner_id = get_int_or_none(partner_id)

    item_id = request.REQUEST.get('id')
    contact_id = get_int_or_none(item_id)

    content_id = request.REQUEST.get('ct')
    content_id = get_int_or_none(content_id)

    if content_id == ContentType.objects.get_for_model(Partner).id:
        partner = get_object_or_404(Partner, id=partner_id, owner=company)
        log_change(partner, None, request.user, partner, partner.name,
                   action_type=DELETION)
        partner.archive()
        return HttpResponseRedirect(reverse('prm') + '?company=' +
                                    str(company.id))
    elif content_id == ContentType.objects.get_for_model(ContactRecord).id:
        contact_record = get_object_or_404(ContactRecord, partner=partner_id,
                                           id=item_id)
        partner = get_object_or_404(Partner, id=partner_id, owner=company)
        # At one point, contacts could be deleted. The previous functionality
        # at this location couldn't handle that, accessing
        # contact_record.contact.name directly. Chaining getattr may not be
        # pretty but it ensures that we will never be accessing nonexistent
        # attributes.
        contact_name = getattr(getattr(contact_record,
                                       'contact',
                                       None),
                               'name',
                               '')
        log_change(contact_record, None, request.user, partner,
                   contact_name, action_type=DELETION)
        contact_record.archive()
        return HttpResponseRedirect(reverse('partner_records')+'?company=' +
                                    str(company.id)+'&partner=' +
                                    str(partner_id))
    elif content_id == ContentType.objects.get_for_model(PartnerSavedSearch).id:
        saved_search = get_object_or_404(PartnerSavedSearch, id=item_id)
        partner = get_object_or_404(Partner, id=partner_id, owner=company)
        log_change(saved_search, None, request.user, partner,
                   saved_search.email, action_type=DELETION)
        saved_search.delete()
        return HttpResponseRedirect(reverse('partner_searches')+'?company=' +
                                    str(company.id)+'&partner=' +
                                    str(partner_id))
    else:
        partner = get_object_or_404(Partner, id=partner_id, owner=company)
        contact = get_object_or_404(Contact, id=contact_id)
        log_change(contact, None, request.user, partner, contact.name,
                   action_type=DELETION)
        contact.archive()
        return HttpResponseRedirect(reverse('partner_details')+'?company=' +
                                    str(company.id)+'&partner=' +
                                    str(partner_id))
Exemplo n.º 2
0
def delete_prm_item(request):
    """
    Deletes Partners and Contacts

    """
    company = get_company_or_404(request)
    partner_id = request.REQUEST.get('partner')
    partner_id = get_int_or_none(partner_id)

    item_id = request.REQUEST.get('id')
    contact_id = get_int_or_none(item_id)

    content_id = request.REQUEST.get('ct')
    content_id = get_int_or_none(content_id)

    if content_id == ContentType.objects.get_for_model(Partner).id:
        partner = get_object_or_404(Partner, id=partner_id, owner=company)
        Contact.objects.filter(partner=partner).delete()
        log_change(partner, None, request.user, partner, partner.name,
                   action_type=DELETION)
        partner.delete()
        return HttpResponseRedirect(reverse('prm') + '?company=' +
                                    str(company.id))
    elif content_id == ContentType.objects.get_for_model(ContactRecord).id:
        contact_record = get_object_or_404(ContactRecord, partner=partner_id,
                                           id=item_id)
        partner = get_object_or_404(Partner, id=partner_id, owner=company)
        log_change(contact_record, None, request.user, partner,
                   contact_record.contact.name, action_type=DELETION)
        contact_record.delete()
        return HttpResponseRedirect(reverse('partner_records')+'?company=' +
                                    str(company.id)+'&partner=' +
                                    str(partner_id))
    elif content_id == ContentType.objects.get_for_model(PartnerSavedSearch).id:
        saved_search = get_object_or_404(PartnerSavedSearch, id=item_id)
        partner = get_object_or_404(Partner, id=partner_id, owner=company)
        log_change(saved_search, None, request.user, partner,
                   saved_search.email, action_type=DELETION)
        saved_search.delete()
        return HttpResponseRedirect(reverse('partner_searches')+'?company=' +
                                    str(company.id)+'&partner=' +
                                    str(partner_id))
    else:
        partner = get_object_or_404(Partner, id=partner_id, owner=company)
        contact = get_object_or_404(Contact, id=contact_id)
        log_change(contact, None, request.user, partner, contact.name,
                   action_type=DELETION)
        contact.delete()
        return HttpResponseRedirect(reverse('partner_details')+'?company=' +
                                    str(company.id)+'&partner=' +
                                    str(partner_id))
Exemplo n.º 3
0
def candidate_information(request):
    """
    Sends user info, primary name, and searches to candidate_information.html.
    Gathers the employer's (request.user) companies and microsites and puts
    the microsites' domains in a list for further checking and logic,
    see helpers.py.

    """
    user_id = get_int_or_none(request.REQUEST.get('user'))
    company = get_company(request)

    if not user_id or not company:
        raise Http404

    # user gets pulled out from id
    try:
        candidate = User.objects.get(id=user_id)
    except User.DoesNotExist:
        raise Http404

    if not candidate.opt_in_employers:
        raise Http404

    urls = saved_searches(request.user, company, candidate)
    actions = analytics(request.user, company, candidate)
    actions = get_analytics_counts(actions)

    if not urls and not actions:
        raise Http404

    manager = PrimaryNameProfileUnitManager(order=['employmenthistory',
                                                   'education',
                                                   'militaryservice'])
    models = manager.displayed_units(candidate.profileunits_set.all())

    primary_name = getattr(manager, 'primary_name', 'Name not given')

    coming_from = {'path': 'view'}

    searches = candidate.savedsearch_set.all()
    searches = [search for search in searches
                if get_domain(search.feed).lower() in urls]

    modified_url = remove_param_from_url(request.build_absolute_uri(), 'user')
    query_string = "?%s" % urlparse(modified_url).query

    data_dict = {
        'user_info': models,
        'company_id': company.pk,
        'primary_name': primary_name,
        'the_user': candidate,
        'searches': searches,
        'coming_from': coming_from,
        'query_string': query_string,
        'actions': actions,
    }

    return render_to_response('mydashboard/candidate_information.html',
                              data_dict, RequestContext(request))
Exemplo n.º 4
0
def prm_worthy(request):
    """
    Makes sure the User is worthy enough to use PRM.

    """
    company = get_company(request)
    if company is None:
        raise Http404

    partner_id = get_int_or_none(request.REQUEST.get('partner'))
    partner = get_object_or_404(company.partner_set, id=partner_id)

    return company, partner, request.user
Exemplo n.º 5
0
def prm_worthy(request):
    """
    Makes sure the User is worthy enough to use PRM.

    """
    company = get_company(request)
    if company is None:
        raise Http404("mypartners.helpers.prm_worthy: no company")

    partner_id = get_int_or_none(request.REQUEST.get('partner'))
    partner = get_object_or_404(company.partner_set, id=partner_id)

    return company, partner, request.user
Exemplo n.º 6
0
def talent_information(request):
    print user_is_allowed
    """
    Sends user info, primary name, and searches to talent_information.html.
    Gathers the employer's (request.user) companies and microsites and puts
    the microsites' domains in a list for further checking and logic,
    see helpers.py.

    """
    
    user_id = get_int_or_none(request.REQUEST.get('user'))
    print user_id

    
    try:
        talent = User.objects.get(id=user_id)
    except User.DoesNotExist:
        raise Http404

    
    manager = PrimaryNameProfileUnitManager(order=['basicinfo',
                                                    'experience',
                                                    'education',
                                                    'skill'
                                                    'social'])
    print type(talent)
    models = manager.displayed_units(talent.profileunits_set.all())


    
    data_dict = {
        'user_info': models,

    }
    print data_dict
    return render_to_response('mydashboard/talent_information.html',
                              data_dict, RequestContext(request))