当前位置: 首页>>代码示例>>Python>>正文


Python helpers.prm_worthy函数代码示例

本文整理汇总了Python中mypartners.helpers.prm_worthy函数的典型用法代码示例。如果您正苦于以下问题:Python prm_worthy函数的具体用法?Python prm_worthy怎么用?Python prm_worthy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了prm_worthy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: partner_get_records

def partner_get_records(request):
    if request.method == "GET":
        prm_worthy(request)

        dt_range, date_str, records = get_records_from_request(request)
        records = records.exclude(contact_type="job")
        email = records.filter(contact_type="email").count()
        email += records.filter(contact_type="pssemail").count()
        phone = records.filter(contact_type="phone").count()
        meetingorevent = records.filter(contact_type="meetingorevent").count()

        # figure names
        if email != 1:
            email_name = "Emails"
        else:
            email_name = "Email"
        if phone != 1:
            phone_name = "Phone Calls"
        else:
            phone_name = "Phone Call"
        if meetingorevent != 1:
            meetingorevent_name = "Meeting or Event"
        else:
            meetingorevent_name = "Meetings & Events"

        data = SortedDict()

        data["email"] = {"count": email, "name": email_name, "typename": "email"}
        data["phone"] = {"count": phone, "name": phone_name, "typename": "phone"}
        data["meetingorevent"] = {"count": meetingorevent, "name": meetingorevent_name, "typename": "meetingorevent"}

        return HttpResponse(json.dumps(data))
    else:
        raise Http404
开发者ID:vfulco,项目名称:MyJobs,代码行数:34,代码来源:views.py

示例2: partner_get_referrals

def partner_get_referrals(request):
    if request.method == "GET":
        prm_worthy(request)
        dt_range, date_str, records = get_records_from_request(request)

        # figure names
        if records.applications != 1:
            app_name = "Applications"
        else:
            app_name = "Application"
        if records.interviews != 1:
            interview_name = "Interviews"
        else:
            interview_name = "Interview"
        if records.hires != 1:
            hire_name = "Hires"
        else:
            hire_name = "Hire"

        data = {
            "applications": {"count": records.applications, "name": app_name, "typename": "job"},
            "interviews": {"count": records.interviews, "name": interview_name, "typename": "job"},
            "hires": {"count": records.hires, "name": hire_name, "typename": "job"},
        }

        return HttpResponse(json.dumps(data))
    else:
        raise Http404
开发者ID:vfulco,项目名称:MyJobs,代码行数:28,代码来源:views.py

示例3: partner_get_referrals

def partner_get_referrals(request):
    if request.method == 'GET':
        prm_worthy(request)
        dt_range, date_str, records = get_records_from_request(request)

        # figure names
        if records.applications != 1:
            app_name = 'Applications'
        else:
            app_name = 'Application'
        if records.interviews != 1:
            interview_name = 'Interviews'
        else:
            interview_name = 'Interview'
        if records.hires != 1:
            hire_name = 'Hires'
        else:
            hire_name = 'Hire'

        data = {
            'applications': {'count': records.applications, 'name': app_name,
                             'typename': 'job'},
            'interviews': {'count': records.interviews, 'name': interview_name,
                           'typename': 'job'},
            'hires': {'count': records.hires, 'name': hire_name,
                      'typename': 'job'},
        }

        return HttpResponse(json.dumps(data))
    else:
        raise Http404
开发者ID:zeus911,项目名称:MyJobs,代码行数:31,代码来源:views.py

示例4: prm_edit_records

def prm_edit_records(request):
    company, partner, user = prm_worthy(request)
    record_id = request.GET.get('id', None)

    try:
        instance = ContactRecord.objects.get(pk=record_id)
    except ContactRecord.DoesNotExist:
        instance = None

    if request.method == 'POST':
        instance = None
        if record_id:
            try:
                instance = ContactRecord.objects.get(pk=record_id)
            except ContactRecord.DoesNotExist:
                instance = None

        form = ContactRecordForm(request.POST, request.FILES,
                                 partner=partner, instance=instance)
        if form.is_valid():
            form.save(user, partner)
            return HttpResponseRedirect(reverse('record_view') + '?' +
                                        request.META['QUERY_STRING'])
    else:
        form = ContactRecordForm(partner=partner, instance=instance)

    ctx = {
        'company': company,
        'partner': partner,
        'content_type': ContentType.objects.get_for_model(ContactRecord).id,
        'item_id': record_id,
        'form': form,
    }
    return render_to_response('mypartners/edit_record.html', ctx,
                              RequestContext(request))
开发者ID:vfulco,项目名称:MyJobs,代码行数:35,代码来源:views.py

示例5: partner_savedsearch_save

def partner_savedsearch_save(request):
    """
    Handles saving the PartnerSavedSearchForm and creating the inactive user
    if it is needed.

    """
    company, partner, user = prm_worthy(request)
    item_id = request.REQUEST.get("id", None)

    if item_id:
        item = get_object_or_404(PartnerSavedSearch, id=item_id, provider=company.id)
        form = PartnerSavedSearchForm(instance=item, auto_id=False, data=request.POST, partner=partner, request=request)
        if form.is_valid():
            form.save()
            return HttpResponse(status=200)
        else:
            return HttpResponse(json.dumps(form.errors))
    form = PartnerSavedSearchForm(request.POST, partner=partner, request=request)

    # Since the feed is created below, this will always be invalid.
    if "feed" in form.errors:
        del form.errors["feed"]

    if form.is_valid():
        instance = form.instance
        instance.provider = company
        instance.partner = partner
        instance.created_by = request.user
        instance.custom_message = instance.partner_message
        form.save()
        return HttpResponse(status=200)
    else:
        return HttpResponse(json.dumps(form.errors))
开发者ID:vfulco,项目名称:MyJobs,代码行数:33,代码来源:views.py

示例6: prm_overview

def prm_overview(request):
    """
    View that is the "Overview" of one's Partner Activity.

    """
    company, partner, user = prm_worthy(request)

    most_recent_activity = partner.get_logs()
    records = partner.get_contact_records()
    total_records = partner.get_contact_records().count()
    communication = records.order_by('-date_time')
    referrals = records.filter(contact_type='job').count()
    records = records.exclude(contact_type='job').count()
    most_recent_communication = communication[:1]
    saved_searches = partner.get_searches()
    most_recent_saved_searches = saved_searches[:1]

    ctx = {'partner': partner,
           'company': company,
           'recent_activity': most_recent_activity,
           'recent_communication': most_recent_communication,
           'recent_ss': most_recent_saved_searches,
           'count': records,
           'referrals': referrals,
           'view_name': 'PRM',
           'total_records': total_records}

    return render_to_response('mypartners/overview.html', ctx,
                              RequestContext(request))
开发者ID:zeus911,项目名称:MyJobs,代码行数:29,代码来源:views.py

示例7: get_contact_information

def get_contact_information(request):
    """
    Returns a json object containing a contact's email address and
    phone number if they have one.

    """
    if request.method == "POST" and request.is_ajax():
        _, partner, _ = prm_worthy(request)

        contact_id = request.POST.get('contact') or None
        try:
            contact = Contact.objects.get(pk=contact_id)
        except Contact.DoesNotExist:
            data = {'error': 'Contact does not exist'}
            return HttpResponse(json.dumps(data))

        if partner != contact.partner:
            data = {'error': 'Permission denied'}
            return HttpResponse(json.dumps(data))

        if hasattr(contact, 'email'):
            if hasattr(contact, 'phone'):
                data = {'email': contact.email,
                        'phone': contact.phone}
            else:
                data = {'email': contact.email}
        else:
            if hasattr(contact, 'phone'):
                data = {'phone': contact.phone}
            else:
                data = {}

        return HttpResponse(json.dumps(data))
    else:
        return Http404("This view is only reachable by an AJAX POST request.")
开发者ID:zeus911,项目名称:MyJobs,代码行数:35,代码来源:views.py

示例8: prm_records

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))
开发者ID:vfulco,项目名称:MyJobs,代码行数:34,代码来源:views.py

示例9: get_uploaded_file

def get_uploaded_file(request):
    """
    Determines the location of a PRMAttachment (either in S3 or in local
    storage) and redirects to it.

    PRMAttachments stored in S3 require a generated key and have a 10 minute
    access window.

    """
    company, partner, user = prm_worthy(request)
    file_id = request.GET.get('id', None)
    attachment = get_object_or_404(PRMAttachment, pk=file_id,
                                   contact_record__partner=partner)
    try:
        if repr(default_storage.connection) == 'S3Connection:s3.amazonaws.com':
            from boto.s3.connection import S3Connection

            s3 = S3Connection(settings.AWS_ACCESS_KEY_ID,
                              settings.AWS_SECRET_KEY, is_secure=True)
            path = s3.generate_url(600, 'GET',
                                   bucket=settings.AWS_STORAGE_BUCKET_NAME,
                                   key=attachment.attachment.name,
                                   force_http=True)
        else:
            path = "%s%s" % (settings.MEDIA_URL, attachment.attachment.name)
    except AttributeError:
        path = "%s%s" % (settings.MEDIA_URL, attachment.attachment.name)

    return HttpResponseRedirect(path)
开发者ID:zeus911,项目名称:MyJobs,代码行数:29,代码来源:views.py

示例10: prm_saved_searches

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))
开发者ID:zeus911,项目名称:MyJobs,代码行数:27,代码来源:views.py

示例11: edit_location

def edit_location(request):
    company, partner, _ = prm_worthy(request)
    contact = get_object_or_none(Contact, id=request.REQUEST.get("id"))
    location = get_object_or_none(Location, id=request.REQUEST.get("location"))

    if request.method == "POST":
        if location:
            form = LocationForm(request.POST, instance=location)
        else:
            form = LocationForm(request.POST)

        if form.is_valid():
            location = form.save(request)

            if location not in contact.locations.all():
                contact.locations.add(location)
                contact.save()

            return HttpResponseRedirect(reverse("edit_contact") + "?partner=%s&id=%s" % (partner.id, contact.id))
    else:
        form = LocationForm(instance=location)

    ctx = {"form": form, "company": company, "partner": str(partner.id)}
    if contact:
        ctx["contact"] = str(contact.id)
    if location:
        ctx["location"] = str(location.id)

    return render_to_response("mypartners/edit_location.html", ctx, RequestContext(request))
开发者ID:vfulco,项目名称:MyJobs,代码行数:29,代码来源:views.py

示例12: prm_overview

def prm_overview(request):
    """
    View that is the "Overview" of one's Partner Activity.

    """
    company, partner, user = prm_worthy(request)

    most_recent_activity = partner.get_logs()
    records = partner.get_contact_records()
    total_records = partner.get_contact_records().count()
    communication = records.order_by("-date_time")
    referrals = records.filter(contact_type="job").count()
    records = records.exclude(contact_type="job").count()
    most_recent_communication = communication[:1]
    saved_searches = partner.get_searches()
    most_recent_saved_searches = saved_searches[:1]

    ctx = {
        "partner": partner,
        "company": company,
        "recent_activity": most_recent_activity,
        "recent_communication": most_recent_communication,
        "recent_ss": most_recent_saved_searches,
        "count": records,
        "referrals": referrals,
        "view_name": "PRM",
        "total_records": total_records,
    }

    return render_to_response("mypartners/overview.html", ctx, RequestContext(request))
开发者ID:vfulco,项目名称:MyJobs,代码行数:30,代码来源:views.py

示例13: delete_location

def delete_location(request):
    company, partner, _ = prm_worthy(request)
    contact = get_object_or_404(Contact, pk=request.REQUEST.get("id", 0))
    location = get_object_or_404(Location, pk=request.REQUEST.get("location", 0))

    contact.locations.remove(location)

    return HttpResponseRedirect(reverse("edit_contact") + "?partner=%s&id=%s" % (partner.id, contact.id))
开发者ID:vfulco,项目名称:MyJobs,代码行数:8,代码来源:views.py

示例14: save

    def save(self, request, commit=True):
        new_or_change = CHANGE if self.instance.pk else ADDITION

        instance = super(LocationForm, self).save(commit)
        _, partner, _ = prm_worthy(request)
        log_change(instance, self, request.user, partner, instance.label,
                   action_type=new_or_change)

        return instance
开发者ID:vfulco,项目名称:MyJobs,代码行数:9,代码来源:forms.py

示例15: prm_export

def prm_export(request):
    #TODO: investigate using django's builtin serialization for XML
    company, partner, user = prm_worthy(request)
    file_format = request.REQUEST.get('file_format', 'csv')
    fields = retrieve_fields(ContactRecord)
    _, _, records = get_records_from_request(request)

    if file_format == 'xml':
        root = etree.Element("contact_records")
        for record in records:
            xml_record = etree.SubElement(root, "record")
            for field in fields:
                xml = etree.SubElement(xml_record, field)
                value = getattr(record, field, '')

                if hasattr(value, 'all'):
                    value = ', '.join([val.name for val in value.all() if val])

                xml.text = contact_record_val_to_str(value)
        response = HttpResponse(etree.tostring(root, pretty_print=True,
                                               xml_declaration=True),
                                mimetype='application/force-download')
    elif file_format == 'printer_friendly':
        ctx = {
            'company': company,
            'fields': fields,
            'partner': partner,
            'records': records,
        }
        return render_to_response('mypartners/printer_friendly.html', ctx,
                                  RequestContext(request))
    # CSV/XLS
    else:
        response = HttpResponse(content_type='text/csv')
        writer = unicodecsv.writer(response, encoding='utf-8')
        writer.writerow(fields)
        for record in records:
            values = [getattr(record, field, '') for field in fields]
            values = [
                contact_record_val_to_str(v)
                if not hasattr(v, 'all') else
                ', '.join([val.name for val in v.all() if val]) for v in values
            ]
            # Remove the HTML and reformat.
            values = [strip_tags(v) for v in values]
            # replaces multiple occurences of space by a single sapce.
            values = [' '.join(filter(bool, v.split(' '))) for v in values]
            values = [re.sub('\s+\n\s+', '\n', v) for v in values]
            writer.writerow(values)

    response['Content-Disposition'] = 'attachment; ' \
                                      'filename="company_record_report".%s' \
                                      % file_format

    return response
开发者ID:zeus911,项目名称:MyJobs,代码行数:55,代码来源:views.py


注:本文中的mypartners.helpers.prm_worthy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。