create views for application lists

This commit is contained in:
aatish 2018-10-20 14:00:59 +05:45
parent 57d270879a
commit 7a992a44d0
5 changed files with 52 additions and 4 deletions

View file

@ -16,9 +16,9 @@
<nav class="my-2 my-md-0 mr-md-3">
<a class="p-2 text-dark" href="#">Search</a>
<a class="p-2 text-dark" href="#">Tags</a>
<a class="p-2 text-dark" href="#">Jobs</a>
<a class="p-2 text-dark" href="{% url 'jobs:job_list' %}">Jobs</a>
</nav>
<a class="btn btn-outline-primary" href="{% url 'jobs:create' %}">Post a job</a>
<a class="btn btn-outline-primary" href="{% url 'jobs:job_create' %}">Post a job</a>
</div>
<div class="container">

View file

@ -0,0 +1,31 @@
{% extends 'base.html' %}
{% block body_content %}
<div class="row">
<div class="col-md-12">
<div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="display-4">Applications</h1>
<p class="lead"></p>
</div>
{% for application in applications %}
<div class="card">
<div class="card-body">
<h4 class="card-title">
<a href="{{ application.get_absolute_url }}">Submitted by: {{ application.applicant }}</a>
</h4>
<p class="card-text">
Submitted: {{ application.created }}
</p>
<p class="card-text">
{{ application.cover_text }}
</p>
<ol>
{% for answer in application.answers.all %}
<li>{{answer.question}}<p>{{answer.text}}</p></li>
{% endfor %}
</ol>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}

View file

@ -26,6 +26,10 @@
<br/>
{% has_perm 'jobs.change_job' request.user job as can_change_job %}
{% if can_change_job %}
<a href="{% url 'jobs:job_applications' job.pk %}">
Applications ({{job.applications.count}})</span>
</a>
<form method="POST" action="{% url 'jobs:job_renew' job.pk %}">
{% csrf_token %}
<button type="submit" class="btn btn-primary">Renew Job</button>

View file

@ -6,11 +6,12 @@ from . import autocomplete as autocomplete_views
app_name = 'jobs'
urlpatterns = [
path('', views.Index.as_view(), name='index'),
path('jobs/create/', views.JobCreate.as_view(), name='create'),
path('jobs/', views.JobList.as_view(), name='list'),
path('jobs/create/', views.JobCreate.as_view(), name='job_create'),
path('jobs/', views.JobList.as_view(), name='job_list'),
path(
'jobs/<int:pk>/detail/', views.JobDetail.as_view(), name='job_detail'),
path('jobs/<int:pk>/renew/', views.JobRenew.as_view(), name='job_renew'),
path('jobs/<int:job_pk>/applications/', views.ApplicationList.as_view(), name='job_applications'),
path(
'jobs/<int:job_pk>/apply/',
views.ApplicationCreate.as_view(),

View file

@ -126,3 +126,15 @@ class ApplicationCreate(CreateView):
def form_invalid(self, form, answer_form):
return self.render_to_response(
self.get_context_data(form=form, answer_form=answer_form))
class ApplicationList(ListView):
model = Application
context_object_name = 'applications'
def get_queryset(self):
return super().get_queryset().filter(job_id=self.kwargs['job_pk'])
class ApplicationDetail(DetailView):
model = Application