diff --git a/jobs/views.py b/jobs/views.py index 5c24935..c03081e 100644 --- a/jobs/views.py +++ b/jobs/views.py @@ -25,6 +25,9 @@ class HomeView(ListView): context['candidates'] = Account.objects.filter(is_employee=True).count() context['resumes'] = Profile.objects.exclude(resume="").count() context['employers'] = Account.objects.filter(is_employer=True).count() + if self.request.user.is_authenticated: + context['wish_list'] = Job.objects.filter(wish_list__user_id=self.request.user.id).values_list('id', flat=True) + return context diff --git a/templates/base.html b/templates/base.html index 5f57707..76f19b8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -58,7 +58,7 @@
- Apply Job - - - + Apply Job - - - + {% if job.id in wish_list %} + + + + {% else %} + + + + {% endif %}
@@ -482,6 +485,7 @@ url:"/users/add-wishlist/" + id, method:"GET", success:function () { + $('#jobwl' + id).removeClass('btn-primary').addClass('btn-danger') alert("Success") } }); @@ -494,6 +498,7 @@ url:"/users/remove-from-wishlist/" + id, method:"GET", success:function () { + $('#jobwl' + id).removeClass('btn-danger').addClass('btn-primary') alert("Success") } }); diff --git a/templates/users/my-wish-list.html b/templates/users/my-wish-list.html new file mode 100644 index 0000000..dd492bd --- /dev/null +++ b/templates/users/my-wish-list.html @@ -0,0 +1,257 @@ +{% extends 'base.html' %} +{% load static %} +{% block content %} + +
+
+
+
+
+

We have 0 great job offers you deserve!

+

Your Dream
Job is Waiting

+ + +
+
+
+
+ + +
+
+ {% if user.is_employee %} + {% if jobs %} +
+
+ Recently Added Jobs +

My wishlist

+
+
+
+ {% for job in jobs %} +
+
+ +
+
+

{{ job.title }}

+
+ {% if job.job_type == 'full_time' %} + Full Time + {% elif job.job_type == 'part_time'%} + Part Time + {% elif job.job_type == 'freelance'%} + Freelance + {% elif job.job_type == 'internship'%} + Internship + {% elif job.job_type == 'temporary'%} + Temporary + {% endif %} +
+
+
+ +
{{ job.location }}
+
+
+ +
+ Apply Job + + {% if job.id in wish_list %} + + + + {% else %} + + + + {% endif %} +
+
+
+ {% endfor %} + {% else %} +
+
+

Your wishlist is empty!

+
+
+ {% endif %} + {% else %} +
+
+ Recently Added Jobs +

Your are not an employee!

+
+
+ {% endif %} +
+
+ {% if is_paginated %} +
+
+
    + {% if page_obj.has_previous %} +
  • <
  • + {% else %} +
  • <
  • + {% endif %} + {% for i in paginator.page_range %} + {% if page_obj.number == i %} +
  • {{ i }}
  • + {% else %} +
  • {{ i }}
  • + {% endif %} + {% endfor %} + {% if page_obj.has_next %} +
  • >
  • + {% else %} +
  • >
  • + {% endif %} +
+
+
+ {% endif %} +
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/users/urls.py b/users/urls.py index 1bff95e..d035e58 100644 --- a/users/urls.py +++ b/users/urls.py @@ -13,4 +13,5 @@ urlpatterns = [ path('employee-display-messages//', EmployeeDisplayMessages.as_view(), name='employer_display_messages'), path('add-wishlist//', AddWishListView.as_view(), name='add_wishlist'), path('remove-from-wishlist//', RemoveFromWishListView.as_view(), name='remove_from_wishlist'), + path('mywishlist//', MyWishList.as_view(), name='my_wish_list'), ] diff --git a/users/views.py b/users/views.py index 699ea25..b1377a8 100644 --- a/users/views.py +++ b/users/views.py @@ -151,3 +151,21 @@ class RemoveFromWishListView(UpdateView): return redirect('jobs:home') else: return redirect('jobs:home') + + +class MyWishList(ListView): + template_name = 'users/my-wish-list.html' + context_object_name = 'jobs' + model = Job + paginate_by = 5 + + def get_queryset(self): + return Job.objects.filter(wish_list__user_id=self.request.user.id) + + def get_context_data(self, **kwargs): + context = super(MyWishList, self).get_context_data(**kwargs) + if self.request.user.is_authenticated: + context['wish_list'] = Job.objects.filter(wish_list__user_id=self.request.user.id).values_list('id', + flat=True) + + return context