34# created wish list buttons for detail page
This commit is contained in:
parent
b9f93a6dc5
commit
f75b316e43
@ -57,6 +57,7 @@ class SingleJobView(SuccessMessageMixin, UpdateView):
|
|||||||
context = super(SingleJobView, self).get_context_data(**kwargs)
|
context = super(SingleJobView, self).get_context_data(**kwargs)
|
||||||
context['categories'] = Category.objects.all()
|
context['categories'] = Category.objects.all()
|
||||||
context['employee_applied'] = Job.objects.get(pk=self.kwargs['pk']).employee.all().filter(id=self.request.user.id)
|
context['employee_applied'] = Job.objects.get(pk=self.kwargs['pk']).employee.all().filter(id=self.request.user.id)
|
||||||
|
context['in_my_list'] = Job.objects.get(pk=self.kwargs['pk']).wish_list.all().filter(user_id=self.request.user.id)
|
||||||
try:
|
try:
|
||||||
context['applied_employees'] = Job.objects.get(pk=self.kwargs['pk'], employer_id=self.request.user.id).employee.all()
|
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
|
context['employer_id'] = Job.objects.get(pk=self.kwargs['pk']).employer_id
|
||||||
|
56
static/js/addorremove.js
Normal file
56
static/js/addorremove.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
function addorremove(id) {
|
||||||
|
if (id){
|
||||||
|
var wishlist = $('#jobwl' + id).data('wl');
|
||||||
|
if(wishlist == 0) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/users/add-wishlist/" + id,
|
||||||
|
method: "GET",
|
||||||
|
success: function () {
|
||||||
|
$('#jobwl' + id).removeClass('btn-primary').addClass('btn-danger')
|
||||||
|
const Toast = Swal.mixin({
|
||||||
|
toast: true,
|
||||||
|
position: 'top',
|
||||||
|
showConfirmButton: true,
|
||||||
|
timer: 3000,
|
||||||
|
timerProgressBar: true,
|
||||||
|
didOpen: (toast) => {
|
||||||
|
toast.addEventListener('mouseenter', Swal.stopTimer)
|
||||||
|
toast.addEventListener('mouseleave', Swal.resumeTimer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
Toast.fire({
|
||||||
|
icon: 'success',
|
||||||
|
title: 'Added'
|
||||||
|
})
|
||||||
|
$('#jobwl' + id).data('wl', 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$.ajax({
|
||||||
|
url:"/users/remove-from-wishlist/" + id,
|
||||||
|
method:"GET",
|
||||||
|
success:function () {
|
||||||
|
$('#jobwl' + id).removeClass('btn-danger').addClass('btn-primary')
|
||||||
|
const Toast = Swal.mixin({
|
||||||
|
toast: true,
|
||||||
|
position: 'top',
|
||||||
|
showConfirmButton: true,
|
||||||
|
timer: 3000,
|
||||||
|
timerProgressBar: true,
|
||||||
|
didOpen: (toast) => {
|
||||||
|
toast.addEventListener('mouseenter', Swal.stopTimer)
|
||||||
|
toast.addEventListener('mouseleave', Swal.resumeTimer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
Toast.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Removed'
|
||||||
|
})
|
||||||
|
$('#jobwl' + id).data('wl', 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
static/js/addorremovenotauth.js
Normal file
24
static/js/addorremovenotauth.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
function addorremove(id) {
|
||||||
|
if (id){
|
||||||
|
$.ajax({
|
||||||
|
success:function () {
|
||||||
|
const Toast = Swal.mixin({
|
||||||
|
toast: true,
|
||||||
|
position: 'top',
|
||||||
|
showConfirmButton: true,
|
||||||
|
timer: 3000,
|
||||||
|
timerProgressBar: true,
|
||||||
|
didOpen: (toast) => {
|
||||||
|
toast.addEventListener('mouseenter', Swal.stopTimer)
|
||||||
|
toast.addEventListener('mouseleave', Swal.resumeTimer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
Toast.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'You are not an employee!'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -202,13 +202,12 @@
|
|||||||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBVWaKrjvy3MaE7SQ74_uJiULgl1JY0H2s&sensor=false"></script>
|
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBVWaKrjvy3MaE7SQ74_uJiULgl1JY0H2s&sensor=false"></script>
|
||||||
<script src="{% static "js/google-map.js" %}"></script>
|
<script src="{% static "js/google-map.js" %}"></script>
|
||||||
<script src="{% static "js/main.js" %}"></script>
|
<script src="{% static "js/main.js" %}"></script>
|
||||||
|
<script src="{% static "js/main.js" %}"></script>
|
||||||
{% if user.is_authenticated and user.is_employee %}
|
{% if user.is_authenticated and user.is_employee %}
|
||||||
<script src="{% static "js/addorremove.js" %}"></script>
|
<script src="{% static "js/addorremove.js" %}"></script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<script src="{% static "js/addorremove2.js" %}"></script>
|
<script src="{% static "js/addorremovenotauth.js" %}"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -478,91 +478,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% if user.is_authenticated and user.is_employee%}
|
|
||||||
<script type="text/javascript">
|
|
||||||
function addorremove(id) {
|
|
||||||
if (id){
|
|
||||||
var wishlist = $('#jobwl' + id).data('wl');
|
|
||||||
if(wishlist == 0) {
|
|
||||||
$.ajax({
|
|
||||||
url: "/users/add-wishlist/" + id,
|
|
||||||
method: "GET",
|
|
||||||
success: function () {
|
|
||||||
$('#jobwl' + id).removeClass('btn-primary').addClass('btn-danger')
|
|
||||||
const Toast = Swal.mixin({
|
|
||||||
toast: true,
|
|
||||||
position: 'top',
|
|
||||||
showConfirmButton: true,
|
|
||||||
timer: 3000,
|
|
||||||
timerProgressBar: true,
|
|
||||||
didOpen: (toast) => {
|
|
||||||
toast.addEventListener('mouseenter', Swal.stopTimer)
|
|
||||||
toast.addEventListener('mouseleave', Swal.resumeTimer)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Toast.fire({
|
|
||||||
icon: 'success',
|
|
||||||
title: 'Added'
|
|
||||||
})
|
|
||||||
$('#jobwl' + id).data('wl', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
$.ajax({
|
|
||||||
url:"/users/remove-from-wishlist/" + id,
|
|
||||||
method:"GET",
|
|
||||||
success:function () {
|
|
||||||
$('#jobwl' + id).removeClass('btn-danger').addClass('btn-primary')
|
|
||||||
const Toast = Swal.mixin({
|
|
||||||
toast: true,
|
|
||||||
position: 'top',
|
|
||||||
showConfirmButton: true,
|
|
||||||
timer: 3000,
|
|
||||||
timerProgressBar: true,
|
|
||||||
didOpen: (toast) => {
|
|
||||||
toast.addEventListener('mouseenter', Swal.stopTimer)
|
|
||||||
toast.addEventListener('mouseleave', Swal.resumeTimer)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Toast.fire({
|
|
||||||
icon: 'error',
|
|
||||||
title: 'Removed'
|
|
||||||
})
|
|
||||||
$('#jobwl' + id).data('wl', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% else %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
function addtomywishlist(id) {
|
|
||||||
if (id){
|
|
||||||
$.ajax({
|
|
||||||
success:function () {
|
|
||||||
const Toast = Swal.mixin({
|
|
||||||
toast: true,
|
|
||||||
position: 'top',
|
|
||||||
showConfirmButton: true,
|
|
||||||
timer: 3000,
|
|
||||||
timerProgressBar: true,
|
|
||||||
didOpen: (toast) => {
|
|
||||||
toast.addEventListener('mouseenter', Swal.stopTimer)
|
|
||||||
toast.addEventListener('mouseleave', Swal.resumeTimer)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Toast.fire({
|
|
||||||
icon: 'error',
|
|
||||||
title: 'You are not an employee!'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -28,9 +28,15 @@
|
|||||||
<input type="submit" value="Apply" class="btn btn-primary py-2 mr-1" disabled title="You have already applied.">
|
<input type="submit" value="Apply" class="btn btn-primary py-2 mr-1" disabled title="You have already applied.">
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="submit" value="Apply" class="btn btn-primary py-2 mr-1">
|
<input type="submit" value="Apply" class="btn btn-primary py-2 mr-1">
|
||||||
<a href="#" class="btn btn-danger rounded-circle btn-favorite d-flex align-items-center">
|
{% if in_my_list %}
|
||||||
<span class="icon-heart"></span>
|
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Remove from my wish list" onclick="addorremove({{ job.id }})" class="btn btn-danger rounded-circle btn-favorite d-flex align-items-center">
|
||||||
</a>
|
<span class="icon-heart"></span>
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Add to my wish list" onclick="addorremove({{ job.id }})" class="btn btn-primary rounded-circle btn-favorite d-flex align-items-center">
|
||||||
|
<span class="icon-heart"></span>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -168,11 +168,11 @@
|
|||||||
<a href="{% url 'jobs:single_job' job.slug job.pk %}" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
<a href="{% url 'jobs:single_job' job.slug job.pk %}" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||||
|
|
||||||
{% if job.id in wish_list %}
|
{% if job.id in wish_list %}
|
||||||
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Remove from my wish list" onclick="removefrommywishlist({{ job.id }})" class="btn btn-danger rounded-circle btn-favorite d-flex align-items-center">
|
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Remove from my wish list" onclick="addorremove({{ job.id }})" class="btn btn-danger rounded-circle btn-favorite d-flex align-items-center">
|
||||||
<span class="icon-heart"></span>
|
<span class="icon-heart"></span>
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Add to my wish list" onclick="addtomywishlist({{ job.id }})" class="btn btn-primary rounded-circle btn-favorite d-flex align-items-center">
|
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Add to my wish list" onclick="addorremove({{ job.id }})" class="btn btn-primary rounded-circle btn-favorite d-flex align-items-center">
|
||||||
<span class="icon-heart"></span>
|
<span class="icon-heart"></span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -196,62 +196,36 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row mt-5">
|
{% if user.is_authenticated %}
|
||||||
{% if is_paginated %}
|
<div class="row mt-5">
|
||||||
<div class="col text-center">
|
{% if is_paginated %}
|
||||||
<div class="block-27">
|
<div class="col text-center">
|
||||||
<ul>
|
<div class="block-27">
|
||||||
{% if page_obj.has_previous %}
|
<ul>
|
||||||
<li><a href="?page={{ page_obj.previous_page_number }}"><</a></li>
|
{% if page_obj.has_previous %}
|
||||||
{% else %}
|
<li><a href="?page={{ page_obj.previous_page_number }}"><</a></li>
|
||||||
<li class="disabled"><span><</span></li>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in paginator.page_range %}
|
|
||||||
{% if page_obj.number == i %}
|
|
||||||
<li class="active"><span>{{ i }}</span></li>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href="?page={{ i }}">{{ i }}</a></li>
|
<li class="disabled"><span><</span></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% for i in paginator.page_range %}
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.number == i %}
|
||||||
<li><a href="?page={{ page_obj.next_page_number }}">></a></li>
|
<li class="active"><span>{{ i }}</span></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="disabled"><span>></span></li>
|
<li><a href="?page={{ i }}">{{ i }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
{% endfor %}
|
||||||
</div>
|
{% if page_obj.has_next %}
|
||||||
</div>
|
<li><a href="?page={{ page_obj.next_page_number }}">></a></li>
|
||||||
|
{% else %}
|
||||||
|
<li class="disabled"><span>></span></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function addtomywishlist(id) {
|
|
||||||
if (id){
|
|
||||||
$.ajax({
|
|
||||||
url:"/users/add-wishlist/" + id,
|
|
||||||
method:"GET",
|
|
||||||
success:function () {
|
|
||||||
$('#jobwl' + id).removeClass('btn-primary').addClass('btn-danger')
|
|
||||||
alert("Success")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function removefrommywishlist(id) {
|
|
||||||
if (id){
|
|
||||||
$.ajax({
|
|
||||||
url:"/users/remove-from-wishlist/" + id,
|
|
||||||
method:"GET",
|
|
||||||
success:function () {
|
|
||||||
$('#jobwl' + id).removeClass('btn-danger').addClass('btn-primary')
|
|
||||||
alert("Success")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user