Skip to content

Commit

Permalink
added project requirements update script command
Browse files Browse the repository at this point in the history
  • Loading branch information
Pythonian committed Feb 22, 2024
1 parent 7c1326e commit 9a1f4bc
Show file tree
Hide file tree
Showing 13 changed files with 380 additions and 229 deletions.
6 changes: 3 additions & 3 deletions apps/core/management/commands/create_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


class Command(BaseCommand):
help = 'Create a new superuser'
help = "Create a new superuser"

def handle(self, *args, **options):
User.objects.create_superuser(username='admin', email='admin', password='admin')
User.objects.create_superuser(username="admin", email="admin@admin.com", password="admin")

self.stdout.write(self.style.SUCCESS('Superuser created successfully!'))
self.stdout.write(self.style.SUCCESS("Superuser created successfully!"))
37 changes: 37 additions & 0 deletions apps/core/management/commands/pip_updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import subprocess

from django.core.management.base import BaseCommand


class Command(BaseCommand):
help = "Check for and update outdated Python packages using pip."

def handle(self, *args, **options):
try:
# Use pip list to get a list of outdated packages
outdated_packages = subprocess.check_output(
["pip", "list", "--outdated", "--format=columns"], universal_newlines=True
)

if not outdated_packages.strip():
self.stdout.write(self.style.SUCCESS("All packages are up to date!"))
return

self.stdout.write("Outdated packages:")
self.stdout.write(outdated_packages)

# Ask the user if they want to update packages
response = input("Do you want to update these packages? (y/n): ").strip().lower()

if response == "y":
# Upgrade outdated packages
subprocess.call(
["pip", "install", "--upgrade"]
+ [line.split()[0] for line in outdated_packages.strip().split("\n")[2:]]
)
self.stdout.write(self.style.SUCCESS("Packages updated successfully!"))
else:
self.stdout.write(self.style.NOTICE("No packages were updated."))

except Exception as e:
self.stderr.write(self.style.ERROR(f"An error occurred: {str(e)}"))
89 changes: 36 additions & 53 deletions apps/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from apps.core.utils import mk_paginator
from apps.jobs.models import Job, State, Category


from .models import Testimonial


Expand All @@ -23,17 +22,17 @@ def home(request):
categories = Category.objects.all()[:8]
testimonials = Testimonial.objects.all()[:3]

template = 'core/home.html'
template = "core/home.html"
context = {
'jobs': jobs,
'jobs_count': Job.active.all().count(),
'companies': companies,
'companies_count': Company.objects.all().count(),
'states_count': State.objects.all().count(),
'resumes': resumes,
'resumes_count': Resume.objects.all().count(),
'categories': categories,
'testimonials': testimonials,
"jobs": jobs,
"jobs_count": Job.active.all().count(),
"companies": companies,
"companies_count": Company.objects.all().count(),
"states_count": State.objects.all().count(),
"resumes": resumes,
"resumes_count": Resume.objects.all().count(),
"categories": categories,
"testimonials": testimonials,
}

return render(request, template, context)
Expand All @@ -42,11 +41,11 @@ def home(request):
@login_required
def dashboard(request):
if request.user.is_company:
return redirect('employers:account')
return redirect("employers:account")
elif request.user.is_employee:
return redirect('employees:dashboard')
return redirect("employees:dashboard")
else:
return redirect('core:home')
return redirect("core:home")


def companies(request):
Expand All @@ -65,9 +64,9 @@ def companies(request):
companies = Company.objects.filter(jobs__isnull=False).distinct()
companies = mk_paginator(request, companies, 12)

template = 'core/companies.html'
template = "core/companies.html"
context = {
'companies': companies,
"companies": companies,
}

return render(request, template, context)
Expand All @@ -85,10 +84,10 @@ def company_detail(request, slug):
company = get_object_or_404(Company, slug=slug)
jobs = company.jobs.all()

template = 'employers/detail.html'
template = "employers/detail.html"
context = {
'company': company,
'jobs': jobs,
"company": company,
"jobs": jobs,
# 'last_seen': request.user.last_seen,
}

Expand All @@ -99,90 +98,74 @@ def resumes(request):
resumes = Resume.objects.all()
resumes = mk_paginator(request, resumes, 12)

template = 'core/resumes.html'
template = "core/resumes.html"
context = {
'resumes': resumes,
"resumes": resumes,
}

return render(request, template, context)


def help_center(request):

template = 'core/help-center.html'
context = {

}
template = "core/help-center.html"
context = {}

return render(request, template, context)


def help_article(request):

template = 'core/help-article.html'
context = {

}
template = "core/help-article.html"
context = {}

return render(request, template, context)


def help_category(request):

template = 'core/help-category.html'
context = {

}
template = "core/help-category.html"
context = {}

return render(request, template, context)


def faq(request):

template = 'core/faq.html'
context = {

}
template = "core/faq.html"
context = {}

return render(request, template, context)


def about(request):

template = 'core/about.html'
context = {

}
template = "core/about.html"
context = {}

return render(request, template, context)


def policy(request):

template = 'core/policy.html'
context = {

}
template = "core/policy.html"
context = {}

return render(request, template, context)


def post(request):

template = 'core/post.html'
context = {

}
template = "core/post.html"
context = {}

return render(request, template, context)


def contact(request):

template = 'core/contact.html'
context = {

}
template = "core/contact.html"
context = {}

return render(request, template, context)

Expand Down
52 changes: 34 additions & 18 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
{% load static %}

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand All @@ -13,17 +14,20 @@

<body class="d-flex flex-column min-vh-100">
{% if request.user.is_authenticated and not user.email_verified %}
<div class="m-0 rounded-0 alert alert-warning" role="alert">
<div class="container">
<i class="fa-solid fa-warning me-1"></i> We sent an email confirmation link to <strong>{{ user.email }}</strong>. Please check your email address.
</div>
<div class="m-0 rounded-0 alert alert-warning" role="alert">
<div class="container">
<i class="fa-solid fa-warning me-1"></i> We sent an email confirmation link to
<strong>{{ user.email }}</strong>. Please check your email address.
</div>
</div>
{% endif %}
{% if next %}
<div class="m-0 rounded-0 alert alert-warning" role="alert">
<div class="container">
<i class="fa-solid fa-warning me-1"></i> {% if request.user.is_authenticated %}Your account doesn't have access to the page. To proceed, please login with an
account that has access. {% else %} Please login with your correct credentials to access the page.{% endif %}
<i class="fa-solid fa-warning me-1"></i> {% if request.user.is_authenticated %}Your account doesn't have
access to the page. To proceed, please login with an
account that has access. {% else %} Please login with your correct credentials to access the
page.{% endif %}

</div>
</div>
Expand All @@ -46,25 +50,32 @@
</li>
<li class="nav-item me-lg-2">
<a class="nav-link {% url 'core:companies' as companies_url %}{% if request.get_full_path == companies_url %}active{% endif %}"
href="{% url 'core:companies' %}"><i class="me-1 fa-solid fa-building"></i> Employers</a>
href="{% url 'core:companies' %}"><i class="me-1 fa-solid fa-building"></i> Companies</a>
</li>
<li class="nav-item">
<a class="nav-link {% url 'core:resumes' as resumes_url %}{% if request.get_full_path == resumes_url %}active{% endif %}"
href="{% url 'core:resumes' %}"><i class="me-1 fa-solid fa-file-lines"></i> Resumes</a>
href="{% url 'core:resumes' %}"><i class="me-1 fa-solid fa-user-tie"></i> Candidates</a>
</li>
</ul>
<div class="d-flex mb-3 mb-lg-0">
{% if request.user.is_authenticated %}
<div class="dropdown">
<a class="nav-link dropdown-toggle text-white" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
{% if user.is_company %} {{ user.company.contact_person }} {% else %}{{ request.user.get_full_name }}{% endif %}
<a class="nav-link dropdown-toggle text-white" href="#" id="navbarDropdown" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
{% if user.is_company %} {{ user.company.contact_person }}
{% else %}{{ request.user.get_full_name }}{% endif %}
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
{% if user.is_company %}
<li class="mb-2"><a class="text-primary dropdown-item" href="{% url 'employers:account' %}"><i class="fa-solid fa-user me-1"></i> My Account</a></li>
<li class="mb-2"><a class="text-primary dropdown-item" href="{% url 'employers:jobs' %}"><i class="fa-solid fa-briefcase me-1"></i> Manage Jobs</a></li>
<li class="mb-2"><a class="text-primary dropdown-item" href="{% url 'employers:candidates' %}"><i class="fa-solid fa-users me-1"></i> Manage Candidates</a>
{% else %}
<li class="mb-2"><a class="text-primary dropdown-item"
href="{% url 'employers:account' %}"><i class="fa-solid fa-user me-1"></i> My
Account</a></li>
<li class="mb-2"><a class="text-primary dropdown-item" href="{% url 'employers:jobs' %}"><i
class="fa-solid fa-briefcase me-1"></i> Manage Jobs</a></li>
<li class="mb-2"><a class="text-primary dropdown-item"
href="{% url 'employers:candidates' %}"><i class="fa-solid fa-users me-1"></i>
Manage Candidates</a>
{% else %}
<li class="mb-2">
<a class="text-primary dropdown-item" href="{% url 'employees:dashboard' %}">
<i class="fa-solid fa-gauge me-1"></i> My Dashboard
Expand Down Expand Up @@ -100,15 +111,19 @@
<hr class="dropdown-divider">
</li>
<li>
<a class="dropdown-item text-danger" data-bs-toggle="modal" data-bs-target="#logoutModal">
<a class="dropdown-item text-danger" data-bs-toggle="modal"
data-bs-target="#logoutModal">
<i class="fa-solid fa-power-off me-1"></i> Logout
</a>
</li>
</ul>
</div>
{% else %}
<a href="{% url 'auth:login' %}" class="btn {% url 'auth:login' as login_url %}{% if request.get_full_path == login_url %}btn-light{% else %}btn-outline-light{% endif %} me-2"><i class="fa-solid fa-right-to-bracket me-1"></i> Login</a>
<a href="{% url 'auth:signup_choice' %}" class="btn btn-primary"><i class="fa-solid fa-user-plus me-1"></i> Register</a>
<a href="{% url 'auth:login' %}"
class="btn {% url 'auth:login' as login_url %}{% if request.get_full_path == login_url %}btn-light{% else %}btn-outline-light{% endif %} me-2"><i
class="fa-solid fa-right-to-bracket me-1"></i> Login</a>
<a href="{% url 'auth:signup_choice' %}" class="btn btn-primary"><i
class="fa-solid fa-user-plus me-1"></i> Register</a>
{% endif %}
</div>
</div>
Expand All @@ -134,4 +149,5 @@
{% block scripts %}{% endblock scripts %}

</body>
</html>

</html>
Loading

0 comments on commit 9a1f4bc

Please sign in to comment.