From 4dfae071fb27c32b83370da0818eca5d575a4590 Mon Sep 17 00:00:00 2001 From: Eligiusz Kurzawa Date: Fri, 15 Jan 2021 19:58:42 +0100 Subject: [PATCH] 26# created update job view, template --- jobs/forms.py | 7 ++ jobs/urls.py | 2 + jobs/views.py | 14 ++- templates/jobs/single.html | 4 + templates/jobs/update.html | 120 ++++++++++++++++++++++ templates/users/employer-posted-jobs.html | 66 +----------- 6 files changed, 146 insertions(+), 67 deletions(-) create mode 100644 templates/jobs/update.html diff --git a/jobs/forms.py b/jobs/forms.py index 29fb5f9..25655b8 100644 --- a/jobs/forms.py +++ b/jobs/forms.py @@ -13,3 +13,10 @@ class ApplyJobForm(forms.ModelForm): class Meta: model = Job fields = [] + + +class UpdateJobForm(forms.ModelForm): + class Meta: + model = Job + fields = ['title', 'company', 'location', 'job_type', 'category', 'description'] + widgets = {'job_type': forms.RadioSelect} diff --git a/jobs/urls.py b/jobs/urls.py index 91aa9e2..b53ce61 100644 --- a/jobs/urls.py +++ b/jobs/urls.py @@ -7,5 +7,7 @@ urlpatterns = [ path('create-job/', CreateJobView.as_view(), name="create_job"), path('search/', SearchJobView.as_view(), name="search"), path('detail///', SingleJobView.as_view(), name="single_job"), + path('update///', UpdateJobView.as_view(), name="update_job"), + path('delete///', DeleteJobView.as_view(), name="delete_job"), path('category-detail///', CategoryDetailView.as_view(), name="category_detail"), ] diff --git a/jobs/views.py b/jobs/views.py index e82dbad..2aed01e 100644 --- a/jobs/views.py +++ b/jobs/views.py @@ -4,9 +4,9 @@ from django.db.models import Q from django.shortcuts import get_object_or_404 from django.utils.decorators import method_decorator from django.urls import reverse -from django.views.generic import TemplateView, ListView, CreateView, DetailView, UpdateView +from django.views.generic import TemplateView, ListView, CreateView, DetailView, UpdateView, DeleteView -from jobs.forms import CreateJobForm, ApplyJobForm +from jobs.forms import CreateJobForm, ApplyJobForm, UpdateJobForm from jobs.models import Job, Category @@ -107,3 +107,13 @@ class SearchJobView(ListView): context['categories'] = Category.objects.all() return context + +class UpdateJobView(SuccessMessageMixin ,UpdateView): + model = Job + template_name = 'jobs/update.html' + form_class = UpdateJobForm + success_message = "You updated your job!" + + +class DeleteJobView(SuccessMessageMixin, DeleteView): + pass diff --git a/templates/jobs/single.html b/templates/jobs/single.html index f2a416b..8a4e312 100644 --- a/templates/jobs/single.html +++ b/templates/jobs/single.html @@ -53,6 +53,10 @@ {% endif %} + {% endif %} diff --git a/templates/jobs/update.html b/templates/jobs/update.html new file mode 100644 index 0000000..8245d32 --- /dev/null +++ b/templates/jobs/update.html @@ -0,0 +1,120 @@ +{% extends 'base.html' %} +{% load static %} +{% block content %} + +
+
+
+
+ +

Update a job

+
+
+
+
+ +
+
+
+ +
+ {% if user.is_employer %} +
+ {% csrf_token %} + {% if form.errors %} + + {% endif %} + {% for field in form.visible_fields|slice:"3" %} +
+
+ + +
+
+ {% endfor %} + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ {{ form.media }} + {{ form.description }} + +
+ +
+
+ +
+
+ +
+ {% else %} +
+
+ +
+
+ {% endif %} +
+ +
+
+

Contact Info

+

Address

+

203 Fake St. Mountain View, San Francisco, California, USA

+ +

Phone

+

+1 232 3235 324

+ +

Email Address

+

[email protected]

+ +
+ +
+

More Info

+

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa ad iure porro mollitia architecto hic consequuntur. Distinctio nisi perferendis dolore, ipsa consectetur

+

Learn More

+
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/users/employer-posted-jobs.html b/templates/users/employer-posted-jobs.html index 0b4c80e..af0aedc 100644 --- a/templates/users/employer-posted-jobs.html +++ b/templates/users/employer-posted-jobs.html @@ -125,76 +125,12 @@ -
-
-
-
-
-
-
-

Search Millions of Jobs

-

A small river named Duden flows by their place and supplies.

-
-
-
-
-
-
-
-

Easy To Manage Jobs

-

A small river named Duden flows by their place and supplies.

-
-
-
-
-
-
-
-

Top Careers

-

A small river named Duden flows by their place and supplies.

-
-
-
-
-
-
-
-

Search Expert Candidates

-

A small river named Duden flows by their place and supplies.

-
-
-
-
-
-
- -
-
-
-
- Categories work wating for you -

Current Job Posts

-
-
-
- {% for category in categories %} - - {% endfor %} - -
-
-
-
Recently Added Jobs -

Recent Jobs

+

My jobs