Database schema updated, PATCH /discussions/:id + user_updated
This commit is contained in:
parent
54811beda8
commit
bc098077cf
@ -34,7 +34,7 @@ def createLabels(data):
|
|||||||
|
|
||||||
def updateLabelsByParagraphId(data):
|
def updateLabelsByParagraphId(data):
|
||||||
for paragraph_ in data:
|
for paragraph_ in data:
|
||||||
Paragraph.objects.filter(pk = paragraph_['id']).update(label = paragraph_['label'])
|
Paragraph.objects.filter(pk = paragraph_['id']).update(label = paragraph_['label'], user_updated = True)
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
def addToDatabase(data, file_id):
|
def addToDatabase(data, file_id):
|
||||||
@ -85,14 +85,17 @@ def listParagraphsFromDiscussion(id):
|
|||||||
message = []
|
message = []
|
||||||
para_id = []
|
para_id = []
|
||||||
label = []
|
label = []
|
||||||
|
user_updated = []
|
||||||
paragraphs = Paragraph.objects.filter(post_id = elem.pk)
|
paragraphs = Paragraph.objects.filter(post_id = elem.pk)
|
||||||
for paragraph in paragraphs:
|
for paragraph in paragraphs:
|
||||||
message.append(paragraph.message)
|
message.append(paragraph.message)
|
||||||
para_id.append(paragraph.pk)
|
para_id.append(paragraph.pk)
|
||||||
label.append(paragraph.label)
|
label.append(paragraph.label)
|
||||||
|
user_updated.append(paragraph.user_updated)
|
||||||
obj['message'] = message
|
obj['message'] = message
|
||||||
obj['para_id'] = para_id
|
obj['para_id'] = para_id
|
||||||
obj['label'] = label
|
obj['label'] = label
|
||||||
|
obj['user_updated'] = user_updated
|
||||||
posts_.append(obj)
|
posts_.append(obj)
|
||||||
out['posts'] = posts_
|
out['posts'] = posts_
|
||||||
return(out)
|
return(out)
|
||||||
|
@ -25,4 +25,5 @@ class Post(models.Model):
|
|||||||
class Paragraph(models.Model):
|
class Paragraph(models.Model):
|
||||||
message = models.TextField()
|
message = models.TextField()
|
||||||
label = models.CharField(max_length=255)
|
label = models.CharField(max_length=255)
|
||||||
|
user_updated = models.BooleanField(default=False)
|
||||||
post = models.ForeignKey(Post, on_delete=models.CASCADE)
|
post = models.ForeignKey(Post, on_delete=models.CASCADE)
|
||||||
|
Loading…
Reference in New Issue
Block a user