Commit 66e62e89 authored by Matthieu Fesselier's avatar Matthieu Fesselier

update: rename thread into conversation

parent e6cd19b5
Pipeline #3384 passed with stage
in 27 seconds
......@@ -3,8 +3,8 @@ This module is an add-on for Django REST Framework, based on Django LDP add-on.
It aims at enabling people with little development skills to serve their own data, to be used with a LDP application.
# Models
## Thread
## Conversation
A list of messages related to each others
## Message
A text sent by a member in a thread
\ No newline at end of file
A text sent by a member in a conversation
\ No newline at end of file
from django.contrib import admin
from .models import Thread, Message
from .models import Conversation, Message
admin.site.register(Thread)
admin.site.register(Conversation)
admin.site.register(Message)
import factory
from .models import Thread, Message
from .models import Conversation, Message
from django.contrib.auth.models import User
from django.db.models.signals import post_save
@factory.django.mute_signals(post_save)
class ThreadFactory(factory.django.DjangoModelFactory):
class ConversationFactory(factory.django.DjangoModelFactory):
class Meta:
model = Thread
model = Conversation
title = factory.Faker('text', max_nb_chars=250)
text = factory.Faker('paragraph', nb_sentences=3, variable_nb_sentences=True)
......@@ -19,7 +19,7 @@ class MessageFactory(factory.django.DjangoModelFactory):
class Meta:
model = Message
thread = factory.SubFactory(ThreadFactory)
conversation = factory.SubFactory(ConversationFactory)
text = factory.Faker('paragraph', nb_sentences=3, variable_nb_sentences=True)
author_user = factory.Iterator(User.objects.all())
dateCreated = factory.Faker('past_datetime')
from django.core.management.base import BaseCommand, CommandError
from djangoldp_conversation.factories import ThreadFactory, MessageFactory
from djangoldp_conversation.factories import ConversationFactory, MessageFactory
class Command(BaseCommand):
help = 'Mock data'
def add_arguments(self, parser):
parser.add_argument('--size', type=int, default=0, help='Number of thread to create')
parser.add_argument('--sizeof', type=int, default=10, help='Number of message into each thread created')
parser.add_argument('--size', type=int, default=0, help='Number of conversations to create')
parser.add_argument('--sizeof', type=int, default=10, help='Number of message into each conversation created')
def handle(self, *args, **options):
for i in range(0, options['size']):
thread = ThreadFactory.create()
MessageFactory.create_batch(options['sizeof'], thread=thread)
conversation = ConversationFactory.create()
MessageFactory.create_batch(options['sizeof'], conversation=conversation)
self.stdout.write(self.style.SUCCESS('Successful data mock install'))
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2019-05-03 03:23
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('djangoldp_conversation', '0002_auto_20190227_1041'),
]
operations = [
migrations.RenameModel(
old_name='Thread',
new_name='Conversation',
),
migrations.AlterModelOptions(
name='conversation',
options={'ordering': ['-dateCreated'], 'permissions': (('view_conversation', 'Read'), ('control_conversation', 'Control'))},
),
migrations.RenameField(
model_name='message',
old_name='thread',
new_name='conversation',
),
]
......@@ -3,7 +3,7 @@ from django.conf import settings
from django.contrib.auth.models import User
from djangoldp.models import Model
class Thread(Model):
class Conversation(Model):
title = models.TextField()
text = models.TextField(null=True)
author_user = models.ForeignKey(settings.AUTH_USER_MODEL)
......@@ -11,12 +11,12 @@ class Thread(Model):
class Meta:
permissions = (
('view_thread', 'Read'),
('control_thread', 'Control'),
('view_conversation', 'Read'),
('control_conversation', 'Control'),
)
auto_author = 'author_user'
ordering = ['-dateCreated']
container_path = "threads"
container_path = "conversations"
nested_fields = ["message_set", "author_user"]
def __str__(self):
......@@ -26,7 +26,7 @@ class Thread(Model):
class Message(Model):
dateCreated = models.DateField(auto_now_add=True)
text = models.TextField()
thread = models.ForeignKey("Thread", on_delete=models.DO_NOTHING)
conversation = models.ForeignKey("Conversation", on_delete=models.DO_NOTHING)
author_user = models.ForeignKey(settings.AUTH_USER_MODEL)
# response_to = models.ForeignKey(Member, on_delete=models.SET_NULL, related_name="response", blank=True, null=True)
......
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