Exemplo n.º 1
0
    def item_description(self, item):
        """ Return item description. """
        if item.model_name == 'task':
            return markdown(item.description or '')

        if item.model_name == 'solution':
            return markdown(item.description or '')

        if item.model_name == 'comment':
            return markdown(item.comment or '')

        return unicode(item)
Exemplo n.º 2
0
def get_blurb(bkey):
    ret = None

    try:
        b = Blurb.objects.get(slug=bkey)

    except models.ObjectDoesNotExist:
        ret = None

    else:
        if b.content:
            ret = markdown(b.content, extensions=settings.MARKDOWN_EXTENSIONS)

    if ret is None:
        ret = 'No content found for {}'.format(bkey)

    return ret
Exemplo n.º 3
0
def get_blurb (bkey):
  ret = None
  
  try:
    b = Blurb.objects.get(slug=bkey)
    
  except models.ObjectDoesNotExist:
    ret = None
    
  else:
    if b.content:
      ret = markdown(b.content, extensions=settings.MARKDOWN_EXTENSIONS)
      
  if ret is None:
    ret = 'No content found for {}'.format(bkey)
    
  return ret
  
Exemplo n.º 4
0
    def post(self, request, *args, **kwargs):
        """ Handle POST request.

        Process the addition, deletion, and editing of comments
        on the commentable instance. Returns HTTP response.

        """
        commentable = self.get_commentable()  # noqa
        # Edit or delete comment
        comment_edit = request.POST.get('comment_edit')
        comment_delete = request.POST.get('comment_delete')
        comment_id = request.POST.get('comment_id')
        if request.is_ajax() and \
                (comment_edit or comment_delete) and comment_id:
            try:
                comment = Comment.objects.get(id=comment_id)
            except Comment.DoesNotExist as xxx_todo_changeme:
                Comment.MultipleObjectsReturned = xxx_todo_changeme
                return HttpResponseNotFound(
                    "Comment with not found with id : %s" % comment_id)
            else:
                if not comment.is_owner(request.user):
                    return HttpResponseForbidden("Not your comment.")
                if comment_delete:
                    commentable.delete_comment(comment)
                    return HttpResponse("Comment deleted")
                elif comment_edit:
                    comment.comment = comment_edit
                    comment.save()
                    # For jeditable return data to display
                    return HttpResponse(markdown(comment.comment))
        # Post a comment
        comment_text = request.POST.get('comment')
        if comment_text is not None:
            commentable.add_comment(self.user, comment_text)
            return self.get_comment_redirect()

        return self.get_comment_redirect()
Exemplo n.º 5
0
 def description_html(self):
     return markdown(self.description)
Exemplo n.º 6
0
 def test_filters(self):
     from django_markdown.templatetags.django_markdown import markdown
     self.assertEqual(markdown('| header |\n| ---- |\n| data   |', 'tables'), '<table>\n<thead>\n<tr>\n<th>header</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>data</td>\n</tr>\n</tbody>\n</table>')
Exemplo n.º 7
0
 def test_base(self):
     from django_markdown.utils import markdown
     self.assertEqual(markdown('**test**'), '<p><strong>test</strong></p>')
Exemplo n.º 8
0
 def test_filters(self):
     from django_markdown.templatetags.django_markdown import markdown
     self.assertEqual(
         markdown('| header |\n| ---- |\n| data   |', 'tables'),
         '<table>\n<thead>\n<tr>\n<th>header</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>data</td>\n</tr>\n</tbody>\n</table>'
     )
Exemplo n.º 9
0
 def test_base(self):
     from django_markdown.utils import markdown
     self.assertEqual(markdown('**test**'), '<p><strong>test</strong></p>')
Exemplo n.º 10
0
def get_normal_comment(text_comment):
    text_comment = markdown(text_comment, safe=True)
    if 'HTML_REMOVED' in text_comment:
        return False
    else:
        return text_comment
Exemplo n.º 11
0
 def description_html(self):
     return markdown(self.description,
                     extensions=['fenced_code', 'codehilite'])
Exemplo n.º 12
0
 def to_representation(self, obj):
     return markdown(obj)