Skip to content

Commit 415c336

Browse files
germanpskalanuxIanPuchetti
authored
61 agregar un link que vaya a la página de administración de ofertas (#549)
* Added pytest as a runner * Added pytest as a runner on Makefile * Added joboffers app * Some fixes to the JobOffer model * Added initial joboffer detail * Added initial job offer add form * Changed joboffer's urls to use their namespace * Added some basic pytest's fixtures * Updated JobOffer's factory to include all the needed fields * Added joboffer creation test * Added joboffer admin page * Moved add button to bottom of the page (joboffers) * Added search button in admin page (joboffers) * Added joboffer edit view * Changed joboffer's choices to their long version * Added link to joboffers admin page and company association to logged users. * Added missing template file Co-authored-by: Juan Manuel Schillaci <[email protected]> Co-authored-by: Ian Puchetti <[email protected]>
1 parent 5659a92 commit 415c336

File tree

9 files changed

+154
-66
lines changed

9 files changed

+154
-66
lines changed

joboffers/templates/joboffers/_tags_filtering_form.html

Lines changed: 0 additions & 41 deletions
This file was deleted.

joboffers/templates/joboffers/joboffer_list.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,9 @@ <h4>
4545
{% endblock %}
4646

4747
{% block right-column %}
48-
{% include "joboffers/_tags_filtering_form.html" %}
48+
{% if user.is_authenticated %}
49+
{% include "companies/_user_actions.html" %}
50+
{% endif %}
51+
52+
{% include "_tags_filtering_form.html" %}
4953
{% endblock %}

joboffers/tests/test_views.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,54 @@ def test_JobOfferHistoryView_renders_with_context(
729729
]
730730

731731

732+
@pytest.mark.django_db
733+
def test_joboffer_list_view_includes_user_and_own_company_for_publisher(publisher_client):
734+
"""
735+
Test that the joboffer list view includes user and own_company in the companies for a publisher
736+
"""
737+
client = publisher_client
738+
JobOfferFactory.create(state=OfferState.ACTIVE)
739+
740+
target_url = reverse(LIST_URL)
741+
742+
response = client.get(target_url)
743+
744+
assert response.context_data['user'].is_authenticated
745+
assert response.context_data['own_company']
746+
747+
748+
@pytest.mark.django_db
749+
def test_joboffer_list_view_includes_user_and_own_company_for_user_without_company(logged_client):
750+
"""
751+
Test that the joboffer list view includes user and own_company in the companies for user
752+
without company
753+
"""
754+
client = logged_client
755+
JobOfferFactory.create(state=OfferState.ACTIVE)
756+
757+
target_url = reverse(LIST_URL)
758+
759+
response = client.get(target_url)
760+
761+
assert response.context_data['user'].is_authenticated
762+
assert 'own_company' not in response.context_data
763+
764+
765+
@pytest.mark.django_db
766+
def test_joboffer_list_view_includes_user_and_own_company_for_unlogged_user(client):
767+
"""
768+
Test that the joboffer list view includes user and own_company for anonymous user
769+
"""
770+
JobOfferFactory.create(state=OfferState.ACTIVE)
771+
772+
target_url = reverse(LIST_URL)
773+
774+
response = client.get(target_url)
775+
776+
assert response.context_data['user'].is_anonymous
777+
assert 'own_company' not in response.context_data
778+
779+
732780
@pytest.mark.django_db
733781
def test_joboffer_list_view_render_list_with_an_active_joboffer(publisher_client):
734782
"""

joboffers/views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ def get_context_data(self, **kwargs):
429429
if self.request.GET.get('search'):
430430
context['search'] = self.request.GET.get('search')
431431

432+
context['user'] = self.request.user
433+
434+
user_company = UserCompanyProfile.objects.for_user(user=self.request.user)
435+
if user_company:
436+
context['own_company'] = user_company.company
437+
432438
self.context = context
433439

434440
return context

pycompanies/tests/test_views.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
USER_ASSOCIATED_CORRECTLY = 'Le usuarie fue asociade correctamente.'
1818

1919
ADMIN_URL = reverse('companies:admin')
20+
COMPANY_LIST_URL = reverse('companies:company_list_all')
2021

2122

2223
def get_plain_messages(request):
@@ -375,3 +376,42 @@ def test_get_user_display_name_with_first_name_and_last_name():
375376
actual_name = get_user_display_name(user)
376377

377378
assert actual_name == f"{user.first_name} {user.last_name}"
379+
380+
381+
@pytest.mark.django_db
382+
def test_company_list_view_includes_user_and_own_company_for_publisher(publisher_client):
383+
"""
384+
Test that the company list view includes user and own_company in the companies for a publisher
385+
"""
386+
client = publisher_client
387+
388+
response = client.get(COMPANY_LIST_URL)
389+
390+
assert response.context_data['user'].is_authenticated
391+
assert 'own_company' in response.context_data
392+
393+
394+
@pytest.mark.django_db
395+
def test_company_list_view_includes_user_and_own_company_for_user_without_company(logged_client):
396+
"""
397+
Test that the company list view includes user and own_company in the companies for user
398+
without company
399+
"""
400+
client = logged_client
401+
402+
response = client.get(COMPANY_LIST_URL)
403+
404+
assert response.context_data['user'].is_authenticated
405+
assert 'own_company' not in response.context_data
406+
407+
408+
@pytest.mark.django_db
409+
def test_company_list_view_includes_user_and_own_company_for_unlogged_user(client):
410+
"""
411+
Test that the company list view includes user and own_company for anonymous user
412+
"""
413+
414+
response = client.get(COMPANY_LIST_URL)
415+
416+
assert response.context_data['user'].is_anonymous
417+
assert 'own_company' not in response.context_data

pycompanies/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def get_queryset(self):
4848

4949
def get_context_data(self, **kwargs):
5050
context = super().get_context_data(**kwargs)
51+
52+
context['user'] = self.request.user
53+
5154
user_company = UserCompanyProfile.objects.for_user(user=self.request.user)
5255
if self.request.user.is_anonymous is False and user_company:
5356
context['own_company'] = user_company.company

static/css/styles.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,14 @@ div.sponsored_jobs {
659659
background-color: #33681e;
660660
border-color: #558b2f;
661661
}
662+
663+
.my-actions .list-group-item {
664+
background-color: #F6DDCC;
665+
color: ;
666+
}
667+
668+
.my-actions .list-group-item-heading {
669+
display: flex;
670+
align-items: center;
671+
justify-content: space-between;
672+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{% load i18n %}
2+
<div class="list-group my-actions">
3+
{% if own_company %}
4+
<div class="list-group-item">
5+
<div class="h4 list-group-item-heading flex-center">
6+
<span>{{ own_company.name }}</span>
7+
<span class="pull-right">
8+
<i class="fa fa-building" style="font-size: 1.5em;"></i>
9+
</span>
10+
</div>
11+
</div>
12+
13+
<div class="list-group-item">
14+
<a href="{% url 'joboffers:admin' %}" class="btn btn-default">
15+
{% trans 'Administrar Ofertas' %}
16+
</a>
17+
<a href="{% url 'companies:analytics' own_company.id %}" class="btn btn-dark-green">
18+
{% trans 'Analítica de Ofertas' %}
19+
</a>
20+
</div>
21+
{% else %}
22+
<div class="list-group-item">
23+
<div class="h4 list-group-item-heading flex-center">
24+
<span>{{ user.username }}</span>
25+
<span class="pull-right">
26+
<i class="fa fa-user" style="font-size: 1.5em;"></i>
27+
</span>
28+
</div>
29+
</div>
30+
<div class="list-group-item">
31+
<a href="{% url 'companies:admin' %}" class="btn btn-default btn-md">
32+
{% trans 'Asociarme a Empresa' %}
33+
</a>
34+
</div>
35+
{% endif %}
36+
</div>

templates/companies/company_list.html

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,11 @@ <h3>
3737
{% endblock %}
3838

3939
{% block right-column %}
40-
<section class="list-group">
41-
<header class="list-group-item">
42-
<h4 class="list-group-item-heading" style="color: #35679a;">
43-
{% if own_company %}
44-
{% trans 'Estás asociade a la empresa' %}
45-
<span style="color:#428bca;">{{own_company}}</span>
46-
{% else %}
47-
{% trans 'No estás asociade a ninguna empresa' %}
48-
{% endif %}
49-
</h4>
50-
</header>
51-
<article class="list-group-item">
52-
{% if own_company %}
53-
<a href="{% url 'companies:admin' %}" class="btn btn-default btn-md">
54-
{% trans 'Administrar ' %}
55-
</a>
56-
{% else %}
57-
<a href="{% url 'companies:association_list' %}" class="btn btn-default btn-md">
58-
{% trans 'Administrar' %}
59-
</a>
60-
{% endif %}
61-
<div class="clearfix"></div>
62-
</article>
63-
</section>
40+
{% if user.is_authenticated %}
41+
{% include "companies/_user_actions.html" %}
42+
{% endif %}
43+
6444
{{ block.super }}
45+
6546
{% include "_tags_filtering_form.html" %}
6647
{% endblock %}

0 commit comments

Comments
 (0)