diff --git a/jobs/models.py b/jobs/models.py
index f179685..bd9f77f 100644
--- a/jobs/models.py
+++ b/jobs/models.py
@@ -15,6 +15,9 @@ class Category(models.Model):
self.slug = slugify(self.title)
super(Category, self).save(*args, **kwargs)
+ def job_count(self):
+ return self.jobs.all().count()
+
class Job(models.Model):
title = models.CharField(max_length=300)
diff --git a/jobs/urls.py b/jobs/urls.py
index 09985ee..cdcc362 100644
--- a/jobs/urls.py
+++ b/jobs/urls.py
@@ -1,6 +1,7 @@
from django.urls import path
from .views import *
+app_name = "jobs"
urlpatterns = [
path('', HomeView.as_view(), name="home"),
]
diff --git a/jobs/views.py b/jobs/views.py
index cb57bb8..b26290f 100644
--- a/jobs/views.py
+++ b/jobs/views.py
@@ -1,6 +1,6 @@
from django.views.generic import TemplateView, ListView
-from jobs.models import Job
+from jobs.models import Job, Category
class HomeView(ListView):
@@ -8,3 +8,8 @@ class HomeView(ListView):
context_object_name = 'jobs'
model = Job
paginate_by = 1
+
+ def get_context_data(self, **kwargs):
+ context = super(HomeView, 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 59dae8e..3b5c95a 100644
--- a/templates/jobs/index.html
+++ b/templates/jobs/index.html
@@ -178,38 +178,14 @@
+ {% for category in categories %}
-
-
-
+ {% endfor %}
+
diff --git a/templates/users/user-register.html b/templates/users/user-register.html
new file mode 100644
index 0000000..6f73097
--- /dev/null
+++ b/templates/users/user-register.html
@@ -0,0 +1,75 @@
+{% extends 'base.html' %}
+{% load static %}
+{% block content %}
+
+
+
+
+
+
Home Post a Job
+
Post a Job
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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/users/forms.py b/users/forms.py
new file mode 100644
index 0000000..65625a7
--- /dev/null
+++ b/users/forms.py
@@ -0,0 +1,12 @@
+from django import forms
+from django.contrib.auth.forms import UserCreationForm
+from users.models import Account
+
+
+class AccountRegisterForm(UserCreationForm):
+ CHOICES = [('is_employee', 'Employee'), ('is_employer', 'Employer')]
+ user_types = forms.CharField(label="User Type", widget=forms.RadioSelect(choices=CHOICES))
+
+ class Meta:
+ model = Account
+ fields = ['email', 'first_name', 'last_name']
diff --git a/users/urls.py b/users/urls.py
index 06cf910..ef6fe94 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -1,6 +1,7 @@
from django.urls import path
from .views import *
+app_name = "users"
urlpatterns = [
-
+ path('register/', UserRegisterView.as_view(), name='register')
]
diff --git a/users/views.py b/users/views.py
index 91ea44a..2701f22 100644
--- a/users/views.py
+++ b/users/views.py
@@ -1,3 +1,24 @@
-from django.shortcuts import render
+from django.contrib.messages.views import SuccessMessageMixin
+from django.shortcuts import redirect
+from django.views.generic import CreateView
-# Create your views here.
+from users.forms import AccountRegisterForm
+
+
+class UserRegisterView(SuccessMessageMixin, CreateView):
+ template_name = 'users/user-register.html'
+ form_class = AccountRegisterForm
+ success_url = '/'
+ success_message = "Your user account has been created."
+
+ def form_valid(self, form):
+ user = form.save(commit=False)
+ user_type = form.cleaned_data['user_types']
+ if user_type == 'is_employee':
+ user.is_employee = True
+ elif user_type == 'is_employer':
+ user.is_employer = True
+
+ user.save()
+
+ return redirect(self.success_url)