30# created views for wishlist
This commit is contained in:
parent
e034fbd20a
commit
0da729e1fc
@ -482,7 +482,7 @@
|
|||||||
url:"/users/add-wishlist/" + id,
|
url:"/users/add-wishlist/" + id,
|
||||||
method:"GET",
|
method:"GET",
|
||||||
success:function () {
|
success:function () {
|
||||||
alert("success")
|
alert("Success")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -494,7 +494,7 @@
|
|||||||
url:"/users/remove-from-wishlist/" + id,
|
url:"/users/remove-from-wishlist/" + id,
|
||||||
method:"GET",
|
method:"GET",
|
||||||
success:function () {
|
success:function () {
|
||||||
alert("success")
|
alert("Success")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,6 @@ urlpatterns = [
|
|||||||
path('employer-jobs/', EmployerPostedJobsView.as_view(), name='employer_jobs'),
|
path('employer-jobs/', EmployerPostedJobsView.as_view(), name='employer_jobs'),
|
||||||
path('employee-messages/<int:pk>/', EmployeeMessagesView.as_view(), name='employer_messages'),
|
path('employee-messages/<int:pk>/', EmployeeMessagesView.as_view(), name='employer_messages'),
|
||||||
path('employee-display-messages/<int:pk>/', EmployeeDisplayMessages.as_view(), name='employer_display_messages'),
|
path('employee-display-messages/<int:pk>/', EmployeeDisplayMessages.as_view(), name='employer_display_messages'),
|
||||||
path('add-wishlist/<int:pk>/', EmployeeDisplayMessages.as_view(), name='employer_display_messages'),
|
path('add-wishlist/<int:pk>/', AddWishListView.as_view(), name='add_wishlist'),
|
||||||
|
path('remove-from-wishlist/<int:pk>/', RemoveFromWishListView.as_view(), name='remove_from_wishlist'),
|
||||||
]
|
]
|
||||||
|
@ -121,3 +121,33 @@ class EmployeeDisplayMessages(DetailView):
|
|||||||
if self.object.user != request.user:
|
if self.object.user != request.user:
|
||||||
return HttpResponseRedirect('/')
|
return HttpResponseRedirect('/')
|
||||||
return super(EmployeeDisplayMessages, self).get(request, *args, **kwargs)
|
return super(EmployeeDisplayMessages, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(login_required(login_url='/users/login'), name='dispatch')
|
||||||
|
class AddWishListView(UpdateView):
|
||||||
|
template_name = 'jobs/index.html'
|
||||||
|
model = Profile
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
if self.request.user.is_employee:
|
||||||
|
job = Job.objects.get(id=self.kwargs['pk'])
|
||||||
|
profile = Profile.objects.get(user=request.user)
|
||||||
|
profile.wish_list.add(job)
|
||||||
|
return redirect('jobs:home')
|
||||||
|
else:
|
||||||
|
return redirect('jobs:home')
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(login_required(login_url='/users/login'), name='dispatch')
|
||||||
|
class RemoveFromWishListView(UpdateView):
|
||||||
|
template_name = 'jobs/index.html'
|
||||||
|
model = Profile
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
if self.request.user.is_employee:
|
||||||
|
job = Job.objects.get(id=self.kwargs['pk'])
|
||||||
|
profile = Profile.objects.get(user=request.user)
|
||||||
|
profile.wish_list.remove(job)
|
||||||
|
return redirect('jobs:home')
|
||||||
|
else:
|
||||||
|
return redirect('jobs:home')
|
||||||
|
Loading…
Reference in New Issue
Block a user