def render(self, request): context_instance = RequestContext(request) return render_to_string('smartsnippets/widgets/textfield/widget.html', {'field': self.variable}, context_instance=context_instance) class TextAreaField(SmartSnippetWidgetBase): name = 'TextArea Field' def render(self, request): context_instance = RequestContext(request) return render_to_string('smartsnippets/widgets/textareafield/widget.html', {'field': self.variable}, context_instance=context_instance) class DropDownField(SmartSnippetWidgetBase): name = 'DropDown Field' model = DropDownVariable def render(self, request): context_instance = RequestContext(request) return render_to_string('smartsnippets/widgets/dropdownfield/widget.html', {'field': self.variable}, context_instance=context_instance) widget_pool.register_widget(TextField) widget_pool.register_widget(TextAreaField) widget_pool.register_widget(DropDownField)
class DropDownField(SmartSnippetWidgetBase): name = 'DropDown Field' model = DropDownVariable template = 'smartsnippets/widgets/dropdownfield/widget.html' class SwitcherField(SmartSnippetWidgetBase): name = 'Switcher Field' template = 'smartsnippets/widgets/switcherfield/widget.html' class JSONField(TextField): name = 'JSON Field' @property def formatted_value(self): try: return json.loads( self.variable.value or '{}', object_pairs_hook=collections.OrderedDict ) except ValueError: pass return {} widget_pool.register_widget(TextField) widget_pool.register_widget(TextAreaField) widget_pool.register_widget(DropDownField) widget_pool.register_widget(SwitcherField) widget_pool.register_widget(JSONField)
class SwitcherField(SmartSnippetWidgetBase): name = 'Switcher Field' template = 'smartsnippets/widgets/switcherfield/widget.html' class URLField(SmartSnippetWidgetBase): name = 'URL Field' template = 'smartsnippets/widgets/urlfield/widget.html' class JSONField(TextField): name = 'JSON Field' @property def formatted_value(self): try: return json.loads(self.variable.value or '{}', object_pairs_hook=collections.OrderedDict) except ValueError: pass return {} widget_pool.register_widget(TextField) widget_pool.register_widget(TextAreaField) widget_pool.register_widget(DropDownField) widget_pool.register_widget(SwitcherField) widget_pool.register_widget(URLField) widget_pool.register_widget(JSONField)