Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • an3-aboobakuru/systemdev
1 result
Select Git revision
Loading items
Show changes
Commits on Source (4)
Showing
with 267 additions and 32 deletions
No preview for this file type
......@@ -65,6 +65,7 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'accounts.context_processors.add_user_role'
],
},
},
......
No preview for this file type
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
from django.contrib import admin
# Register your models here.
from .models import Notification
@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
list_display = ('user', 'message', 'is_read', 'created_at')
list_filter = ('is_read', 'created_at')
search_fields = ('user__username', 'message')
from django.contrib import admin
from .models import CustomUser, EmployerProfile, Notification, JobSeekerProfile
from django.contrib.auth.admin import UserAdmin
......@@ -29,10 +17,31 @@ class CustomUserAdmin(UserAdmin):
# Register the CandidateProfile
@admin.register(JobSeekerProfile)
class JobSeekerProfileAdmin(admin.ModelAdmin):
list_display = ('user', 'first_name', 'last_name', 'email')
list_display = ('user', 'first_name', 'last_name', 'get_email')
def get_email(self, obj):
return obj.user.email
get_email.short_description = 'Email'
# Register the EmployerProfile
@admin.register(EmployerProfile)
class EmployerProfileAdmin(admin.ModelAdmin):
list_display = ('user', 'business_name', 'business_type', 'business_category', 'location', 'region')
list_display = ('user', 'business_name', 'business_type', 'business_category', 'location', 'region', 'get_email', 'truncated_fields_for_jobs', 'status')
list_filter = ('business_category', 'status') # Add filters
search_fields = ('business_name', 'user__email') # Add search fields
def get_email(self, obj):
return obj.user.email
get_email.short_description = 'Email'
def truncated_fields_for_jobs(self, obj):
return obj.fields_for_jobs[:50] + "..." if len(obj.fields_for_jobs) > 50 else obj.fields_for_jobs
truncated_fields_for_jobs.short_description = "Fields for Jobs"
# Register the Notification model
@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
list_display = ('user', 'message', 'is_read', 'created_at')
list_filter = ('is_read', 'is_archived','created_at')
search_fields = ('user__username', 'message')
from .models import JobSeekerProfile, EmployerProfile
def add_user_role(request):
if request.user.is_authenticated:
if request.user.user_type == "job_seeker":
return {"role": "Job Seeker"}
elif request.user.user_type == "employer":
return {"role": "Employer"}
elif request.user.user_type == "admin":
return {"role": "Admin"}
return {"role": None}
from django import forms
from django.contrib.auth.forms import UserCreationForm
from .models import CustomUser, JobSeekerProfile, EmployerProfile
from .models import CustomUser, JobSeekerProfile, EmployerProfile, STATUS_CHOICES, CATEGORY_CHOICES
from django import forms
from .models import CustomUser
class EmployerProfileForm(forms.ModelForm):
class Meta:
model = EmployerProfile
fields = ['business_name', 'business_type', 'business_category', 'location', 'region','email']
fields = [
'business_name',
'business_type',
'business_category',
'location',
'region',
'status',
'fields_for_jobs',
]
widgets = {
'business_name': forms.TextInput(attrs={'class': 'form-control'}),
'business_type': forms.Select(attrs={'class': 'form-control'}),
'business_category': forms.TextInput(attrs={'class': 'form-control'}),
'business_category': forms.Select(choices=CATEGORY_CHOICES, attrs={'class': 'form-control'}),
'location': forms.TextInput(attrs={'class': 'form-control'}),
'region': forms.TextInput(attrs={'class': 'form-control'}),
'email': forms.EmailInput(attrs={'class': 'form-control'}),
'status': forms.Select(choices=STATUS_CHOICES, attrs={'class': 'form-control'}),
'fields_for_jobs': forms.TextInput(attrs={'class': 'form-control'}),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Dynamically populate fields_for_jobs dropdown
self.fields['fields_for_jobs'].queryset = EmployerProfile.objects.all()
self.fields['fields_for_jobs'].empty_label = "Select a Job"
class JobSeekerProfileForm(forms.ModelForm):
class Meta:
model = JobSeekerProfile
fields = ['first_name', 'last_name', 'email', 'resume', 'skills']
fields = ['first_name', 'last_name', 'resume', 'skills']
widgets = {
'first_name': forms.TextInput(attrs={'class': 'form-control'}),
'last_name': forms.TextInput(attrs={'class': 'form-control'}),
'email': forms.EmailInput(attrs={'class': 'form-control'}),
'resume': forms.ClearableFileInput(attrs={'accept': '.pdf'}),
'skills': forms.Textarea(attrs={'class': 'form-control', 'rows': 5}),
'skills': forms.Select(choices=CATEGORY_CHOICES, attrs={'class': 'form-control'})
}
class ProfileEditForm(forms.ModelForm):
class Meta:
model = CustomUser # Replace with your user model
fields = ['username', 'email'] # Add fields you want users to edit
model = CustomUser
fields = ['username', 'email']
widgets = {
'username': forms.TextInput(attrs={'class': 'form-control'}),
'email': forms.EmailInput(attrs={'class': 'form-control'}),
......@@ -47,26 +63,26 @@ class ProfileEditForm(forms.ModelForm):
class JobSeekerRegisterForm(UserCreationForm):
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)
email = forms.EmailField()
email = forms.EmailField(required=True)
resume = forms.FileField(required=False, widget=forms.ClearableFileInput(attrs={'accept': '.pdf'}))
skills = forms.CharField(required=False, widget=forms.Textarea(attrs={'class': 'form-control', 'rows': 5}))
skills = forms.ChoiceField(choices=CATEGORY_CHOICES, required=False, widget=forms.Select(attrs={'class': 'form-control'}))
class Meta:
model = CustomUser
fields = ['username', 'password1', 'password2', 'first_name', 'last_name', 'email']
fields = ['username', 'password1', 'password2', 'first_name', 'last_name']
widgets = {
'resume': forms.ClearableFileInput(attrs={'accept': '.pdf'}), # Limit to PDF files
}
def save(self, commit=True):
user = super().save(commit=False)
user.user_type = 'job_seeker'
user.email = self.cleaned_data['email'] # Save email to user
if commit:
user.save()
JobSeekerProfile.objects.create(
user=user,
first_name=self.cleaned_data['first_name'],
last_name=self.cleaned_data['last_name'],
email=self.cleaned_data['email'],
resume=self.cleaned_data.get('resume'),
skills=self.cleaned_data.get('skills', '')
)
......@@ -76,18 +92,29 @@ class JobSeekerRegisterForm(UserCreationForm):
class EmployerRegisterForm(UserCreationForm):
business_name = forms.CharField(max_length=200)
business_type = forms.ChoiceField(choices=[('Local', 'Local'), ('Service', 'Service'), ('Online', 'Online')])
business_category = forms.CharField(max_length=200)
email = forms.EmailField(required=True)
business_category = forms.ChoiceField(choices=CATEGORY_CHOICES, widget=forms.Select(attrs={'class': 'form-control'}))
location = forms.CharField(max_length=200)
region = forms.CharField(max_length=100)
fields_for_jobs = forms.CharField(
required=False,
widget=forms.Textarea(attrs={'class': 'form-control', 'rows': 3}),
help_text="Enter the fields for jobs, separated by commas."
)
status = forms.ChoiceField(
choices=[('Open', 'Open'), ('Close', 'Close')],
widget=forms.Select(attrs={'class': 'form-control'}),
initial='Open'
)
class Meta:
model = CustomUser
fields = ['username', 'password1', 'password2', 'business_name', 'business_type', 'business_category', 'location', 'region', 'email']
fields = ['username', 'password1', 'password2', 'business_name', 'business_type', 'business_category', 'location', 'region', 'fields_for_jobs', 'status']
def save(self, commit=True):
user = super().save(commit=False)
user.user_type = 'employer'
user.email = self.cleaned_data['email'] # Save email to user
if commit:
user.save()
EmployerProfile.objects.create(
......@@ -97,7 +124,8 @@ class EmployerRegisterForm(UserCreationForm):
business_category=self.cleaned_data['business_category'],
location=self.cleaned_data['location'],
region=self.cleaned_data['region'],
email = self.cleaned_data['email'],
fields_for_jobs=self.cleaned_data.get('fields_for_jobs', ''),
status=self.cleaned_data.get('status', 'Open'),
)
return user
# Generated by Django 5.0.6 on 2024-08-12 18:10
# Generated by Django 5.1.2 on 2024-12-10 06:14
from django.db import migrations, models
......@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('PROJECT1', '0015_customuser_role_alter_customuser_groups_and_more'),
("accounts", "0005_notification_email_notification_related_cv_and_more"),
]
operations = [
migrations.AddField(
model_name='job',
name='form_url',
field=models.URLField(blank=True, null=True),
model_name="notification",
name="is_archived",
field=models.BooleanField(default=False),
),
]
# Generated by Django 4.2.4 on 2023-12-15 02:49
# Generated by Django 5.1.2 on 2024-12-10 10:43
from django.db import migrations
......@@ -6,11 +6,16 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("PROJECT1", "0006_order_user_alter_cartitem_user_and_more"),
("accounts", "0006_notification_is_archived"),
]
operations = [
migrations.DeleteModel(
name="FauxPayment",
migrations.RemoveField(
model_name="employerprofile",
name="email",
),
migrations.RemoveField(
model_name="jobseekerprofile",
name="email",
),
]
# Generated by Django 5.1.2 on 2024-12-10 11:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("accounts", "0007_remove_employerprofile_email_and_more"),
]
operations = [
migrations.AlterField(
model_name="employerprofile",
name="business_category",
field=models.CharField(
choices=[
("Accounting / Finance", "Accounting / Finance"),
("Administrative / Clerical", "Administrative / Clerical"),
("Beauty / Wellness / Fitness", "Beauty / Wellness / Fitness"),
("Building / Construction", "Building / Construction"),
("Call Centres / Telemarketing", "Call Centres / Telemarketing"),
("Cleaning / Housekeeping", "Cleaning / Housekeeping"),
("Creative / Design", "Creative / Design"),
(
"Customer Service / Receptionists",
"Customer Service / Receptionists",
),
("Drivers / Riders / Delivery", "Drivers / Riders / Delivery"),
("Education / Training", "Education / Training"),
(
"General Production / Operators",
"General Production / Operators",
),
("Hospitality / F&B", "Hospitality / F&B"),
("Human Resources", "Human Resources"),
("IT / Technical / Engineers", "IT / Technical / Engineers"),
("Manufacturing", "Manufacturing"),
("Nursing / Health Care", "Nursing / Health Care"),
("Others", "Others"),
("Sales / Retail / Marketing", "Sales / Retail / Marketing"),
(
"Secretaries / Personal Assistants",
"Secretaries / Personal Assistants",
),
("Security", "Security"),
("Temporary / Events", "Temporary / Events"),
("Warehousing & Logistics", "Warehousing & Logistics"),
],
max_length=50,
),
),
migrations.AlterField(
model_name="jobseekerprofile",
name="skills",
field=models.CharField(
choices=[
("Accounting / Finance", "Accounting / Finance"),
("Administrative / Clerical", "Administrative / Clerical"),
("Beauty / Wellness / Fitness", "Beauty / Wellness / Fitness"),
("Building / Construction", "Building / Construction"),
("Call Centres / Telemarketing", "Call Centres / Telemarketing"),
("Cleaning / Housekeeping", "Cleaning / Housekeeping"),
("Creative / Design", "Creative / Design"),
(
"Customer Service / Receptionists",
"Customer Service / Receptionists",
),
("Drivers / Riders / Delivery", "Drivers / Riders / Delivery"),
("Education / Training", "Education / Training"),
(
"General Production / Operators",
"General Production / Operators",
),
("Hospitality / F&B", "Hospitality / F&B"),
("Human Resources", "Human Resources"),
("IT / Technical / Engineers", "IT / Technical / Engineers"),
("Manufacturing", "Manufacturing"),
("Nursing / Health Care", "Nursing / Health Care"),
("Others", "Others"),
("Sales / Retail / Marketing", "Sales / Retail / Marketing"),
(
"Secretaries / Personal Assistants",
"Secretaries / Personal Assistants",
),
("Security", "Security"),
("Temporary / Events", "Temporary / Events"),
("Warehousing & Logistics", "Warehousing & Logistics"),
],
max_length=50,
),
),
]
# Generated by Django 4.2.4 on 2023-12-12 09:10
# Generated by Django 5.1.2 on 2024-12-10 12:54
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("PROJECT1", "0003_contact"),
("accounts", "0008_alter_employerprofile_business_category_and_more"),
]
operations = [
migrations.RemoveField(
model_name="order",
name="user",
),
migrations.AddField(
model_name="orderitem",
name="user",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
model_name="jobseekerprofile",
name="allowed_employers",
field=models.ManyToManyField(
blank=True,
related_name="allowed_candidates",
to=settings.AUTH_USER_MODEL,
),
),
......
# Generated by Django 5.1.2 on 2024-12-11 05:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("accounts", "0009_jobseekerprofile_allowed_employers"),
]
operations = [
migrations.AddField(
model_name="employerprofile",
name="fields_for_jobs",
field=models.TextField(
blank=True,
help_text="Enter the fields for jobs, separated by commas. Example: Cashier, Manager, Driver.",
),
),
migrations.AddField(
model_name="employerprofile",
name="status",
field=models.CharField(
choices=[("Open", "Open"), ("Close", "Close")],
default="Open",
help_text="Indicates whether the employer is currently hiring.",
max_length=10,
),
),
]