Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Djangoldp Conversations
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Startin blox
djangoldp-packages
Djangoldp Conversations
Commits
66e62e89
Commit
66e62e89
authored
May 03, 2019
by
Matthieu Fesselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: rename thread into conversation
parent
e6cd19b5
Pipeline
#3384
passed with stage
in 27 seconds
Changes
6
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
18 deletions
+46
-18
README.md
README.md
+2
-2
djangoldp_conversation/admin.py
djangoldp_conversation/admin.py
+2
-2
djangoldp_conversation/factories.py
djangoldp_conversation/factories.py
+4
-4
djangoldp_conversation/management/commands/mock_conversation.py
...ldp_conversation/management/commands/mock_conversation.py
+5
-5
djangoldp_conversation/migrations/0003_auto_20190503_0323.py
djangoldp_conversation/migrations/0003_auto_20190503_0323.py
+28
-0
djangoldp_conversation/models.py
djangoldp_conversation/models.py
+5
-5
No files found.
README.md
View file @
66e62e89
...
...
@@ -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
djangoldp_conversation/admin.py
View file @
66e62e89
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
)
djangoldp_conversation/factories.py
View file @
66e62e89
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
Thread
Factory
(
factory
.
django
.
DjangoModelFactory
):
class
Conversation
Factory
(
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
(
Thread
Factory
)
conversation
=
factory
.
SubFactory
(
Conversation
Factory
)
text
=
factory
.
Faker
(
'paragraph'
,
nb_sentences
=
3
,
variable_nb_sentences
=
True
)
author_user
=
factory
.
Iterator
(
User
.
objects
.
all
())
dateCreated
=
factory
.
Faker
(
'past_datetime'
)
djangoldp_conversation/management/commands/mock_conversation.py
View file @
66e62e89
from
django.core.management.base
import
BaseCommand
,
CommandError
from
djangoldp_conversation.factories
import
Thread
Factory
,
MessageFactory
from
djangoldp_conversation.factories
import
Conversation
Factory
,
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
=
Thread
Factory
.
create
()
MessageFactory
.
create_batch
(
options
[
'sizeof'
],
thread
=
thread
)
conversation
=
Conversation
Factory
.
create
()
MessageFactory
.
create_batch
(
options
[
'sizeof'
],
conversation
=
conversation
)
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'Successful data mock install'
))
djangoldp_conversation/migrations/0003_auto_20190503_0323.py
0 → 100644
View file @
66e62e89
# -*- 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'
,
),
]
djangoldp_conversation/models.py
View file @
66e62e89
...
...
@@ -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
=
"
thread
s"
container_path
=
"
conversation
s"
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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment