From 603f5d2981161b764722fe101bf01db2dbc456a4 Mon Sep 17 00:00:00 2001 From: Isaiah Olatunbosun Date: Fri, 9 Jun 2023 19:36:45 +0100 Subject: [PATCH 01/12] created job form --- .DS_Store | Bin 0 -> 8196 bytes docker-compose.yml | 1 - jobs/__init__.py | 0 jobs/admin.py | 3 + jobs/apps.py | 6 + jobs/forms.py | 23 ++++ jobs/migrations/0001_initial.py | 29 +++++ jobs/migrations/0002_job_contract_type.py | 19 +++ jobs/migrations/__init__.py | 0 jobs/models.py | 33 +++++ jobs/templates/jobs/create_job.html | 147 ++++++++++++++++++++++ jobs/templates/jobs/job_listing.html | 8 ++ jobs/tests.py | 3 + jobs/urls.py | 11 ++ jobs/views.py | 27 ++++ web/settings.py | 1 + web/urls.py | 1 + 17 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 .DS_Store create mode 100644 jobs/__init__.py create mode 100644 jobs/admin.py create mode 100644 jobs/apps.py create mode 100644 jobs/forms.py create mode 100644 jobs/migrations/0001_initial.py create mode 100644 jobs/migrations/0002_job_contract_type.py create mode 100644 jobs/migrations/__init__.py create mode 100644 jobs/models.py create mode 100644 jobs/templates/jobs/create_job.html create mode 100644 jobs/templates/jobs/job_listing.html create mode 100644 jobs/tests.py create mode 100644 jobs/urls.py create mode 100644 jobs/views.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0df1499b684efa3525982d3ef4fd5045cc6a25b3 GIT binary patch literal 8196 zcmeHM-A)rh6h1=>ZK+6O0P(_P6K@fzXbkbDwh+_AU_wzY)YM(Nwhi0e+TBu-kn~=k z!B;R|`XKr)Ug>vcmu6?%!ky7DLw3&Y%=eu+e>=+n5s7lYQ6yR=qAV_!g*>_mjpz9q zYctWvZAbw=(IGixqijQ{q+{M-IAkf3 z!%&8F5+R*Lw6cg!C_=6do+05RN}<%fj)0E9cm(+Do}+a>vr{jAe)kS7$Fnet7fJvn zuK$)zs#pM{K_2i&IPdqsZIX-U9@$k#VSY+5(_l7%4-&Xv30&qJM=k1;rJ`q=3H1C3 zJ=Kz#9|_JZIBj@glc{P?eM=zoRL4)3PT;SJs|5~5RMuFG=BYx@X`6P?AJ8u39@SJ1 zJwY_rV{u)SoL$-nwn}Asfx9ZWPho3^8VUB-1bZ%?6BWzWDJ!kSv2+(+d03%~-iLRb zU7L;}PcZ5vbRnmTt{a!=nxq5yR&->rUJrWK>BIPnoNooaK<`i$E~@VYnFx@_jH_u+9HEI+XhS4y0f<6Q=;G@_i3y%(}t;*5f1yhp|G9%oCQ zi@f--GC;j0_99s`asDEZ0hnwZd&X}FYqR0)VRFZlRT5`k1DC5TKqh&0A4~^N2|sz) zQT&_*hIblNwi*%6xQOq@sj!|CC}eXI${P6HXlMU!b)B{!Y;61#GpY3KTqcvtE7KAQeup<{@{c|NZ}BC3;pzKu6%ej(|vS*S5=W zVcHJLXKe%5TU^{2Hw>kupp(aONO>HG9R0%(_XeQMDMfM^N{pcW^*;pY@4x>3%gVdj F-5*>FRU-fZ literal 0 HcmV?d00001 diff --git a/docker-compose.yml b/docker-compose.yml index aafef7d4..d022a0a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,6 @@ version: "3" services: web: - image: geekzone/backend:${TAG} build: context: . dockerfile: docker/backend/Dockerfile diff --git a/jobs/__init__.py b/jobs/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/jobs/admin.py b/jobs/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/jobs/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/jobs/apps.py b/jobs/apps.py new file mode 100644 index 00000000..cae3796c --- /dev/null +++ b/jobs/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class JobsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'jobs' diff --git a/jobs/forms.py b/jobs/forms.py new file mode 100644 index 00000000..0c41bd2b --- /dev/null +++ b/jobs/forms.py @@ -0,0 +1,23 @@ +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 diff --git a/jobs/migrations/0001_initial.py b/jobs/migrations/0001_initial.py new file mode 100644 index 00000000..c152c4ef --- /dev/null +++ b/jobs/migrations/0001_initial.py @@ -0,0 +1,29 @@ +# 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()), + ], + ), + ] diff --git a/jobs/migrations/0002_job_contract_type.py b/jobs/migrations/0002_job_contract_type.py new file mode 100644 index 00000000..14e37c73 --- /dev/null +++ b/jobs/migrations/0002_job_contract_type.py @@ -0,0 +1,19 @@ +# 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, + ), + ] diff --git a/jobs/migrations/__init__.py b/jobs/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/jobs/models.py b/jobs/models.py new file mode 100644 index 00000000..3700dd2c --- /dev/null +++ b/jobs/models.py @@ -0,0 +1,33 @@ +from django.db import models + +# Create your models here. + + +class Job(models.Model): + SECTOR_CHOICES = [ + ('commercial', 'Commercial'), + ('charity', 'Charity') + ] + + CONTRACT_TYPE_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'), + ] + + title = models.CharField(max_length=100) + description = models.TextField() + sector = models.CharField(max_length=20, choices=SECTOR_CHOICES) + contract_type = models.CharField(max_length=20, choices=CONTRACT_TYPE_CHOICES) + pay = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True) + employer_name = models.CharField(max_length=100) + incorporation_number = models.CharField(max_length=20, null=True, blank=True) + website = models.URLField(max_length=200) + expiry_date = models.DateField() + application_url = models.URLField(max_length=200) + + def is_expired(self): + from datetime import date + return date.today() > self.expiry_date diff --git a/jobs/templates/jobs/create_job.html b/jobs/templates/jobs/create_job.html new file mode 100644 index 00000000..7462d3d6 --- /dev/null +++ b/jobs/templates/jobs/create_job.html @@ -0,0 +1,147 @@ +{% extends 'base.html' %} + +{% block content %} + + {% if form.errors %} + {{ form.errors }} + {% endif %} + + + + + + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/jobs/templates/jobs/job_listing.html b/jobs/templates/jobs/job_listing.html new file mode 100644 index 00000000..58d4e1e8 --- /dev/null +++ b/jobs/templates/jobs/job_listing.html @@ -0,0 +1,8 @@ + +{% for job in jobs %} +

{{ job.title }}

+

{{ job.description }}

+ +{% empty %} +

No job listings available.

+{% endfor %} diff --git a/jobs/tests.py b/jobs/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/jobs/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/jobs/urls.py b/jobs/urls.py new file mode 100644 index 00000000..26950ebe --- /dev/null +++ b/jobs/urls.py @@ -0,0 +1,11 @@ +from django.urls import path + +from . import views + +app_name = 'jobs' + +urlpatterns = [ + path('', views.job_listing, name='job_listing'), + path('create/', views.create_job, name='create_job'), + +] \ No newline at end of file diff --git a/jobs/views.py b/jobs/views.py new file mode 100644 index 00000000..29a94503 --- /dev/null +++ b/jobs/views.py @@ -0,0 +1,27 @@ +from django.shortcuts import render, redirect + +from .models import Job +from .forms import JobForm + +# Create your views here. + + +def create_job(request): + if request.method == 'POST': + form = JobForm(request.POST) + if form.is_valid(): + form.save() + return redirect('jobs:job_listing') + else: + form = JobForm() + + # If form is invalid, print errors + if form.errors: + print(form.errors) + return render(request, 'jobs/create_job.html', {'form': form}) + + +def job_listing(request): + jobs = Job.objects.all() + return render(request, 'jobs/job_listing.html', {'jobs': jobs}) + diff --git a/web/settings.py b/web/settings.py index f8a1c9ec..74be4b78 100644 --- a/web/settings.py +++ b/web/settings.py @@ -54,6 +54,7 @@ "memberships", "django_extensions", "django_probes", + "jobs", ] MIDDLEWARE = [ diff --git a/web/urls.py b/web/urls.py index f793ea30..f32631bb 100644 --- a/web/urls.py +++ b/web/urls.py @@ -21,4 +21,5 @@ path("admin/", admin.site.urls), path("memberships/", include("memberships.urls")), path("theme/", include("theme.urls")), + path("jobs/", include("jobs.urls")), ] From d29250cf2586fb2e5bce35c7cd4fcf072b7a17a7 Mon Sep 17 00:00:00 2001 From: Isaiah Olatunbosun Date: Fri, 9 Jun 2023 23:15:28 +0100 Subject: [PATCH 02/12] updated job listing page --- jobs/models.py | 5 +++++ jobs/templates/jobs/job_detail.html | 6 +++++ jobs/templates/jobs/job_listing.html | 33 ++++++++++++++++++++++------ jobs/urls.py | 4 ++-- jobs/views.py | 9 +++++++- 5 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 jobs/templates/jobs/job_detail.html diff --git a/jobs/models.py b/jobs/models.py index 3700dd2c..c3b23f8f 100644 --- a/jobs/models.py +++ b/jobs/models.py @@ -1,4 +1,6 @@ from django.db import models +from django.urls import reverse + # Create your models here. @@ -31,3 +33,6 @@ class Job(models.Model): def is_expired(self): from datetime import date return date.today() > self.expiry_date + + def get_absolute_url(self): + return reverse("jobs:job_detail", kwargs={'pk': self.pk}) diff --git a/jobs/templates/jobs/job_detail.html b/jobs/templates/jobs/job_detail.html new file mode 100644 index 00000000..6549be5e --- /dev/null +++ b/jobs/templates/jobs/job_detail.html @@ -0,0 +1,6 @@ +{% extends 'base.html' %} + +{% block content %} + + +{% endblock %} \ No newline at end of file diff --git a/jobs/templates/jobs/job_listing.html b/jobs/templates/jobs/job_listing.html index 58d4e1e8..d7027c14 100644 --- a/jobs/templates/jobs/job_listing.html +++ b/jobs/templates/jobs/job_listing.html @@ -1,8 +1,27 @@ +{% extends 'base.html' %} -{% for job in jobs %} -

{{ job.title }}

-

{{ job.description }}

- -{% empty %} -

No job listings available.

-{% endfor %} +{% block content %} + +
    + {% for job in jobs %} +
  • +
    + +
    +

    {{ job.title }}

    +

    {{ job.employer_name }}

    +
    +
    + +
  • + + {% empty %} +

    No job listings available.

    + {% endfor %} + +
+ + + +{% endblock %} diff --git a/jobs/urls.py b/jobs/urls.py index 26950ebe..aea3dab0 100644 --- a/jobs/urls.py +++ b/jobs/urls.py @@ -7,5 +7,5 @@ urlpatterns = [ path('', views.job_listing, name='job_listing'), path('create/', views.create_job, name='create_job'), - -] \ No newline at end of file + path('/', views.job_detail, name='job_detail'), +] diff --git a/jobs/views.py b/jobs/views.py index 29a94503..c41fbcfd 100644 --- a/jobs/views.py +++ b/jobs/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render, redirect +from django.shortcuts import render, redirect, get_object_or_404 from .models import Job from .forms import JobForm @@ -25,3 +25,10 @@ def job_listing(request): jobs = Job.objects.all() return render(request, 'jobs/job_listing.html', {'jobs': jobs}) + +def job_detail(request, pk): + + job = get_object_or_404(Job, pk=pk) + + return render(request, 'jobs/job_detail.html', {'job': job}) + From f873c66e9025e7bf147ad28ff4a3515930e9705c Mon Sep 17 00:00:00 2001 From: Isaiah Olatunbosun Date: Sat, 10 Jun 2023 12:01:55 +0100 Subject: [PATCH 03/12] added paginator --- jobs/migrations/0003_auto_20230610_0843.py | 23 ++++++++++++++++++++++ jobs/migrations/0004_auto_20230610_0852.py | 23 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 jobs/migrations/0003_auto_20230610_0843.py create mode 100644 jobs/migrations/0004_auto_20230610_0852.py diff --git a/jobs/migrations/0003_auto_20230610_0843.py b/jobs/migrations/0003_auto_20230610_0843.py new file mode 100644 index 00000000..31f511a9 --- /dev/null +++ b/jobs/migrations/0003_auto_20230610_0843.py @@ -0,0 +1,23 @@ +# 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), + ), + ] diff --git a/jobs/migrations/0004_auto_20230610_0852.py b/jobs/migrations/0004_auto_20230610_0852.py new file mode 100644 index 00000000..d5c819ea --- /dev/null +++ b/jobs/migrations/0004_auto_20230610_0852.py @@ -0,0 +1,23 @@ +# 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), + ), + ] From 1b647efbfd2715921d076852ff09101fed5f7ca7 Mon Sep 17 00:00:00 2001 From: Isaiah Olatunbosun Date: Mon, 26 Jun 2023 20:30:33 +0100 Subject: [PATCH 04/12] added job unpulish feature --- jobs/management/__init__.py | 0 jobs/management/commands/__init__.py | 0 .../management/commands/unpublish_listings.py | 13 ++++ jobs/migrations/0005_auto_20230610_0901.py | 24 +++++++ jobs/migrations/0006_job_is_published.py | 18 +++++ jobs/migrations/0007_job_published_date.py | 20 ++++++ jobs/migrations/0008_auto_20230626_1917.py | 22 ++++++ jobs/migrations/0009_auto_20230626_1922.py | 22 ++++++ jobs/migrations/0010_auto_20230626_1924.py | 24 +++++++ jobs/models.py | 13 +++- jobs/templates/jobs/create_job.html | 68 +++++++++++++++---- jobs/templates/jobs/job_detail.html | 51 ++++++++++++++ jobs/templates/jobs/job_listing.html | 46 ++++++++++++- jobs/views.py | 11 +-- 14 files changed, 310 insertions(+), 22 deletions(-) create mode 100644 jobs/management/__init__.py create mode 100644 jobs/management/commands/__init__.py create mode 100644 jobs/management/commands/unpublish_listings.py create mode 100644 jobs/migrations/0005_auto_20230610_0901.py create mode 100644 jobs/migrations/0006_job_is_published.py create mode 100644 jobs/migrations/0007_job_published_date.py create mode 100644 jobs/migrations/0008_auto_20230626_1917.py create mode 100644 jobs/migrations/0009_auto_20230626_1922.py create mode 100644 jobs/migrations/0010_auto_20230626_1924.py diff --git a/jobs/management/__init__.py b/jobs/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/jobs/management/commands/__init__.py b/jobs/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/jobs/management/commands/unpublish_listings.py b/jobs/management/commands/unpublish_listings.py new file mode 100644 index 00000000..e6f92d9f --- /dev/null +++ b/jobs/management/commands/unpublish_listings.py @@ -0,0 +1,13 @@ +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) + \ No newline at end of file diff --git a/jobs/migrations/0005_auto_20230610_0901.py b/jobs/migrations/0005_auto_20230610_0901.py new file mode 100644 index 00000000..52b043dd --- /dev/null +++ b/jobs/migrations/0005_auto_20230610_0901.py @@ -0,0 +1,24 @@ +# 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, + ), + ] diff --git a/jobs/migrations/0006_job_is_published.py b/jobs/migrations/0006_job_is_published.py new file mode 100644 index 00000000..0b499ac4 --- /dev/null +++ b/jobs/migrations/0006_job_is_published.py @@ -0,0 +1,18 @@ +# 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), + ), + ] diff --git a/jobs/migrations/0007_job_published_date.py b/jobs/migrations/0007_job_published_date.py new file mode 100644 index 00000000..9c968778 --- /dev/null +++ b/jobs/migrations/0007_job_published_date.py @@ -0,0 +1,20 @@ +# 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, + ), + ] diff --git a/jobs/migrations/0008_auto_20230626_1917.py b/jobs/migrations/0008_auto_20230626_1917.py new file mode 100644 index 00000000..87f00432 --- /dev/null +++ b/jobs/migrations/0008_auto_20230626_1917.py @@ -0,0 +1,22 @@ +# 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), + ), + ] diff --git a/jobs/migrations/0009_auto_20230626_1922.py b/jobs/migrations/0009_auto_20230626_1922.py new file mode 100644 index 00000000..2853c930 --- /dev/null +++ b/jobs/migrations/0009_auto_20230626_1922.py @@ -0,0 +1,22 @@ +# 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), + ), + ] diff --git a/jobs/migrations/0010_auto_20230626_1924.py b/jobs/migrations/0010_auto_20230626_1924.py new file mode 100644 index 00000000..5c95ad54 --- /dev/null +++ b/jobs/migrations/0010_auto_20230626_1924.py @@ -0,0 +1,24 @@ +# 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, + ), + ] diff --git a/jobs/models.py b/jobs/models.py index c3b23f8f..f845eb41 100644 --- a/jobs/models.py +++ b/jobs/models.py @@ -12,23 +12,30 @@ class Job(models.Model): ] CONTRACT_TYPE_CHOICES = [ - ('voluntary', 'Voluntary (Unpaid)'), + ('voluntary', 'Voluntary'), ('temporary', 'Temporary'), ('fixed_term_contract', 'Fixed Term Contract'), - ('part_time_permanent', 'Part-time Permanent Employed'), + ('part_time_permanent', 'Part-time Permanent'), ('full_time_permanent', 'Full-time Permanent Employed'), ] title = models.CharField(max_length=100) description = models.TextField() sector = models.CharField(max_length=20, choices=SECTOR_CHOICES) - contract_type = models.CharField(max_length=20, choices=CONTRACT_TYPE_CHOICES) + contract_type = models.CharField(max_length=40, choices=CONTRACT_TYPE_CHOICES) pay = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True) employer_name = models.CharField(max_length=100) incorporation_number = models.CharField(max_length=20, null=True, blank=True) website = models.URLField(max_length=200) expiry_date = models.DateField() application_url = models.URLField(max_length=200) + is_published = models.BooleanField(default=True) + created = models.DateTimeField(auto_now_add=True) + published_date = models.DateField(auto_now_add=True) + + + class Meta: + ordering = ['-created'] def is_expired(self): from datetime import date diff --git a/jobs/templates/jobs/create_job.html b/jobs/templates/jobs/create_job.html index 7462d3d6..b26641ec 100644 --- a/jobs/templates/jobs/create_job.html +++ b/jobs/templates/jobs/create_job.html @@ -2,9 +2,9 @@ {% block content %} - {% if form.errors %} + {% if form.errors %} {{ form.errors }} - {% endif %} + {% endif %}