Commit 5d06fd5d authored by Jean-Baptiste's avatar Jean-Baptiste

update: use the framework Model and urls

parent 08297756
Pipeline #2813 passed with stage
in 27 seconds
...@@ -3,6 +3,7 @@ from .models import JobOffer ...@@ -3,6 +3,7 @@ from .models import JobOffer
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db.models.signals import post_save from django.db.models.signals import post_save
@factory.django.mute_signals(post_save) @factory.django.mute_signals(post_save)
class JobOfferFactory(factory.django.DjangoModelFactory): class JobOfferFactory(factory.django.DjangoModelFactory):
class Meta: class Meta:
......
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db import models from django.db import models
from djangoldp.models import Model
from djangoldp_skill.models import Skill from djangoldp_skill.models import Skill
class JobOffer(models.Model): class JobOffer(Model):
author = models.ForeignKey(User, on_delete=models.CASCADE) author = models.ForeignKey(User, on_delete=models.CASCADE)
title = models.CharField(max_length=255, blank=True, null=True) title = models.CharField(max_length=255, blank=True, null=True)
description = models.CharField(max_length=255, blank=True, null=True) description = models.CharField(max_length=255, blank=True, null=True)
...@@ -14,10 +15,8 @@ class JobOffer(models.Model): ...@@ -14,10 +15,8 @@ class JobOffer(models.Model):
class Meta: class Meta:
auto_author = 'author' auto_author = 'author'
permissions = ( nested_fields = ["skills"]
('view_joboffer', 'Read'), container_path = 'job-offers/'
('control_joboffer', 'Control'),
)
def __str__(self): def __str__(self):
return '{} ({})'.format(self.title, self.author.get_full_name()) return '{} ({})'.format(self.title, self.author.get_full_name())
"""djangoldp joboffer URL Configuration"""
from django.conf.urls import url
from djangoldp.views import LDPViewSet
from .models import JobOffer
urlpatterns = [
url(r'^job-offers/', LDPViewSet.urls(model=JobOffer, nested_fields=["skills"])),
]
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