forked from django-cms/djangocms-versioning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
40 lines (26 loc) · 958 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from cms.models import CMSPlugin
from django.db import models
from django.urls import reverse
class Poll(models.Model):
name = models.TextField()
def __str__(self):
return f"{self.name} ({self.pk})"
class PollContent(models.Model):
poll = models.ForeignKey(Poll, on_delete=models.CASCADE)
language = models.TextField()
text = models.TextField()
def __str__(self):
return self.text
def get_absolute_url(self):
return reverse("admin:polls_pollcontent_changelist")
def get_preview_url(self):
return reverse("admin:polls_pollcontent_preview", args=[self.id])
class Answer(models.Model):
poll_content = models.ForeignKey(PollContent, on_delete=models.CASCADE)
text = models.TextField()
def __str__(self):
return self.text
class PollPlugin(CMSPlugin):
poll = models.ForeignKey(Poll, on_delete=models.CASCADE)
def __str__(self):
return str(self.poll)