Skip to content

Commit

Permalink
Solve minor bugs (#560)
Browse files Browse the repository at this point in the history
* Solve minor bugs

* Solve minor bugs

* Solve failing tests
  • Loading branch information
tzulberti committed Apr 13, 2023
1 parent 3dbf850 commit efd6ffe
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion joboffers/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def clean(self):
remoteness = cleaned_data.get('remoteness')
location = cleaned_data.get('location')

if remoteness == Remoteness.OFFICE and not location:
if remoteness in (Remoteness.OFFICE, Remoteness.HYBRID) and not location:
raise ValidationError(_('Debe especificar un lugar para modalidad prescencial.'))

class Meta:
Expand Down
6 changes: 3 additions & 3 deletions joboffers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re

from datetime import date
from urllib.parse import urlparse
from urllib.parse import urlparse, urljoin

from autoslug import AutoSlugField
from django.conf import settings
Expand Down Expand Up @@ -150,8 +150,8 @@ def get_full_url(self):
"""
Get the full url of the offer with domain and scheme prefix
"""
prefix = urlparse(settings.BASE_URL, scheme='https').geturl()
return f"{prefix}{self.get_absolute_url()}"
prefix = urlparse(f"https://{settings.BASE_URL}").geturl()
return urljoin(prefix, self.get_absolute_url())

def __str__(self):
return self.title
Expand Down
2 changes: 1 addition & 1 deletion joboffers/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def test_joboffer_get_full_url(settings):
dummy_job_slug = 'python-job'
settings.BASE_URL = dummy_url
joboffer_url = reverse('joboffers:view', kwargs={'slug': dummy_job_slug})
expected_url = "".join(('https:///example.com', joboffer_url))
expected_url = "".join(('https://example.com', joboffer_url))

joboffer = JobOffer(slug=dummy_job_slug)
result = joboffer.get_full_url()
Expand Down
6 changes: 3 additions & 3 deletions joboffers/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_joboffer_request_moderation_ok(publisher_client, user_company_profile,
assert len(telegram_history) == 1
sent_message = telegram_history[0]['text'][0]
assert sent_message.endswith(TELEGRAM_MODERATION_MESSAGE.format(
offer_url=joboffer.get_absolute_url()
offer_url=joboffer.get_full_url()
))


Expand Down Expand Up @@ -412,7 +412,7 @@ def test_joboffer_approve_ok(
assert len(telegram_history) == 1
sent_message = telegram_history[0]['text'][0]
assert sent_message.endswith(TELEGRAM_APPROVED_MESSAGE.format(
offer_url=joboffer.get_absolute_url(),
offer_url=joboffer.get_full_url(),
username=admin_user.username
))

Expand Down Expand Up @@ -490,7 +490,7 @@ def test_joboffer_reject_ok(admin_client, admin_user, user_company_profile, tele
sent_message = telegram_history[0]['text'][0]
assert sent_message.endswith(TELEGRAM_REJECT_MESSAGE.format(
offer_title=joboffer.title,
offer_url=joboffer.get_absolute_url(),
offer_url=joboffer.get_full_url(),
username=admin_user.username
))

Expand Down
6 changes: 3 additions & 3 deletions joboffers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def form_valid(self, form):
send_mail_to_publishers(offer, subject, body)

moderators_message = TELEGRAM_REJECT_MESSAGE.format(
offer_url=offer.get_absolute_url(),
offer_url=offer.get_full_url(),
username=user.username
)

Expand Down Expand Up @@ -306,7 +306,7 @@ def update_object(self, offer):
)

moderators_message = TELEGRAM_APPROVED_MESSAGE.format(
offer_url=offer.get_absolute_url(),
offer_url=offer.get_full_url(),
username=user.username
)

Expand Down Expand Up @@ -361,7 +361,7 @@ def update_object(self, offer):
offer.save()

moderators_message = TELEGRAM_MODERATION_MESSAGE.format(
offer_url=offer.get_absolute_url()
offer_url=offer.get_full_url()
)

send_notification_to_moderators(moderators_message)
Expand Down

0 comments on commit efd6ffe

Please sign in to comment.