def process_preview(self, request, form, context): context['newsitem'] = form.save(commit=False) context['newsitem'].body_html = convert_text_to_html(form.cleaned_data['body'], "bbcode") context['newsitem'].body_html = smiles(context['newsitem'].body_html ) context['newsitem'].submitter_username = request.user.username context['newsitem'].post_time = datetime.now() print "Form Valid?: ", form.is_valid()
def save(self, commit=True): profile = super(PersonalityProfileForm, self).save(commit=False) profile.signature_html = convert_text_to_html(profile.signature, self.profile) if forum_settings.SMILES_SUPPORT: profile.signature_html = smiles(profile.signature_html) if commit: profile.save() return profile
def test_smiles(self): smiled_data = smiles(self.data_smiles) self.assertEqual( smiled_data, u'Lorem ipsum dolor <img src="{0}djangobb_forum/img/smilies/neutral.png" /> sit amet <img src="{0}djangobb_forum/img/smilies/smile.png" /> <a href="http://djangobb.org/">http://djangobb.org/</a>'.format( settings.STATIC_URL ), )
def post_preview(request): """Preview for markitup""" markup = request.user.forum_profile.markup data = request.POST.get("data", "") data = convert_text_to_html(data, markup) if forum_settings.SMILES_SUPPORT: data = smiles(data) return render(request, "djangobb_forum/post_preview.html", {"data": data})
def post_preview(request): '''Preview for markitup''' markup = request.user.forum_profile.markup data = request.POST.get('data', '') data = convert_text_to_html(data, markup) if forum_settings.SMILES_SUPPORT: data = smiles(data) return render(request, 'djangobb_forum/post_preview.html', {'data': data})
def save(self, *args, **kwargs): if self.markup == 'bbcode': self.body_html = bbmarkup.bbcode(self.body) elif self.markup == 'markdown' and MARKDOWN_AVAILABLE: self.body_html = unicode(Markdown(self.body, safe_mode='escape')) #self.body_html = markdown(self.body, 'safe') else: raise Exception('Invalid markup property: %s' % self.markup) self.body_html = urlize(self.body_html) if forum_settings.SMILES_SUPPORT and self.user.forum_profile.show_smilies: self.body_html = smiles(self.body_html) super(Post, self).save(*args, **kwargs)
def post_preview(request): '''Preview for markitup''' data = request.POST.get('data', '') try: data = convert_text_to_html(data, request.user.forum_profile) except UnapprovedImageError as e: return render(request, 'djangobb_forum/post_preview.html', {'data': e.user_error()}) if forum_settings.SMILES_SUPPORT: data = smiles(data) return render(request, 'djangobb_forum/post_preview.html', {'data': data})
def post_preview(request): '''Preview for markitup''' data = request.POST.get('data', '') try: data = convert_text_to_html(data, request.user.forum_profile) except UnapprovedImageError as e: return render(request, 'djangobb_forum/post_preview.html', { 'data': e.user_error() }) if forum_settings.SMILES_SUPPORT: data = smiles(data) return render(request, 'djangobb_forum/post_preview.html', {'data': data})
def post_preview(request): '''Preview for markitup''' markup = request.user.forum_profile.markup data = request.POST.get('data', '') if markup == 'bbcode': data = bbmarkup.bbcode(data) elif markup == 'markdown' and MARKDOWN_AVAILABLE: data = unicode(Markdown(data, safe_mode='escape')) else: raise Exception('Invalid markup property: %s' % markup) data = urlize(data) if forum_settings.SMILES_SUPPORT: data = smiles(data) return {'data': data}
def save(self, *args, **kwargs): self.body_html = convert_text_to_html(self.body, "bbcode") self.body_html = smiles(self.body_html) super(NewsItem, self).save(*args, **kwargs)
def test_smiles(self): smiled_data = smiles(self.data_smiles) self.assertEqual(smiled_data, u"Lorem ipsum dolor <img src=\"/static/forum/img/smilies/neutral.png\" /> sit amet <img src=\"/static/forum/img/smilies/smile.png\" /> <a href=\"http://djangobb.org/\">http://djangobb.org/</a>")
def test_smiles(self): smiled_data = smiles(self.data_smiles) self.assertEqual( smiled_data, "Lorem ipsum dolor <img src=\"{0}djangobb_forum/img/smilies/neutral.png\" /> sit amet <img src=\"{0}djangobb_forum/img/smilies/smile.png\" /> <a href=\"http://djangobb.org/\">http://djangobb.org/</a>" .format(settings.STATIC_URL))
def save(self, *args, **kwargs): self.body_html = convert_text_to_html(self.body, self.markup) if forum_settings.SMILES_SUPPORT and self.user.forum_profile.show_smilies: self.body_html = smiles(self.body_html) super(Post, self).save(*args, **kwargs)
def save(self, *args, **kwargs): '''Render the long description into HTML on save''' self.long_desc_html = render_bbcode(self.long_desc) self.long_desc_html = smiles(self.long_desc_html) super(Game, self).save(*args, **kwargs)