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):
|
||||
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)
|
||||
|
||||
def addToDatabase(data, file_id):
|
||||
@ -85,14 +85,17 @@ def listParagraphsFromDiscussion(id):
|
||||
message = []
|
||||
para_id = []
|
||||
label = []
|
||||
user_updated = []
|
||||
paragraphs = Paragraph.objects.filter(post_id = elem.pk)
|
||||
for paragraph in paragraphs:
|
||||
message.append(paragraph.message)
|
||||
para_id.append(paragraph.pk)
|
||||
label.append(paragraph.label)
|
||||
user_updated.append(paragraph.user_updated)
|
||||
obj['message'] = message
|
||||
obj['para_id'] = para_id
|
||||
obj['label'] = label
|
||||
obj['user_updated'] = user_updated
|
||||
posts_.append(obj)
|
||||
out['posts'] = posts_
|
||||
return(out)
|
||||
|
@ -25,4 +25,5 @@ class Post(models.Model):
|
||||
class Paragraph(models.Model):
|
||||
message = models.TextField()
|
||||
label = models.CharField(max_length=255)
|
||||
user_updated = models.BooleanField(default=False)
|
||||
post = models.ForeignKey(Post, on_delete=models.CASCADE)
|
||||
|
Loading…
Reference in New Issue
Block a user