Skip to content

Commit

Permalink
some bugs was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sany07 committed Jul 7, 2020
1 parent 9213e12 commit 08fe631
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 54 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn job.wsgi
Binary file modified account/__pycache__/views.cpython-37.pyc
Binary file not shown.
11 changes: 7 additions & 4 deletions account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,15 @@ def clean(self, *args, **kwargs):

if email and password:
self.user = authenticate(email=email, password=password)

if self.user is None:
try:
user = User.objects.get(email=email)
except User.DoesNotExist:
raise forms.ValidationError("User Does Not Exist.")
if not self.user.check_password(password):

if not user.check_password(password):
raise forms.ValidationError("Password Does not Match.")
if not self.user.is_active:

if not user.is_active:
raise forms.ValidationError("User is not Active.")

return super(UserLoginForm, self).clean(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def employer_registration(request):
def employee_edit_profile(request, id=id):

"""
Handle Employee Profile Update
Handle Employee Profile Update Functionality
"""

Expand Down
17 changes: 14 additions & 3 deletions job/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import os
import django_heroku

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -25,7 +26,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['djobportal.herokuapp.com']


# Application definition
Expand Down Expand Up @@ -53,6 +54,8 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',

'whitenoise.middleware.WhiteNoiseMiddleware',
]

ROOT_URLCONF = 'job.urls'
Expand Down Expand Up @@ -132,7 +135,7 @@
os.path.join(BASE_DIR, "static"),
]

STATIC_ROOT = os.path.join(BASE_DIR,'assets')
STATIC_ROOT = os.path.join(BASE_DIR,'staticfiles')

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
Expand All @@ -157,4 +160,12 @@
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning',
messages.ERROR: 'alert-danger',
}
}


# Activate Django-Heroku.
django_heroku.settings(locals())


STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

Binary file modified jobapp/__pycache__/models.cpython-37.pyc
Binary file not shown.
Binary file modified jobapp/__pycache__/views.cpython-37.pyc
Binary file not shown.
8 changes: 2 additions & 6 deletions jobapp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, *args, **kwargs):
self.fields['salary'].label = "Salary :"
self.fields['description'].label = "Job Description :"
self.fields['tags'].label = "Tags :"
self.fields['last_date'].label = "Dead Line :"
self.fields['last_date'].label = "Submission Deadline :"
self.fields['company_name'].label = "Company Name :"
self.fields['url'].label = "Website :"

Expand Down Expand Up @@ -46,6 +46,7 @@ def __init__(self, *args, **kwargs):
self.fields['last_date'].widget.attrs.update(
{
'placeholder': 'YYYY-MM-DD ',

}
)
self.fields['company_name'].widget.attrs.update(
Expand All @@ -59,11 +60,6 @@ def __init__(self, *args, **kwargs):
}
)


last_date = forms.CharField(widget=forms.TextInput(attrs={
'placeholder': 'Service Name',
'class' : 'datetimepicker1'
}))

class Meta:
model = Job
Expand Down
4 changes: 4 additions & 0 deletions jobapp/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models
from django.contrib.auth import get_user_model
from django.urls import reverse
User = get_user_model()


Expand Down Expand Up @@ -40,6 +41,7 @@ class Job(models.Model):
def __str__(self):
return self.title



class Applicant(models.Model):

Expand All @@ -52,6 +54,8 @@ def __str__(self):
return self.job.title




class BookmarkJob(models.Model):

user = models.ForeignKey(User, on_delete=models.CASCADE)
Expand Down
60 changes: 35 additions & 25 deletions jobapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ def search_result_view(request):
job_title_or_company_name = request.GET['job_title_or_company_name']

if job_title_or_company_name:
job_list = job_list.filter(title__icontains=job_title_or_company_name) | job_list.filter(company_name__icontains=job_title_or_company_name)

job_list = job_list.filter(title__icontains=job_title_or_company_name) | job_list.filter(
company_name__icontains=job_title_or_company_name)

# location
if 'location' in request.GET:
location = request.GET['location']
Expand All @@ -131,7 +132,6 @@ def search_result_view(request):
if job_type:
job_list = job_list.filter(job_type__iexact=job_type)


# job_title_or_company_name = request.GET.get('text')
# location = request.GET.get('location')
# job_type = request.GET.get('type')
Expand All @@ -143,6 +143,8 @@ def search_result_view(request):
# Q(location__icontains=location)
# ).distinct()

# job_list = Job.objects.filter(job_type__iexact=job_type) | Job.objects.filter(
# location__icontains=location) | Job.objects.filter(title__icontains=text) | Job.objects.filter(company_name__icontains=text)

paginator = Paginator(job_list, 10)
page_number = request.GET.get('page')
Expand Down Expand Up @@ -173,7 +175,8 @@ def apply_job_view(request, id):
instance.user = user
instance.save()

messages.success(request, 'You have successfully applied for this job!')
messages.success(
request, 'You have successfully applied for this job!')
return redirect(reverse("jobapp:single-job", kwargs={
'id': id
}))
Expand Down Expand Up @@ -202,18 +205,24 @@ def dashboard_view(request):
"""
jobs = []
savedjobs = []
total_applicants = {}
if request.user.role == 'employer':

jobs = Job.objects.filter(user=request.user.id)
print('1')
for job in jobs:
count = Applicant.objects.filter(job=job.id).count()
total_applicants[job.id] = count

else:
if request.user.role == 'employee':
savedjobs = BookmarkJob.objects.filter(user=request.user.id)
context = {

'jobs': jobs,
'savedjobs': savedjobs
'savedjobs': savedjobs,
'total_applicants': total_applicants
}

print(context)
return render(request, 'jobapp/dashboard.html', context)


Expand All @@ -227,20 +236,6 @@ def delete_job_view(request, id):

job.delete()
messages.success(request, 'Your Job Post was successfully deleted!')

return redirect('jobapp:dashboard')


@login_required(login_url=reverse_lazy('account:login'))
@user_is_employee
def delete_bookmark_view(request, id):

job = get_object_or_404(BookmarkJob, id=id, user=request.user.id)

if job:

job.delete()
messages.success(request, 'Saved Job was successfully deleted!')

return redirect('jobapp:dashboard')

Expand All @@ -259,6 +254,20 @@ def all_applicants_view(request, id):
return render(request, 'jobapp/all-applicants.html', context)


@login_required(login_url=reverse_lazy('account:login'))
@user_is_employee
def delete_bookmark_view(request, id):

job = get_object_or_404(BookmarkJob, id=id, user=request.user.id)

if job:

job.delete()
messages.success(request, 'Saved Job was successfully deleted!')

return redirect('jobapp:dashboard')


@login_required(login_url=reverse_lazy('account:login'))
@user_is_employer
def applicant_details_view(request, id):
Expand Down Expand Up @@ -290,16 +299,17 @@ def job_bookmark_view(request, id):
instance.user = user
instance.save()

messages.success(request, 'You have successfully save this job!')
messages.success(
request, 'You have successfully save this job!')
return redirect(reverse("jobapp:single-job", kwargs={
'id': id
}))

else:
return redirect(reverse("jobapp:single-job", kwargs={
'id': id
}))
'id': id
}))

else:
messages.error(request, 'You already saved this Job!')

Expand Down
Binary file modified requirements.txt
Binary file not shown.
9 changes: 8 additions & 1 deletion static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,11 @@ jQuery(function($) {
quillInit();


});
});



$('.appointment_date').datepicker({
'format': 'yyyy-m-d',
'autoclose': true
});
2 changes: 1 addition & 1 deletion template/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<link rel="stylesheet" href="{% static 'fonts/line-icons/style.css' %}">
<link rel="stylesheet" href="{% static 'css/owl.carousel.min.css' %}">
<link rel="stylesheet" href="{% static 'css/animate.min.css' %}">

<link rel="stylesheet" href="{% static 'css/bootstrap-datepicker.css' %}">

<!-- MAIN CSS -->
<link rel="stylesheet" href="{% static 'css/style.css' %}">
Expand Down
5 changes: 3 additions & 2 deletions template/jobapp/all-applicants.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ <h1 class="text-white font-weight-bold">All Applicants </h1>
<div class="container">
<div class="row">

<h1 class="text-center">All applicants </h1>
<h1 class="text-center"> All applicants </h1>


<div class="table-responsive">
<table class="table table-striped">
<thead>
Expand All @@ -36,6 +35,8 @@ <h1 class="text-center">All applicants </h1>
</thead>
<tbody>
{% for applicant in all_applicants %}
{{ applicant.get_total_applicant }}

<tr>
<th scope="row"><a href="">{{ applicant.user.get_full_name }}</a></th>
<td>{{ applicant.job.title }}</td>
Expand Down
33 changes: 29 additions & 4 deletions template/jobapp/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'base.html' %}
{% load static %}
{% load get_total_applicant %}
{% block content %}

<section class="section-hero overlay inner-page bg-image"
Expand Down Expand Up @@ -47,9 +48,33 @@ <h5 class="card-header text-center">My All Posts</h5>
<td><a href="{% url 'jobapp:single-job' job.id %}">{{ job.title }}</a></td>
<td>{{ job.timestamp | date:'M d, Y' }}</td>
<td>{{ job.last_date | date:'M d, Y' }}</td>
<td><a href="{% url 'jobapp:applicants' job.id %}"><i
class="fa fa-users"></i>{{ job.applicants.count }}
<span class="hidden-xs hidden-sm">Applicants</span> </a>
<td>

{% get_total_applicant total_applicants job as is_applicant %}

{% if is_applicant %}
<a href="{% url 'jobapp:applicants' job.id %}">
<i class="fa fa-users"></i>
<div class="btn btn-success btn-sm text-white">



{% if is_applicant > 1 %}


{% get_total_applicant total_applicants job %} Applicants

{% else %}

{% get_total_applicant total_applicants job %} Applicant

{% endif %}

</div>

</a>
{% endif %}

</td>
<td>
<a class="btn btn-info btn-sm" href="{% url 'jobapp:edit-job' job.id %}"
Expand Down Expand Up @@ -83,7 +108,7 @@ <h5 class="card-header text-center">My Bookmarks Posts</h5>
<td>{{ job.timestamp | date:'M d, Y' }}</td>
<td>{{ job.job.last_date | date:'M d, Y' }}</td>
<td>

<a class="btn btn-danger btn-sm" href="{% url 'jobapp:delete-bookmark' job.id %}"
role="button">Delete</a>
</td>
Expand Down
13 changes: 12 additions & 1 deletion template/jobapp/job-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,18 @@ <h3 class="text-black mb-5 border-bottom pb-2">Job Details</h3>

</select>
</div>


{% elif field.name == 'last_date' %}
<div class="form-group">
<label class="text-black" for="id_{{ field.name }}">{{ field.label }}</label>
<input type="{{ field.field.widget.input_type }}"
class="form-control"
name="{{ field.name }}"
id="id_{{ field.name }}"
value="{{ field.value|date:"Y-d-m" }}"
placeholder="{{ field.field.widget.attrs.placeholder }}">
</div>

{% elif field.name == 'description' %}
<div class="form-group">
<label for="job-type">Description</label>
Expand Down
Loading

0 comments on commit 08fe631

Please sign in to comment.