Skip to content

Commit

Permalink
1. change partial_article.html to show summary
Browse files Browse the repository at this point in the history
  • Loading branch information
WUJISHANXIA committed Oct 15, 2017
1 parent e9be443 commit aa58538
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions bootcamp/articles/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import unicode_literals

import sys
from django.contrib.auth.models import User
from django.db import models
from autoslug import AutoSlugField
Expand Down Expand Up @@ -41,7 +40,6 @@ def __str__(self):
return self.title

def get_content_as_markdown(self):
self.content = self.insert_space_to_long_word(self.content)
return markdown.markdown(self.content, safe_mode='escape')

@staticmethod
Expand Down Expand Up @@ -76,24 +74,6 @@ def get_summary_as_markdown(self):
def get_comments(self):
return ArticleComment.objects.filter(article=self)

@staticmethod
def insert_space_to_long_word(content):
count = 0
index_list = []
for index, character in enumerate(content):
if not character.isspace():
count += 1
else:
count = 0
if count >= 50:
index_list.append(index)
count = 0
content_list = list(content)
for index in index_list:
content_list.insert(index, ' ')
content = ''.join(content_list)
return content


@python_2_unicode_compatible
class ArticleComment(models.Model):
Expand All @@ -111,4 +91,4 @@ def __str__(self):
return '{0} - {1}'.format(self.user.username, self.article.title)

def get_comment_as_markdown(self):
return markdown.markdown(self.comment, safe_mode='escape')
return markdown.markdown(self.comment, safe_mode='escape')

0 comments on commit aa58538

Please sign in to comment.