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
|
@ -48,3 +48,13 @@ class PageVoteVoter(models.Model):
|
|||
unique_together = ["voter", "pagevote"]
|
||||
verbose_name = _("pagevote vote")
|
||||
verbose_name_plural = _("pagevote votes")
|
||||
|
||||
|
||||
class PageVotable:
|
||||
def get_or_create_pagevote(self):
|
||||
if self.pagevote.count():
|
||||
return self.pagevote.first()
|
||||
new_pagevote = PageVote()
|
||||
new_pagevote.linked_object = self
|
||||
new_pagevote.save()
|
||||
return new_pagevote
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue