Commit 912a2272 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

fix: user through nested_field

parent 3ec8ed02
Pipeline #3594 passed with stage
in 28 seconds
from django.conf.urls import url
from .views import JobOffersViewset, JobOffersCurrentViewset, \
JobOffersExpiredViewset, JobOffersSelfViewset, \
JobOffersOwnedViewset
JobOffersExpiredViewset
urlpatterns = [
url(r'^job-offers/current/', JobOffersCurrentViewset.urls()),
url(r'^job-offers/expired/', JobOffersExpiredViewset.urls()),
url(r'^job-offers/self/', JobOffersSelfViewset.urls()),
url(r'^users/(?P<id>[0-9]*)/job-offers/', JobOffersOwnedViewset.urls()),
# Dirty fix for bad id change to job-offers/self/
url(r'^job-offers/', JobOffersViewset.urls()),
]
......@@ -6,7 +6,7 @@ from djangoldp_skill.models import Skill
class JobOffer(Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
author = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='jobOffers', on_delete=models.CASCADE)
title = models.CharField(max_length=255, blank=True, null=True)
description = models.CharField(max_length=255, blank=True, null=True)
skills = models.ManyToManyField(Skill, blank=True)
......
USER_NESTED_FIELDS = ['jobOffers']
\ No newline at end of file
......@@ -19,24 +19,6 @@ class JobOffersExpiredViewset(LDPViewSet):
.filter(closingDate__lte=datetime.now())
class JobOffersSelfViewset(LDPViewSet):
model = JobOffer
def get_queryset(self):
if self.request.user.is_authenticated():
return super().get_queryset() \
.filter(author=self.request.user.id)
raise Exception("User is not authentificated")
class JobOffersOwnedViewset(LDPViewSet):
model = JobOffer
def get_queryset(self):
return super().get_queryset() \
.filter(author=self.kwargs['id'])
# Dirty fix for bad id change to job-offers/self/
class JobOffersViewset(LDPViewSet):
model = JobOffer
......
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