From f36ec6147bfd52027c6549e71f178eb47e43f61d Mon Sep 17 00:00:00 2001 From: Eligiusz Kurzawa Date: Wed, 13 Jan 2021 20:24:06 +0100 Subject: [PATCH] 14# created job detail page --- jobs/models.py | 4 ++-- jobs/urls.py | 1 + jobs/views.py | 13 ++++++++++- templates/jobs/index.html | 2 +- templates/jobs/single.html | 48 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 templates/jobs/single.html diff --git a/jobs/models.py b/jobs/models.py index bd9f77f..fb7006c 100644 --- a/jobs/models.py +++ b/jobs/models.py @@ -2,7 +2,7 @@ from django.db import models from django.template.defaultfilters import slugify from jobportal import settings - +from ckeditor.fields import RichTextField class Category(models.Model): title = models.CharField(max_length=100) @@ -32,7 +32,7 @@ class Job(models.Model): job_type = models.CharField(max_length=20, blank=False, default=None, choices=CHOICES) location = models.CharField(max_length=200, blank=False, default=None) - description = models.TextField(blank=False, default=None) + description = RichTextField(blank=False, default=None) publishing_date = models.DateTimeField(auto_now_add=True) slug = models.SlugField(default=None, editable=False) employer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, default=None) diff --git a/jobs/urls.py b/jobs/urls.py index c249e42..775f526 100644 --- a/jobs/urls.py +++ b/jobs/urls.py @@ -5,4 +5,5 @@ app_name = "jobs" urlpatterns = [ path('', HomeView.as_view(), name="home"), path('create-job/', CreateJobView.as_view(), name="create_job"), + path('detail///', SingleJobView.as_view(), name="single_job"), ] diff --git a/jobs/views.py b/jobs/views.py index c5b7b11..56ada04 100644 --- a/jobs/views.py +++ b/jobs/views.py @@ -2,7 +2,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.messages.views import SuccessMessageMixin from django.utils.decorators import method_decorator -from django.views.generic import TemplateView, ListView, CreateView +from django.views.generic import TemplateView, ListView, CreateView, DetailView from jobs.forms import CreateJobForm from jobs.models import Job, Category @@ -33,3 +33,14 @@ class CreateJobView(SuccessMessageMixin, CreateView): job.employer = self.request.user job.save() return super(CreateJobView, self).form_valid(form) + + +class SingleJobView(DetailView): + template_name = 'jobs/single.html' + model = Job + context_object_name = 'job' + + def get_context_data(self, **kwargs): + context = super(SingleJobView, self).get_context_data(**kwargs) + context['categories'] = Category.objects.all() + return context diff --git a/templates/jobs/index.html b/templates/jobs/index.html index 3b5c95a..e014548 100644 --- a/templates/jobs/index.html +++ b/templates/jobs/index.html @@ -227,7 +227,7 @@
- Apply Job + Apply Job diff --git a/templates/jobs/single.html b/templates/jobs/single.html new file mode 100644 index 0000000..e6714e6 --- /dev/null +++ b/templates/jobs/single.html @@ -0,0 +1,48 @@ +{% extends 'base.html' %} +{% load static %} +{% block content %} + +
+
+
+
+ +

Job detail

+
+
+
+
+ +
+
+
+
+

{{ job.title }}

+

{{ job.description|safe }}

+ +
+ + +
+
+
+ +{% endblock %} \ No newline at end of file