19# created employee profile

This commit is contained in:
Eligiusz Kurzawa 2021-01-15 09:48:48 +01:00
parent 815c86a07c
commit 40406e00b7
5 changed files with 72 additions and 4 deletions

View File

@ -50,6 +50,7 @@ class SingleJobView(SuccessMessageMixin, UpdateView):
context['employee_applied'] = Job.objects.get(pk=self.kwargs['pk']).employee.all().filter(id=self.request.user.id)
try:
context['applied_employees'] = Job.objects.get(pk=self.kwargs['pk'], employer_id=self.request.user.id).employee.all()
context['employer_id'] = Job.objects.get(pk=self.kwargs['pk']).employer_id
except:
pass
return context

View File

@ -36,14 +36,14 @@
{% endif %}
</form>
{% if user.is_employer %}
{% if user.is_employer and user.id == employer_id %}
{% if applied_employees %}
<div class="list-group">
<button type="button" class="list-group-item list-group-item-action active" aria-current="true" style="text-align: center">
Applied candidates
</button>
{% for employee in applied_employees %}
<button type="button" class="list-group-item list-group-item-action">{{ employee.first_name }} {{ employee.last_name }}</button>
<a href="{% url 'users:employee_profile' pk=employee.pk %}" class="list-group-item list-group-item-action">{{ employee.first_name }} {{ employee.last_name }}</a>
{% endfor %}
</div>
{% else %}

View File

@ -0,0 +1,53 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}
<div class="hero-wrap js-fullheight" style="background-image: url('{% static 'images/bg_2.jpg' %}');" data-stellar-background-ratio="0.5"> <div class="overlay"></div>
<div class="container">
<div class="row no-gutters slider-text js-fullheight align-items-end justify-content-start" data-scrollax-parent="true">
<div class="col-md-8 ftco-animate text-center text-md-left mb-5" data-scrollax=" properties: { translateY: '70%' }">
<p class="breadcrumbs" data-scrollax="properties: { translateY: '30%', opacity: 1.6 }"><span class="mr-3"><a href="index.html">Home <i class="ion-ios-arrow-forward"></i></a></span> <span class="mr-3"><a href="blog.html">Blog <i class="ion-ios-arrow-forward"></i></a></span> <span>Single</span></p>
<h1 class="mb-3 bread" data-scrollax="properties: { translateY: '30%', opacity: 1.6 }">Job detail</h1>
</div>
</div>
</div>
</div>
<section class="ftco-section ftco-degree-bg">
<div class="container">
<div class="row">
<div class="col-md-8 ftco-animate" style="text-align: center">
<h2 class="mb-3">{{ account.first_name }} {{ account.last_name }}</h2>
<h5><img src="{{ profile.image.url }}"></h5>
<h5>{{ account.email }}</h5>
<h5>{{ profile.birth_day }}</h5>
<h5>{{ profile.location }}</h5>
<p>{{ profile.resume|safe }}</p>
<hr>
</div> <!-- .col-md-8 -->
<div class="col-md-4 sidebar ftco-animate">
<div class="sidebar-box">
<form action="#" class="search-form">
<div class="form-group">
<span class="icon icon-search"></span>
<input type="text" class="form-control" placeholder="Type a keyword and hit enter">
</div>
</form>
</div>
<div class="sidebar-box ftco-animate">
<div class="categories">
<h3>Categories</h3>
{% for category in categories %}
<li><a href="#">{{ category.title }} <span>{{ category.job_count }}</span></a></li>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</section> <!-- .section -->
{% endblock %}

View File

@ -7,4 +7,5 @@ urlpatterns = [
path('login/', UserLoginView.as_view(), name='login'),
path('logout/', UserLogoutView.as_view(), name='logout'),
path('update-profile/<int:pk>/', UserUpdateView.as_view(), name='update_profile'),
path('employee-profile/<int:pk>/', EmployeeProfileView.as_view(), name='employee_profile'),
]

View File

@ -5,10 +5,11 @@ from django.http import HttpResponseRedirect
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.views.generic import CreateView, UpdateView
from django.views.generic import CreateView, UpdateView, DetailView
from jobs.models import Category
from users.forms import AccountRegisterForm, UserUpdateForm
from users.models import Profile
from users.models import Profile, Account
class UserRegisterView(SuccessMessageMixin, CreateView):
@ -57,3 +58,15 @@ class UserUpdateView(SuccessMessageMixin, UpdateView):
def get_success_url(self):
return reverse('users: update_profile', kwargs={'pk': self.object.pk})
class EmployeeProfileView(DetailView):
template_name = 'users/employee-profile.html'
model = Account
def get_context_data(self, **kwargs):
context = super(EmployeeProfileView, self).get_context_data(**kwargs)
context['account'] = Account.objects.get(pk=self.kwargs['pk'])
context['profile'] = Profile.objects.get(user_id=self.kwargs['pk'])
context['categories'] = Category.objects.all()
return context