Fix pagevote and bookmark bug for new objects
This commit is contained in:
parent
36e27321f7
commit
4ceae6d066
7 changed files with 32 additions and 44 deletions
|
@ -53,3 +53,13 @@ class MakeBookMark(models.Model):
|
|||
unique_together = ["user", "bookmark"]
|
||||
verbose_name = _("make bookmark")
|
||||
verbose_name_plural = _("make bookmarks")
|
||||
|
||||
|
||||
class Bookmarkable:
|
||||
def get_or_create_bookmark(self):
|
||||
if self.bookmark.count():
|
||||
return self.bookmark.first()
|
||||
new_bookmark = BookMark()
|
||||
new_bookmark.linked_object = self
|
||||
new_bookmark.save()
|
||||
return new_bookmark
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue