Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/job #678

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Binary file added .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,6 @@ dmypy.json
.idea/workspace.xml

# Exception for Tailwind CSS
!theme/static/css/dist/
!theme/static/css/dist/

**/.DS_Store
Empty file added jobs/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions jobs/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions jobs/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class JobsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "jobs"
33 changes: 33 additions & 0 deletions jobs/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from django import forms
from django.core.exceptions import ValidationError

from .models import Job


class JobForm(forms.ModelForm):
class Meta:
model = Job
fields = [
"title",
"description",
"sector",
"contract_type",
"pay",
"employer_name",
"incorporation_number",
"website",
"expiry_date",
"application_url",
]

def clean_expiry_date(self):
expiry_date = self.cleaned_data.get("expiry_date")

# Check if the expiry_date is in a valid format
if not expiry_date:
raise ValidationError("Please enter a valid date.")

# Custom validation logic for the expiry_date field
# ...

return expiry_date
Empty file added jobs/management/__init__.py
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions jobs/management/commands/unpublish_listings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import datetime
from django.core.management.base import BaseCommand
from jobs.models import Job


class Command(BaseCommand):
help = "Unpublish expired job listings"

def handle(self, *args, **options):
expired_date = datetime.date.today() - datetime.timedelta(days=30)
expired_listings = Job.objects.filter(created__lt=expired_date)
expired_listings.update(is_published=False)
49 changes: 49 additions & 0 deletions jobs/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 3.2.19 on 2023-05-20 13:10

from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="Job",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=100)),
("description", models.TextField()),
(
"sector",
models.CharField(
choices=[("commercial", "Commercial"), ("charity", "Charity")],
max_length=20,
),
),
(
"pay",
models.DecimalField(
blank=True, decimal_places=2, max_digits=10, null=True
),
),
("employer_name", models.CharField(max_length=100)),
(
"incorporation_number",
models.CharField(blank=True, max_length=20, null=True),
),
("website", models.URLField()),
("expiry_date", models.DateField()),
("application_url", models.URLField()),
],
),
]
28 changes: 28 additions & 0 deletions jobs/migrations/0002_job_contract_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.19 on 2023-05-20 13:55

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("jobs", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="job",
name="contract_type",
field=models.CharField(
choices=[
("voluntary", "Voluntary (Unpaid)"),
("temporary", "Temporary"),
("fixed_term_contract", "Fixed Term Contract"),
("part_time_permanent", "Part-time Permanent Employed"),
("full_time_permanent", "Full-time Permanent Employed"),
],
default="",
max_length=20,
),
preserve_default=False,
),
]
34 changes: 34 additions & 0 deletions jobs/migrations/0003_auto_20230610_0843.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.19 on 2023-06-10 08:43

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("jobs", "0002_job_contract_type"),
]

operations = [
migrations.AlterField(
model_name="job",
name="contract_type",
field=models.CharField(
choices=[
("Voluntary", "Voluntary (Unpaid)"),
("Temporary", "Temporary"),
("Fixed Term Contract", "Fixed Term Contract"),
("Part-time Permanent", "Part Time Permanent Employed"),
("Full-time Permanent Employed", "Full-time Permanent Employed"),
],
max_length=40,
),
),
migrations.AlterField(
model_name="job",
name="sector",
field=models.CharField(
choices=[("Commercial", "Commercial"), ("Charity", "Charity")],
max_length=20,
),
),
]
34 changes: 34 additions & 0 deletions jobs/migrations/0004_auto_20230610_0852.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.19 on 2023-06-10 08:52

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("jobs", "0003_auto_20230610_0843"),
]

operations = [
migrations.AlterField(
model_name="job",
name="contract_type",
field=models.CharField(
choices=[
("voluntary", "Voluntary"),
("temporary", "Temporary"),
("fixed_term_contract", "Fixed Term Contract"),
("part_time_permanent", "Part-time Permanent"),
("full_time_permanent", "Full-time Permanent Employed"),
],
max_length=40,
),
),
migrations.AlterField(
model_name="job",
name="sector",
field=models.CharField(
choices=[("commercial", "Commercial"), ("charity", "Charity")],
max_length=20,
),
),
]
25 changes: 25 additions & 0 deletions jobs/migrations/0005_auto_20230610_0901.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.19 on 2023-06-10 09:01

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):
dependencies = [
("jobs", "0004_auto_20230610_0852"),
]

operations = [
migrations.AlterModelOptions(
name="job",
options={"ordering": ["-created"]},
),
migrations.AddField(
model_name="job",
name="created",
field=models.DateTimeField(
auto_now_add=True, default=django.utils.timezone.now
),
preserve_default=False,
),
]
17 changes: 17 additions & 0 deletions jobs/migrations/0006_job_is_published.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.19 on 2023-06-26 18:47

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("jobs", "0005_auto_20230610_0901"),
]

operations = [
migrations.AddField(
model_name="job",
name="is_published",
field=models.BooleanField(default=True),
),
]
21 changes: 21 additions & 0 deletions jobs/migrations/0007_job_published_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.19 on 2023-06-26 19:05

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):
dependencies = [
("jobs", "0006_job_is_published"),
]

operations = [
migrations.AddField(
model_name="job",
name="published_date",
field=models.DateField(
auto_now_add=True, default=django.utils.timezone.now
),
preserve_default=False,
),
]
21 changes: 21 additions & 0 deletions jobs/migrations/0008_auto_20230626_1917.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.19 on 2023-06-26 19:17

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("jobs", "0007_job_published_date"),
]

operations = [
migrations.RemoveField(
model_name="job",
name="published_date",
),
migrations.AddField(
model_name="job",
name="updated",
field=models.DateField(auto_now=True),
),
]
21 changes: 21 additions & 0 deletions jobs/migrations/0009_auto_20230626_1922.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.19 on 2023-06-26 19:22

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("jobs", "0008_auto_20230626_1917"),
]

operations = [
migrations.RemoveField(
model_name="job",
name="updated",
),
migrations.AddField(
model_name="job",
name="updated_on",
field=models.DateTimeField(auto_now=True),
),
]
25 changes: 25 additions & 0 deletions jobs/migrations/0010_auto_20230626_1924.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.19 on 2023-06-26 19:24

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):
dependencies = [
("jobs", "0009_auto_20230626_1922"),
]

operations = [
migrations.RemoveField(
model_name="job",
name="updated_on",
),
migrations.AddField(
model_name="job",
name="published_date",
field=models.DateField(
auto_now_add=True, default=django.utils.timezone.now
),
preserve_default=False,
),
]
19 changes: 19 additions & 0 deletions jobs/migrations/0011_alter_job_incorporation_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.22 on 2023-10-08 13:27

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):
dependencies = [
("jobs", "0010_auto_20230626_1924"),
]

operations = [
migrations.AlterField(
model_name="job",
name="incorporation_number",
field=models.CharField(blank=True, default="", max_length=20),
preserve_default=False,
),
]
Empty file added jobs/migrations/__init__.py
Empty file.
Loading
Loading