Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the old jobs code #583

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions community/tests/test_homepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from community.views import HomePageView, RECENT_ITEMS_LEN
from events.tests.factories import EventFactory
from jobs.tests.factories import JobFactory
from joboffers.models import OfferState
from joboffers.tests.factories import JobOfferFactory
from news.tests.factories import NewsArticleFactory


Expand All @@ -32,11 +33,11 @@ def test_included_events_have_correct_fields(self):
# Events already have a description field

def test_jobs_are_included_in_recent(self):
job = JobFactory()
job = JobOfferFactory(state=OfferState.ACTIVE)
self.assertEqual([job], self.get_context_data()['recent'])

def test_included_jobs_have_correct_fields(self):
JobFactory()
JobOfferFactory(state=OfferState.ACTIVE)
job = self.get_context_data()['recent'][0]
self.assertEqual(job.category, 'Trabajos')
# jobs already have 'created', 'title' and 'description' fields
Expand All @@ -55,7 +56,7 @@ def test_included_news_have_correct_fields(self):

# Independent of the Model type, all list items are sorted by their 'created' field
def test_items_are_sorted_by_the_created_field(self):
job = JobFactory(set_created='1985-10-26 09:00Z') # Middle-age ;-)
job = JobOfferFactory(state=OfferState.ACTIVE, set_created='1985-10-26 09:00Z') # Middle
event = EventFactory(start_at='1955-11-12 06:38Z') # Oldest
article = NewsArticleFactory(set_created='2015-10-21 09:00Z') # Most recent
# Assert the models are in chronological order
Expand All @@ -64,7 +65,7 @@ def test_items_are_sorted_by_the_created_field(self):
def test_recent_is_a_list_with_at_most_10_items(self):
# Create more than RECENT_ITEMS_LEN models and assert that only 10 are kept as recent
for i in range(RECENT_ITEMS_LEN):
JobFactory()
JobOfferFactory(state=OfferState.ACTIVE)
EventFactory()
NewsArticleFactory()
# The loop above creates RECENT_ITEMS_LEN * 3 items
Expand Down
16 changes: 9 additions & 7 deletions community/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.views.generic.list import MultipleObjectMixin
from django.utils.timezone import now
from events.models import Event
from jobs.models import Job
from joboffers.models import JobOffer, OfferState
from news.models import NewsArticle

RECENT_ITEMS_LEN = 10
Expand All @@ -26,23 +26,25 @@ class HomePageView(TemplateView):
template_name = "community/index.html"

def get_events_for_context(self):
"""Ensure events have 'category', created' and 'title' fields"""
"""Get events annotated for proper usage."""
events = Event.objects.filter(start_at__lt=now())
events = events.order_by('-start_at')
events = events.annotate(
created=F('start_at'),
title=F('name'),
category=Value('Eventos', output_field=CharField()))
return aux_qs_to_list_for_context(events)

def get_jobs_for_context(self):
"""Ensure jobs have a 'category' field"""
jobs = Job.objects.order_by('-created')
jobs = jobs.annotate(category=Value('Trabajos', output_field=CharField()))
"""Get jobs annotated for proper usage."""
jobs = JobOffer.objects.filter(state=OfferState.ACTIVE)
jobs = jobs.annotate(
category=Value('Trabajos', output_field=CharField()),
created=F('created_at'),
)
return aux_qs_to_list_for_context(jobs)

def get_news_for_context(self):
"""Ensure news have 'category' and 'description' fields"""
"""Get news annotated for proper usage."""
news = NewsArticle.objects.order_by('-created')
news = news.annotate(
description=F('body'),
Expand Down
12 changes: 9 additions & 3 deletions events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@

from autoslug import AutoSlugField

from jobs.models import JOB_SENIORITIES


GENDER_OPTIONS = (
('female', _('femenino')),
('male', _('masculino')),
('Otro', _('otro')),
)

JOB_SENIORITIES = (
('Trainee', 'Trainee'),
('Junior', 'Junior'),
('Semi Senior', 'Semi Senior'),
('Senior', 'Senior'),
('Guido', 'Soy Guido Van Rossum'),
)


class Event(models.Model):
"""A PyAr events."""
Expand Down Expand Up @@ -55,7 +61,7 @@ class EventParticipation(models.Model):
max_length=100,
blank=True,
default='',
choices=JOB_SENIORITIES + (('guido', _('Soy Guido Van Rossum')),),
choices=JOB_SENIORITIES,
verbose_name=_('experiencia')
)

Expand Down
87 changes: 0 additions & 87 deletions joboffers/migrations/0016_migrate_old_jobs.py

This file was deleted.

32 changes: 0 additions & 32 deletions joboffers/migrations/0017_migrate_old_jobs_tags.py

This file was deleted.

32 changes: 0 additions & 32 deletions joboffers/migrations/0018_migrate_old_job_comments.py

This file was deleted.

2 changes: 1 addition & 1 deletion joboffers/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def set_created(obj, create, extracted, **kwargs):

"""
if extracted:
obj.created = extracted
obj.created_at = extracted
obj.save()

@post_generation
Expand Down
Empty file removed jobs/__init__.py
Empty file.
6 changes: 0 additions & 6 deletions jobs/admin.py

This file was deleted.

Loading
Loading