• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python helpers.prm_worthy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: get_records

def get_records(request):
    """
    Returns a json object containing the records matching the search
    criteria (contact, contact_type, and date_time range) rendered using
    records.html and the date range and date string required to update
    the time_filter.html template to match the search.

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

    contact = request.REQUEST.get('contact')
    contact_type = request.REQUEST.get('record_type')

    contact = None if contact in ['all', 'undefined'] else contact
    contact_type = None if contact_type in ['all', 'undefined'
                                            ] else contact_type
    dt_range, date_str, records = get_records_from_request(request)

    ctx = {
        'records': records.order_by('-date_time'),
        'company': company,
        'partner': partner,
        'contact_type': None if contact_type == 'all' else contact_type,
        'contact_name': None if contact == 'all' else contact,
        'view_name': 'PRM'
    }

    # Because javascript is going to use this, not a template,
    # convert to localtime here
    date_end = localtime(dt_range[1].replace(tzinfo=pytz.utc))
    date_start = localtime(dt_range[0].replace(tzinfo=pytz.utc))

    data = {
        'month_end':
        date_end.strftime('%m'),
        'day_end':
        date_end.strftime('%d'),
        'year_end':
        date_end.strftime('%Y'),
        'month_start':
        date_start.strftime('%m'),
        'day_start':
        date_start.strftime('%d'),
        'year_start':
        date_start.strftime('%Y'),
        'date_str':
        date_str,
        'html':
        render_to_response('mypartners/records.html', ctx,
                           RequestContext(request)).content,
    }
    return HttpResponse(json.dumps(data))
开发者ID:vfulco,项目名称:MyJobs,代码行数:52,代码来源:views.py


示例17: 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.update_last_action_time()
    contact.locations.remove(location)

    content_id = ContentType.objects.get_for_model(contact.__class__).pk
    return HttpResponseRedirect(
        reverse('edit_contact') + "?partner=%s&id=%s&ct=%s" % (
            partner.id, contact.id, content_id))
开发者ID:wejhink,项目名称:MyJobs,代码行数:13,代码来源:views.py


示例18: prm_view_records

def prm_view_records(request):
    """
    View an individual ContactRecord.

    """
    company, partner, _ = prm_worthy(request)
    _, _, contact_records = get_records_from_request(request)
    page_number = int(request.GET.get('page', 1))
    record_id = int(request.GET.get('id', 0))

    # change number of objects per page
    paginator = Paginator(contact_records, 1)

    if record_id:
        pks = list(contact_records.values_list('pk', flat=True))

        if record_id in pks:
            page_number = pks.index(record_id) + 1
        else:
            page_number = 1
            paginator = Paginator(
                ContactRecord.objects.filter(pk=record_id), 1)

    paginated_records = paginator.page(page_number)
    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)

    search_params = request.GET.copy()
    navigation_params = search_params.copy()
    navigation_params.pop('id', None)

    ctx = {
        'record': record,
        'records': paginated_records,
        'partner': partner,
        'company': company,
        'attachments': attachments,
        'record_history': record_history,
        'view_name': 'PRM',
        'page': page_number,
        'search_params': urlencode(search_params),
        'navigation_params': urlencode(navigation_params)
    }

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


示例19: 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:vfulco,项目名称:MyJobs,代码行数:48,代码来源:views.py


示例20: prm_edit_saved_search

def prm_edit_saved_search(request):
    company, partner, user = prm_worthy(request)
    item_id = request.REQUEST.get('id')
    copy_id = request.REQUEST.get('copies')

    if item_id:
        instance = get_object_or_404(PartnerSavedSearch, id=item_id)
        form = PartnerSavedSearchForm(
            partner=partner, instance=instance, request=request)
    elif copy_id:
        try:
            values = PartnerSavedSearch.objects.filter(pk=copy_id).values()[0]
        except IndexError:
            # saved search to be copied doesn't exist since values is empty
            raise Http404
        else:
            values['label'] = "Copy of %s" % values['label']
            values.pop('email', None)
            values.pop('notes', None)
            values.pop('custom_message', None)
            values.pop('partner_message', None)
            form = PartnerSavedSearchForm(
                initial=values, partner=partner, request=request)
    else:
        form = PartnerSavedSearchForm(partner=partner, request=request)

    microsites = company.prm_saved_search_sites.values_list(
        'domain', flat=True)
    microsites = [
        site.replace('http://', '').replace('https://', '').lower()
        for site in microsites
    ]

    ctx = {
        'company': company,
        'partner': partner,
        'item_id': item_id,
        'form': form,
        'microsites': set(microsites),
        'content_type':
        ContentType.objects.get_for_model(PartnerSavedSearch).id,
        'view_name': 'PRM',
    }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.ContactFactory类代码示例发布时间:2022-05-27
下一篇:
Python myparser.parser函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap