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

Fix bug where selecting 'Remote' work type incorrectly sets 'Allows remote work' to NO (issue #589) #591

Merged
merged 2 commits into from
Dec 24, 2024
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
4 changes: 4 additions & 0 deletions joboffers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ def save(self, *args, **kwargs):

super().save(*args, **kwargs)

@property
def allows_remote_work(self):
return self.remoteness == Remoteness.REMOTE

@classmethod
def get_options(cls):
"""
Expand Down
2 changes: 1 addition & 1 deletion joboffers/templates/joboffers/joboffer_overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h4 class="mt-0">
</dd>
{% endif %}
<dt>Permite trabajar remoto</dt>
<dd>{% if obj.remote_work %}Si{% else %}No{% endif %}</dd>
<dd>{% if obj.allows_remote_work %}{% else %}No{% endif %}</dd>

<dt>Experiencia Requerida</dt>
<dd>{{ obj.get_experience_display }}</dd>
Expand Down
10 changes: 10 additions & 0 deletions pycompanies/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django import forms
from django_summernote.widgets import SummernoteInplaceWidget
from django.utils.translation import gettext_lazy as _
from urllib.parse import urlparse

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Div, ButtonHolder, Layout, Submit
Expand All @@ -12,6 +13,9 @@ class CompanyForm(forms.ModelForm):
"""A PyAr companies form."""

description = forms.CharField(widget=SummernoteInplaceWidget())
link = forms.CharField(
help_text=_('Por favor, ingrese una URL válida con esquema (por ejemplo, https://).')
)

def __init__(self, *args, **kwargs):
super(CompanyForm, self).__init__(*args, **kwargs)
Expand All @@ -28,6 +32,12 @@ def __init__(self, *args, **kwargs):
)
)

def clean_link(self):
link = self.cleaned_data.get('link')
if link and not urlparse(link).scheme:
link = f'https://{link}'
return link

class Meta:
fields = ['name', 'photo', 'link', 'description']
model = Company
Expand Down
Loading