Commit 426f510a authored by smilin_desperado's avatar smilin_desperado

Filter jobs by user

parent b6e9328f
......@@ -21,6 +21,9 @@ class IndexView(LoginRequiredMixin, ListView):
context['form'] = form
return context
def get_queryset(self):
return Job.objects.filter(user=self.request.user)
@login_required()
def add(request):
if request.method == 'POST':
......@@ -48,6 +51,9 @@ class EditView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
success_url = reverse_lazy('tracker:index')
success_message = "%(position_title)s was successfully updated"
def get_queryset(self):
return super().get_queryset().filter(user=self.request.user)
class DeleteJobView(LoginRequiredMixin, DeleteView):
model = Job
template_name = 'tracker/delete.html'
......@@ -57,4 +63,7 @@ class DeleteJobView(LoginRequiredMixin, DeleteView):
def delete(self, request, *args, **kwargs):
messages.success(self.request, self.success_message)
return super(DeleteJobView, self).delete(request, *args, **kwargs)
def get_queryset(self):
return super().get_queryset().filter(user=self.request.user)
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