Exemple #1
0
def jobs(request):
    publicly_available_jobs = Job.get_publicly_available_jobs()
    publicly_available_premium_jobs = Job.get_premium_jobs()

    user_filtered_query_set = JobFilter(request.GET,
                                        queryset=publicly_available_jobs)
    premium_filtered_query_set = JobFilter(
        request.GET, queryset=publicly_available_premium_jobs)

    paginator = Paginator(user_filtered_query_set.qs, 10)
    premium_paginator = Paginator(premium_filtered_query_set.qs, 10)

    try:
        page_number = int(request.GET.get("page", 1))
    except ValueError:
        return redirect("/")

    if page_number > paginator.num_pages:
        return redirect("/")

    public_jobs_to_display = paginator.page(page_number)
    premium_jobs_to_display = premium_paginator.page(1)

    context_dict = {
        "publicly_available_jobs": public_jobs_to_display,
        "premium_available_jobs": premium_jobs_to_display,
        "pages": paginator.page_range,
        "filter": user_filtered_query_set,
    }

    return render(request, template_name="jobs.html", context=context_dict)
Exemple #2
0
    def handle(self, *args, **options):
        if not check_today_is_the_right_day():
            print("Today is not the right day!")
            return

        emails_mailing_lists = [
            mailing.email for mailing in MailingList.objects.all()
        ]

        if len(emails_mailing_lists) == 0:
            print("There are no mailing lists!")
            return

        emails_mailing_replies = [
            format_owner_email(email) for email in emails_mailing_lists
        ]

        to_emails = emails_mailing_replies
        from_emails = emails_mailing_lists

        jobs = list(Job.get_premium_jobs())

        missing_jobs = 10 - len(jobs)

        jobs += list(Job.get_feed_jobs())[:missing_jobs]

        if len(jobs) == 0:
            print("There are no jobs on the platform!")
            return

        plain_text = get_template("emails/weekly_summary.txt")

        subject = "[Vagas][PyJobs] Vagas Python da semana passada"

        context = {
            "dono_do_site": settings.WEBSITE_OWNER_NAME,
            "nome_do_site": settings.WEBSITE_NAME,
            "url_do_site": settings.WEBSITE_HOME_URL,
            "jobs": jobs,
        }

        text_content = plain_text.render(context)

        for email_tup in zip(to_emails, from_emails):
            msg = EmailMultiAlternatives(subject, text_content, email_tup[0],
                                         [email_tup[1]])

            msg.send()

        print("Message sent!")
Exemple #3
0
    def handle(self, *args, **options):
        if not check_today_is_the_right_day():
            return "False"

        jobs = list(Job.get_premium_jobs())

        missing_jobs = 10 - len(jobs)

        jobs += list(Job.get_feed_jobs())[:missing_jobs]

        formated_jobs = [format_job(job) for job in jobs]

        post_telegram_channel(format_message_text(formated_jobs))

        return "True"
    def handle(self, *args, **options):
        if not check_today_is_the_right_day():
            print("Today is not the right day!")
            return

        jobs = list(Job.get_premium_jobs())

        missing_jobs = 10 - len(jobs)

        jobs += list(Job.get_feed_jobs())[:missing_jobs]

        formated_jobs = [format_job(job) for job in jobs]

        post_telegram_channel(format_message_text(formated_jobs))

        print("Message sent!")
Exemple #5
0
def job_skill_view(request, unique_slug):
    """
    This view will return jobs related to a certain skill,
    i.e., Django Jobs or Flask Jobs.
    """
    skill = Skill.objects.filter(unique_slug=unique_slug).first()

    if not skill:
        return redirect("/")

    publicly_available_jobs = Job.get_publicly_available_jobs().filter(
        skills=skill)
    publicly_available_premium_jobs = Job.get_premium_jobs().filter(
        skills=skill)

    paginator = Paginator(publicly_available_jobs, 10)
    premium_paginator = Paginator(publicly_available_premium_jobs, 10)

    try:
        page_number = int(request.GET.get("page", 1))
    except ValueError:
        return redirect("/")

    if page_number > paginator.num_pages:
        return redirect("/")

    public_jobs_to_display = paginator.page(page_number)
    premium_jobs_to_display = premium_paginator.page(1)

    context_dict = {
        "publicly_available_jobs": public_jobs_to_display,
        "premium_available_jobs": premium_jobs_to_display,
        "pages": paginator.page_range,
        "skill": skill,
        "webpush": WEBPUSH_CONTEXT,
    }

    return render(
        request,
        template_name="jobs_by_skill.html",
        context=context_dict,
    )
Exemple #6
0
def index(request):
    search = (request.GET.get("search", "")
              if len(request.GET.get("search", "")) > 3 else None)

    paginator = Paginator(Job.get_publicly_available_jobs(search), 7)

    try:
        page_number = int(request.GET.get("page", 1))
    except ValueError:
        return redirect("/")

    if page_number > paginator.num_pages:
        return redirect("/")

    public_jobs_to_display = paginator.page(page_number)

    context_dict = {
        "publicly_available_jobs": public_jobs_to_display,
        "premium_available_jobs": Job.get_premium_jobs(),
        "new_job_form": JobForm,
        "pages": paginator.page_range,
        "search": search if search is not None else "",
    }
    return render(request, template_name="index.html", context=context_dict)
Exemple #7
0
 def test_premium_available(self):
     self.assertTrue((self.job not in Job.get_premium_jobs()))
Exemple #8
0
 def items(self):
     return Job.get_premium_jobs()
Exemple #9
0
def job_state_view(request, state):
    states = {
        "acre": (0, "Acre"),
        "alagoas": (1, "Alagoas"),
        "amapa": (2, "Amapá"),
        "amazonas": (3, "Amazonas"),
        "bahia": (4, "Bahia"),
        "ceara": (5, "Ceará"),
        "distrito-federal": (6, "Distrito Federal"),
        "espirito-santo": (7, "Espírito Santo"),
        "goias": (8, "Goiás"),
        "maranhao": (9, "Maranhão"),
        "mato-grosso": (10, "Mato Grosso"),
        "mato-grosso-do-sul": (11, "Mato Grosso do Sul"),
        "minas-gerais": (12, "Minas Gerais"),
        "para": (13, "Pará"),
        "paraiba": (14, "Paraíba"),
        "parana": (15, "Paraná"),
        "pernambuco": (16, "Pernambuco"),
        "piaui": (17, "Piauí"),
        "rio-de-janeiro": (18, "Rio de Janeiro"),
        "rio-grande-do-norte": (19, "Rio Grande do Norte"),
        "rio-grande-do-sul": (20, "Rio Grande do Sul"),
        "rondonia": (21, "Rondônia"),
        "roraima": (22, "Roraima"),
        "santa-catarina": (23, "Santa Catarina"),
        "sao-paulo": (24, "São Paulo"),
        "sergipe": (25, "Sergipe"),
        "tocantins": (26, "Tocantins"),
    }

    if state not in states.keys():
        return redirect("/")

    publicly_available_jobs = Job.get_publicly_available_jobs().filter(
        state=states[state][0])
    publicly_available_premium_jobs = Job.get_premium_jobs().filter(
        state=states[state][0])

    paginator = Paginator(publicly_available_jobs, 10)
    premium_paginator = Paginator(publicly_available_premium_jobs, 10)

    try:
        page_number = int(request.GET.get("page", 1))
    except ValueError:
        return redirect("/")

    if page_number > paginator.num_pages:
        return redirect("/")

    public_jobs_to_display = paginator.page(page_number)
    premium_jobs_to_display = premium_paginator.page(1)

    context_dict = {
        "publicly_available_jobs": public_jobs_to_display,
        "premium_available_jobs": premium_jobs_to_display,
        "pages": paginator.page_range,
        "state": states[state][1],
        "webpush": WEBPUSH_CONTEXT,
    }

    return render(
        request,
        template_name="jobs_by_location.html",
        context=context_dict,
    )