Commit e6cd19b5 authored by Matthieu Fesselier's avatar Matthieu Fesselier

Merge branch 'update/remove-urls-py' into 'master'

update: remove #4

Closes #4

See merge request !6
parents 00d0fc2d d652d0ba
Pipeline #3127 passed with stage
in 27 seconds
from django.db import models
from django.conf import settings
from django.contrib.auth.models import User
from djangoldp.models import Model
class Thread(models.Model):
class Thread(Model):
title = models.TextField()
text = models.TextField(null=True)
author_user = models.ForeignKey(settings.AUTH_USER_MODEL)
......@@ -15,12 +16,14 @@ class Thread(models.Model):
auto_author = 'author_user'
ordering = ['-dateCreated']
container_path = "threads"
nested_fields = ["message_set", "author_user"]
def __str__(self):
return '{}'.format(self.title)
class Message(models.Model):
class Message(Model):
dateCreated = models.DateField(auto_now_add=True)
text = models.TextField()
thread = models.ForeignKey("Thread", on_delete=models.DO_NOTHING)
......@@ -34,6 +37,8 @@ class Message(models.Model):
auto_author = 'author_user'
ordering = ['dateCreated']
container_path = "messages"
nested_fields = ["author_user"]
def __str__(self):
return '{}, le {}'.format(self.text, self.dateCreated)
\ No newline at end of file
"""djangoldp_conversation URL Configuration"""
from django.conf.urls import url
from .models import Message, Thread
from djangoldp.views import LDPViewSet
urlpatterns = [
url(r'^threads/', LDPViewSet.urls(model=Thread, nested_fields=["message_set", "author_user"])),
url(r'^messages/', LDPViewSet.urls(model=Message, nested_fields=["author_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