Beispiel #1
0
def p_cities(request):
    """
    @api {get} /class/cities [班级]所有地市列表
    @apiGroup class
    @apiParamExample {json} 请求示例
        {'child':1返回地市+县区数据 0只返回地市数据,province_id:410000  省份id}
    @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": [
                {
                    "id": "410200",
                    "name": "开封市",
                    "child": [
                        {
                            "id": "410202",
                            "name": "龙亭区"
                        }
                    ]
                },
            ],
            "response": "ok",
            "error": ""
        }
    """
    args = request.QUERY.casts(child=int, province_id=int)
    child = args.child or 0
    province_id = args.province_id or 410000
    data = common.get_cities(province_id, child=child)
    return ajax.jsonp_ok(request, data)
Beispiel #2
0
def get_index_params(request):

    # Gets information of client: such as if it is mobile
    is_desktop = not parse(request.META['HTTP_USER_AGENT']).is_mobile

    # If campaign_id is not found; will default to the default_campaign.
    campaign_id = request.GET.get('campaign_id', cts.DEFAULT_CAMPAIGN_ID)
    campaign = Campaign.objects.filter(pk=campaign_id).first()
    campaign.translate(request.LANGUAGE_CODE)

    ip = get_ip(request)

    Visitor(ip=ip, is_mobile=not is_desktop).save()

    perks = campaign.bullets.filter(bullet_type__in=BulletType.objects.filter(
        name='perk'))
    requirements = campaign.bullets.filter(
        bullet_type__in=BulletType.objects.filter(name='requirement'))

    if campaign.image is None:
        campaign.image = "default"
        campaign.save()

    param_dict = {
        'job_title': campaign.title,
        'perks': translate_bullets(perks, request.LANGUAGE_CODE),
        'requirements': translate_bullets(requirements, request.LANGUAGE_CODE),
        'is_desktop': is_desktop,
        'work_areas': common.get_work_areas(request.LANGUAGE_CODE),
        'cities': common.get_cities(),
        'default_city': common.get_city(request),
        'image': campaign.image
    }

    if campaign_id is not None:
        param_dict['campaign_id'] = int(campaign_id)
        try:
            campaign = Campaign.objects.get(pk=int(campaign_id))
            campaign.translate(request.LANGUAGE_CODE)
            # if campaign exists send it.
            param_dict['campaign'] = campaign
        except ObjectDoesNotExist:
            pass

    return param_dict
Beispiel #3
0
def get_drop_down_values(language_code):
    """
    Gets lists of drop down values for several different fields.
    Args:
        language_code: 2 digit code (eg. 'es')
    Returns: A tuple containing (Countries, Education, Professions)
    """

    countries = common.get_countries()
    cities = common.get_cities()

    professions = common.get_professions(language_code)
    work_areas = common.get_work_areas(language_code)
    education = common.get_education(language_code)
    genders = common.get_genders(language_code)
    # TODO: add new drop down here

    return countries, cities, education, professions, work_areas, genders
Beispiel #4
0
def start_post(request):
    """
    Args:
        request: HTTP post request
    Returns: Renders form.html.
    """

    signup_form = CustomUserCreationForm(request.POST)

    if signup_form.is_valid():

        campaign, prospects = campaign_module.create_campaign(request)
        business_user = first_sign_in(signup_form, request)
        business_user.campaigns.add(campaign)
        business_user.save()
        send_signup_emails(business_user, request.LANGUAGE_CODE, campaign)

        #PublicPost.add_to_public_post_queue(campaign)
        if not business_user.is_peaku():
            prospect_module.send_mails(prospects)
            messenger.send(objects=prospects,
                           language_code='es',
                           body_input='candidate_prospect')

        return redirect(
            'tablero-de-control/{business_user_id}/{campaign_id}/applicants'.
            format(business_user_id=business_user.pk, campaign_id=campaign.pk))

    else:

        error_message = get_first_error_message(signup_form)
        return render(
            request, cts.START_VIEW_PATH, {
                'error_message':
                error_message,
                'work_areas':
                common.translate_list_of_objects(WorkArea.objects.all(),
                                                 request.LANGUAGE_CODE),
                'cities':
                common.get_cities()
            })
Beispiel #5
0
def start(request):
    """
    Only displays initial view.
    """

    city = common.get_city(request)

    return render(
        request, cts.START_VIEW_PATH, {
            'error_message':
            '',
            'work_areas':
            common.translate_list_of_objects(WorkArea.objects.all(),
                                             request.LANGUAGE_CODE),
            'cities':
            common.get_cities(),
            'default_city':
            city,
            'requirements':
            Requirement.objects.all(),
            'tests':
            Test.objects.filter(public=True).order_by('name_es')
        })