From 66e62e89d4f3410ef203beee07fa42ec7206a885 Mon Sep 17 00:00:00 2001 From: Matthieu Fesselier Date: Fri, 3 May 2019 10:28:07 +0700 Subject: [PATCH] update: rename thread into conversation --- README.md | 4 +-- djangoldp_conversation/admin.py | 4 +-- djangoldp_conversation/factories.py | 8 +++--- .../management/commands/mock_conversation.py | 10 +++---- .../migrations/0003_auto_20190503_0323.py | 28 +++++++++++++++++++ djangoldp_conversation/models.py | 10 +++---- 6 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 djangoldp_conversation/migrations/0003_auto_20190503_0323.py diff --git a/README.md b/README.md index 1590012..8f2b41f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/djangoldp_conversation/admin.py b/djangoldp_conversation/admin.py index 34893ee..51e1921 100644 --- a/djangoldp_conversation/admin.py +++ b/djangoldp_conversation/admin.py @@ -1,5 +1,5 @@ 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) diff --git a/djangoldp_conversation/factories.py b/djangoldp_conversation/factories.py index c6014ed..104c256 100644 --- a/djangoldp_conversation/factories.py +++ b/djangoldp_conversation/factories.py @@ -1,12 +1,12 @@ 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') diff --git a/djangoldp_conversation/management/commands/mock_conversation.py b/djangoldp_conversation/management/commands/mock_conversation.py index bc21568..4a367f1 100644 --- a/djangoldp_conversation/management/commands/mock_conversation.py +++ b/djangoldp_conversation/management/commands/mock_conversation.py @@ -1,16 +1,16 @@ 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')) diff --git a/djangoldp_conversation/migrations/0003_auto_20190503_0323.py b/djangoldp_conversation/migrations/0003_auto_20190503_0323.py new file mode 100644 index 0000000..d4ba266 --- /dev/null +++ b/djangoldp_conversation/migrations/0003_auto_20190503_0323.py @@ -0,0 +1,28 @@ +# -*- 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', + ), + ] diff --git a/djangoldp_conversation/models.py b/djangoldp_conversation/models.py index 5005769..5cb56b7 100644 --- a/djangoldp_conversation/models.py +++ b/djangoldp_conversation/models.py @@ -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) -- 2.22.2