Merge local changes

This commit is contained in:
app 2020-09-02 14:35:01 +00:00
commit e7c044f87b
2 changed files with 30 additions and 22 deletions

View file

@ -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>
</ul>
</li>
<li class="nav-item">
<li class="nav-item {{ messages_page }}">
<a class="nav-link" href="{% url 'jobs:messages_inbox' %}">Messages</a>
</li>
<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' %}#}
</li>
<a class="btn btn-outline-primary mx-1" href="{% url 'jobs:job_create' %}">Post a job</a>
<div class="dropdown-divider"></div>

View file

@ -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
@login_required()
def send_message(request):
form = MessageForm(request.POST)
if form.is_valid():
@ -247,16 +248,24 @@ def send_message(request):
print("Error")
return redirect('jobs:conversation', pk=request.POST.get('receiver_id'))
@login_required()
def change_status(request):
print(request.POST)
job_id = request.POST.get('job_id')
if job_id is not None:
job = Job.objects.get(id=job_id)
if job.active:
job.active = False
try:
job_obj = Job.objects.get(id=request.POST.get('job_id'))
if job_obj.posted_by == request.user:
if job_obj.active:
job_obj.active = False
else:
job_obj.active = True
job_obj.save()
else:
job.active = True
job.save()
else:
print("Error")
logger.error(
"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:
logger.error(
"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')