6# added user registration
This commit is contained in:
parent
6a0da8cced
commit
afa12d3357
@ -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)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.urls import path
|
||||
from .views import *
|
||||
|
||||
app_name = "jobs"
|
||||
urlpatterns = [
|
||||
path('', HomeView.as_view(), name="home"),
|
||||
]
|
||||
|
@ -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
|
||||
|
@ -178,38 +178,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{% for category in categories %}
|
||||
<div class="col-md-3 ftco-animate">
|
||||
<ul class="category">
|
||||
<li><a href="#">Web Development <span class="number" data-number="1000">0</span></a></li>
|
||||
<li><a href="#">Graphic Designer <span class="number" data-number="1000">0</span></a></li>
|
||||
<li><a href="#">Multimedia <span class="number" data-number="2000">0</span></a></li>
|
||||
<li><a href="#">Advertising <span class="number" data-number="900">0</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-3 ftco-animate">
|
||||
<ul class="category">
|
||||
<li><a href="#">Education & Training <span class="number" data-number="3500">0</span></a></li>
|
||||
<li><a href="#">English <span class="number" data-number="1560">0</span></a></li>
|
||||
<li><a href="#">Social Media <span class="number" data-number="1000">0</span></a></li>
|
||||
<li><a href="#">Writing <span class="number" data-number="2500">0</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-3 ftco-animate">
|
||||
<ul class="category">
|
||||
<li><a href="#">PHP Programming <span class="number" data-number="5500">0</span></a></li>
|
||||
<li><a href="#">Project Management <span class="number" data-number="2000">0</span></a></li>
|
||||
<li><a href="#">Finance Management <span class="number" data-number="800">0</span></a></li>
|
||||
<li><a href="#">Office & Admin <span class="number" data-number="7000">0</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-3 ftco-animate">
|
||||
<ul class="category">
|
||||
<li><a href="#">Web Designer <span><span class="number" data-number="8000">0</span></span></a></li>
|
||||
<li><a href="#">Customer Service <span class="number" data-number="4000">0</span></a></li>
|
||||
<li><a href="#">Marketing & Sales <span class="number" data-number="3300">0</span></a></li>
|
||||
<li><a href="#">Software Development <span class="number" data-number="1356">0</span></a></li>
|
||||
<li><a href="#">{{ category.title }}<span class="number" data-number="{{ category.job_count }}">0</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
75
templates/users/user-register.html
Normal file
75
templates/users/user-register.html
Normal file
@ -0,0 +1,75 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
|
||||
<div class="hero-wrap js-fullheight" style="background-image: url('{% static 'images/bg_2.jpg' %}');" data-stellar-background-ratio="0.5"> <div class="overlay"></div>
|
||||
<div class="container">
|
||||
<div class="row no-gutters slider-text js-fullheight align-items-end justify-content-start" data-scrollax-parent="true">
|
||||
<div class="col-md-8 ftco-animate text-center text-md-left mb-5" data-scrollax=" properties: { translateY: '70%' }">
|
||||
<p class="breadcrumbs" data-scrollax="properties: { translateY: '30%', opacity: 1.6 }"><span class="mr-3"><a href="index.html">Home <i class="ion-ios-arrow-forward"></i></a></span> <span>Post a Job</span></p>
|
||||
<h1 class="mb-3 bread" data-scrollax="properties: { translateY: '30%', opacity: 1.6 }">Post a Job</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ftco-section bg-light">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12 col-lg-8 mb-5">
|
||||
<form action="#" class="p-5 bg-white" method="post">
|
||||
{% csrf_token %}
|
||||
{% for field in form.visible_fields|slice:"5" %}
|
||||
<div class="row form-group">
|
||||
<div class="col-md-12 mb-3 mb-md-0">
|
||||
<label class="font-weight-bold" for="fullname">{{ field.label }}</label>
|
||||
<input type="{{ field.field.widget.input_type }}" id="fullname" class="form-control" placeholder="{{ field.label }}" name="{{ field.html_name }}">
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="row form-group">
|
||||
<div class="col-md-12">
|
||||
<label class="font-weight-bold" for="fullname">User type</label>
|
||||
</div>
|
||||
<div class="col-md-12 mb-3 mb-md-0">
|
||||
<label for="option-job-type-1">
|
||||
{{ form.user_types }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row form-group">
|
||||
<div class="col-md-12">
|
||||
<input type="submit" value="Register" class="btn btn-primary py-2 px-5">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="p-4 mb-3 bg-white">
|
||||
<h3 class="h5 text-black mb-3">Contact Info</h3>
|
||||
<p class="mb-0 font-weight-bold">Address</p>
|
||||
<p class="mb-4">203 Fake St. Mountain View, San Francisco, California, USA</p>
|
||||
|
||||
<p class="mb-0 font-weight-bold">Phone</p>
|
||||
<p class="mb-4"><a href="#">+1 232 3235 324</a></p>
|
||||
|
||||
<p class="mb-0 font-weight-bold">Email Address</p>
|
||||
<p class="mb-0"><a href="#"><span class="__cf_email__" data-cfemail="671e081215020a060e0b2703080a060e094904080a">[email protected]</span></a></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="p-4 mb-3 bg-white">
|
||||
<h3 class="h5 text-black mb-3">More Info</h3>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa ad iure porro mollitia architecto hic consequuntur. Distinctio nisi perferendis dolore, ipsa consectetur</p>
|
||||
<p><a href="#" class="btn btn-primary py-2 px-4">Learn More</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
12
users/forms.py
Normal file
12
users/forms.py
Normal file
@ -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']
|
@ -1,6 +1,7 @@
|
||||
from django.urls import path
|
||||
from .views import *
|
||||
|
||||
app_name = "users"
|
||||
urlpatterns = [
|
||||
|
||||
path('register/', UserRegisterView.as_view(), name='register')
|
||||
]
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user