Ensure unique tags
This commit is contained in:
parent
b301496421
commit
73df5f3579
1 changed files with 11 additions and 2 deletions
|
@ -187,7 +187,16 @@ def add_new():
|
|||
quote = Quote(quote_body, request.remote_addr, timestamp())
|
||||
quote_tags = [Tag(tag) for tag in quote_tags]
|
||||
|
||||
quote.tags.extend(quote_tags)
|
||||
for tag in quote_tags:
|
||||
dbtag = Tag.query.filter_by(name=tag.name).first()
|
||||
print(dbtag)
|
||||
print(dbtag.name)
|
||||
print(dbtag.id)
|
||||
if dbtag is not None:
|
||||
quote.tags.append(dbtag)
|
||||
else:
|
||||
quote.tags.append(tag)
|
||||
#quote.tags.extend(quote_tags)
|
||||
|
||||
db.session.add(quote)
|
||||
db.session.commit()
|
||||
|
|
Loading…
Add table
Reference in a new issue