Commit e7c044f8 authored by app's avatar app

Merge local changes

parents a96a6eeb 7702b513
......@@ -23,19 +23,18 @@
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<li class="nav-item {{ application_page }} dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Applications</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="{% url 'jobs:my_applications' %}">Your applications</a>
<a class="dropdown-item" href="{% url 'jobs:applications_others' %}">Applications to your jobs</a>
<li class="nav-item">
<li class="nav-item {{ messages_page }}">
<a class="nav-link" href="{% url 'jobs:messages_inbox' %}">Messages</a>
<li class="nav-item justify-content-end">
<li class="nav-item {{ my_jobs_page }} justify-content-end">
<a class="nav-link" href="{% url 'jobs:my_jobs' %}">Your Jobs</a>
{# {% url 'jobs:job_list' %}#}
<a class="btn btn-outline-primary mx-1" href="{% url 'jobs:job_create' %}">Post a job</a>
<div class="dropdown-divider"></div>
......@@ -7,11 +7,13 @@ from django.contrib import messages
from django.shortcuts import get_object_or_404, redirect
from rules.contrib.views import PermissionRequiredMixin
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
from .models import Job, Application, Question, JobMessage
from .forms import JobForm, QuestionFormSet, ApplicationForm, AnswerForm, MessageForm
import logging
logger = logging.getLogger(__name__)
User = get_user_model()
class Index(TemplateView):
......@@ -85,7 +87,7 @@ class ApplicationCreate(LoginRequiredMixin, CreateView):
# TODO: restrict users from re-application
model = Application
form_class = ApplicationForm
success_url = reverse_lazy("jobs:index")
success_url = reverse_lazy("jobs:job_list")
def get_question_queryset(self):
# filter questions for particular job and order it so same queryset
......@@ -161,6 +163,7 @@ class ListOwnApplications(ListView):
def get_context_data(self, **kwargs):
context = super(ListOwnApplications, self).get_context_data(**kwargs)
context['title'] = 'Your Applications'
context['application_page'] = 'active'
return context
......@@ -174,11 +177,6 @@ class ListJobApplications(ListView):
def get_context_data(self, **kwargs):
context = super(ListJobApplications, self).get_context_data(**kwargs)
context['title'] = 'Applications to your jobs'
context['form'] = MessageForm
return context
class ApplicationDetail(LoginRequiredMixin, DetailView):
model = Application
......@@ -201,6 +199,7 @@ class MesssageInbox(LoginRequiredMixin, ListView):
def get_context_data(self, **kwargs):
context = super(MesssageInbox, self).get_context_data(**kwargs)
context['title'] = 'Messages Inbox'
context['messages_page'] = 'active'
return context
......@@ -220,6 +219,7 @@ class Conversation(LoginRequiredMixin, ListView):
context = super(Conversation, self).get_context_data(**kwargs)
context['form'] = MessageForm
context['person'] = User.objects.get(id=self.kwargs['pk'])
context['messages_page'] = 'active'
return context
......@@ -235,9 +235,10 @@ class MyJobs(LoginRequiredMixin, ListView):
def get_context_data(self, **kwargs):
context = super(MyJobs, self).get_context_data(**kwargs)
context['title'] = 'Your jobs'
context['my_jobs_page'] = 'active'
return context
def send_message(request):
form = MessageForm(request.POST)
if form.is_valid():
......@@ -247,16 +248,24 @@ def send_message(request):
return redirect('jobs:conversation', pk=request.POST.get('receiver_id'))
def change_status(request):
job_id = request.POST.get('job_id')
if job_id is not None:
job = Job.objects.get(id=job_id)
if = False
job_obj = Job.objects.get(id=request.POST.get('job_id'))
if job_obj.posted_by == request.user:
if = False
else: = True
else: = True
"the user {} tried to toggle the job id {}. But it doesn't belong to him".format(
request.user, request.POST.get('job_id'))
except Job.DoesNotExist:
"the user {} tried to toggle the job id {} but it doesn't exist.".format(
request.user, request.POST.get('job_id'))
return redirect('jobs:my_jobs')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment