blob: 09b9a2d9b55115bdecfb13026da0892862bd0e27 (
plain)
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
41
42
43
44
45
46
47
|
from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from askbot.conf import settings as askbot_settings
from askbot.models import Tag
from askbot.models.tag import get_groups
from django import forms
DEFAULT_INNER_STYLE = ''
DEFAULT_OUTER_STYLE = ''
class AskWidget(models.Model):
'''stores widgets styles and options'''
title = models.CharField(max_length=100)
group = models.ForeignKey(Tag, null=True, blank=True,
related_name='groups')
tag = models.ForeignKey(Tag, null=True, blank=True)
include_text_field = models.BooleanField(default=False, blank=True)
inner_style = models.TextField(default=DEFAULT_INNER_STYLE, blank=True)
outer_style= models.TextField(default=DEFAULT_OUTER_STYLE, blank=True)
class Meta:
app_label = 'askbot'
def __unicode__(self):
return "Widget: %s" % self.title
class CreateAskWidgetForm(forms.ModelForm):
inner_style = forms.CharField(
widget=forms.Textarea,
required=False,
initial=DEFAULT_INNER_STYLE
)
outer_style = forms.CharField(
widget=forms.Textarea,
required=False,
initial=DEFAULT_OUTER_STYLE
)
#these don't work for some reason
#group = forms.ModelChoiceField(query_set=get_groups())
#tag = forms.ModelChoiceField(query_set=Tag.objects.get_content_tags())
class Meta:
model = AskWidget
|