diff options
-rw-r--r-- | askbot/models/widgets.py | 9 | ||||
-rw-r--r-- | askbot/skins/default/templates/list_ask_widget.html | 19 |
2 files changed, 22 insertions, 6 deletions
diff --git a/askbot/models/widgets.py b/askbot/models/widgets.py index a95c2b8c..3303eca7 100644 --- a/askbot/models/widgets.py +++ b/askbot/models/widgets.py @@ -4,6 +4,8 @@ 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 askbot.forms import FormWithHideableFields +from askbot.conf import settings as askbot_settings from django import forms DEFAULT_INNER_STYLE = '' @@ -28,7 +30,7 @@ class AskWidget(models.Model): def __unicode__(self): return "Widget: %s" % self.title -class CreateAskWidgetForm(forms.ModelForm): +class CreateAskWidgetForm(forms.ModelForm, FormWithHideableFields): inner_style = forms.CharField( widget=forms.Textarea, required=False, @@ -45,5 +47,10 @@ class CreateAskWidgetForm(forms.ModelForm): tag = forms.ModelChoiceField(queryset=Tag.objects.get_content_tags(), required=False) + def __init__(self, *args, **kwargs): + super(CreateAskWidgetForm, self).__init__(*args, **kwargs) + if not askbot_settings.GROUPS_ENABLED: + self.hide_field('group') + class Meta: model = AskWidget diff --git a/askbot/skins/default/templates/list_ask_widget.html b/askbot/skins/default/templates/list_ask_widget.html index b895bde9..27b8a20a 100644 --- a/askbot/skins/default/templates/list_ask_widget.html +++ b/askbot/skins/default/templates/list_ask_widget.html @@ -4,11 +4,20 @@ {% block content %} <h1>Ask Question widget list</h1> -{%for widget in widgets%} - <p>Widget: {{widget.title}} | <a href="{% url edit_ask_widget widget.id %}">Edit</a> | <a href="{% url delete_ask_widget widget.id %}">Delete</a> </p> - <p>Code: <script type="text/javascript" src="http://{{request.get_host()}}{% url render_ask_widget widget.id%}" ></script> -{%endfor%} - +<table border="0"> + <tr> + <th>Widget Title </th> + <th>Code</th> + <th>Actions</th> + </tr> + {%for widget in widgets%} + <tr> + <td>{{widget.title}}</td> + <td> <script type="text/javascript" src="http://{{request.get_host()}}{% url render_ask_widget widget.id%}" ></script></td> + <td><a href="{% url edit_ask_widget widget.id %}">Edit</a> | <a href="{% url delete_ask_widget widget.id %}">Delete</a></td> + </tr> + {%endfor%} +</table> {% endblock %} {% block endjs %} |