def clean_text(self): text = self.cleaned_data["text"] if self.instance and self.instance.id: context = None if self.instance == self.event.update_template: context = {"notifications": "test", "event_name": "test"} elif self.instance == self.event.question_template: context = { "questions": "test", "event_name": "test", "url": "test" } elif self.instance in self.instance.event.fixed_templates: context = { item["name"]: "test" for item in get_context_explanation() } if context: try: for language, local_text in text.data.items(): local_text.format(**context) except KeyError as e: raise forms.ValidationError( ('Unknown template key: "{key}", locale: {locale}' ).format(key=e.args[0], locale=language)) return text
def placeholders(self): template = self.object if template and template in template.event.fixed_templates: result = get_context_explanation() if template == template.event.update_template: result = [ item for item in result if item["name"] == "event_name" ] result.append({ "name": "notifications", "explanation": _("A list of notifications for this speaker"), }) elif template == template.event.question_template: result = [ item for item in result if item["name"] in ["event_name"] ] result.append({ "name": "url", "explanation": _("The link to the user's list of proposals"), }) result.append({ "name": "questions", "explanation": _("The list of questions that the user has not answered, as bullet points" ), }) return result return None
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) template = self.object if template and template in template.event.fixed_templates: context['placeholders'] = get_context_explanation() if template == template.event.update_template: context['placeholders'].append({ 'name': 'notifications', 'explanation': _('A list of notifications for this speaker'), }) return context
def placeholders(self): template = self.object if template and template in template.event.fixed_templates: result = get_context_explanation() if template == template.event.update_template: result.append({ "name": "notifications", "explanation": _("A list of notifications for this speaker"), }) return result return None
def placeholders(self): template = self.object if template and template in template.event.fixed_templates: result = get_context_explanation() if template == template.event.update_template: result.append({ 'name': 'notifications', 'explanation': _('A list of notifications for this speaker'), }) return result return None
def clean_text(self): text = self.cleaned_data['text'] if self.instance and self.instance.id: _is_template_with_submission_context = self.instance in [ t for t in self.instance.event.fixed_templates if t != self.event.update_template ] if _is_template_with_submission_context: context = {item['name']: 'test' for item in get_context_explanation()} try: for language, local_text in text.data.items(): local_text.format(**context) except KeyError as e: msg = _('Unknown template key: "{key}", locale: {locale}').format(key=e.args[0], locale=language) raise forms.ValidationError(msg) return text
def get_context_data(self, *args, **kwargs): ctx = super().get_context_data(*args, **kwargs) obj = self.get_object() if obj and obj in obj.event.fixed_templates: ctx['placeholders'] = get_context_explanation() return ctx
def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) template = self.object if template and template in template.event.fixed_templates: context['placeholders'] = get_context_explanation() return context
def get_context_data(self): ctx = super().get_context_data() ctx['placeholders'] = get_context_explanation() return ctx