Database schema updated, PATCH /discussions/:id + user_updated

This commit is contained in:
Marcin Armacki 2020-06-30 15:33:57 +02:00
parent 54811beda8
commit bc098077cf
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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)