Beispiel #1
0
def _image_fields(user):
    profile = get_profile(user)
    image = profile and profile.image
    return {
        "photo_url": image.url if image else "",
        "photo_token": encrypt_image_token(image.name) if image else "",
    }
Beispiel #2
0
def _startup_description(startup, statuses, base_url):
    if startup.is_visible:
        return {
            "is_visible":
            True,
            "name":
            startup.name,
            "id":
            startup.id,
            "profile_url":
            base_url + startup.organization.url_slug,
            "image_token":
            encrypt_image_token(startup.high_resolution_logo.name)
            if startup.high_resolution_logo else '',
            "logo_url":
            logo_url(startup),
            "statuses": [status_description(status) for status in statuses],
        }
    else:
        return {
            "is_visible": False,
            "name": startup.name,
            "profile_url": "",
            "image_token": "",
            "logo_url": "",
            "statuses": [],
        }
    def _calc_result(self):
        jobs = self._get_jobs()
        program = self.data.program
        base_url = base_program_url(program)

        # Parameter `Keywords`
        if self.data.keywords:
            # Build up a big chain of Q objects, OR'd together
            query = Q()
            for kw in self.data.keywords:
                query |= Q(description__icontains=kw)
                query |= Q(title__icontains=kw)
            jobs = jobs.filter(query)

        # Parameter `JobType`
        if self.data.job_type:
            jobs = jobs.filter(type=self.data.job_type)

        # Parameter `OrderBy
        if self.data.order_by == "startup":
            jobs = jobs.order_by("startup__organization__name", "-postdate")
        elif self.data.order_by == "postdatedesc":
            jobs = jobs.order_by("-postdate", "startup__organization__name")
        elif self.data.order_by == "jobtype":
            jobs = jobs.order_by("type",
                                 "-postdate",
                                 "startup__organization__name")

        joblist = []
        for job in jobs:
            if job.startup.high_resolution_logo:
                image_token = encrypt_image_token(
                    job.startup.high_resolution_logo.name)
            else:
                image_token = ""
            url = ""
            if job.startup.is_visible:
                url = base_url + job.startup.organization.url_slug
            joblist.append({"startup_name": job.startup.name,
                            "startup_profile_url": url,
                            "startup_logo_image_token": image_token,
                            "title": job.title,
                            "type": job_type_description(job.type),
                            "application_email": job.applicationemail,
                            "more_info_url": job.more_info_url,
                            "description": job.description,
                            "post_date": job.postdate.strftime("%Y-%m-%d"),
                            "jobkey": job.pk,
                            })

        return {"job_postings": joblist}
Beispiel #4
0
 def _calc_result(self):
     startup = self.data.startup
     if not startup.is_visible:
         return EMPTY_DETAIL_RESULT
     return {
         "additional_industries": [
             industry.name
             for industry in startup.additional_industries.all()
         ],
         "facebook_url":
         startup.facebook_url,
         "full_elevator_pitch":
         startup.full_elevator_pitch,
         "is_visible":
         startup.is_visible,
         "linked_in_url":
         startup.linked_in_url,
         "name":
         startup.name,
         "primary_industry":
         startup.primary_industry.name,
         "public_inquiry_email":
         startup.public_inquiry_email,
         "short_pitch":
         startup.short_pitch,
         "twitter_handle":
         startup.twitter_handle,
         "website_url":
         startup.website_url,
         "image_token":
         encrypt_image_token(startup.high_resolution_logo.name),
         "logo_url":
         logo_url(startup),
         "profile_background_color":
         "#" + (startup.profile_background_color
                or DEFAULT_PROFILE_BACKGROUND_COLOR),
         "profile_text_color":
         "#" + (startup.profile_text_color or DEFAULT_PROFILE_TEXT_COLOR),
         "statuses":
         _statuses(startup, self.data.program),
         "team_members":
         self._team_members(),
         "video_elevator_pitch_url":
         _video_link(startup.video_elevator_pitch_url),
     }
 def _secure_image_token(self):
     return encrypt_image_token(
         self.request.GET["ImageToken"],
         password=settings.V0_SECURITY_KEY)
Beispiel #6
0
 def test_encrypt_image_token_returns_empty_binary_string_if_no_token(self):
     encrypted = encrypt_image_token(None)
     assert encrypted == b''