Browse Source

Closes #61: Method 'extract_links_from_content' always return empty list

Bastien Sevajol (Algoo) 8 years ago
parent
commit
31d2b0ba89
2 changed files with 2 additions and 26 deletions
  1. 0 24
      tracim/tracim/model/data.py
  2. 2 2
      tracim/tracim/model/serializers.py

+ 0 - 24
tracim/tracim/model/data.py View File

@@ -1008,30 +1008,6 @@ class Content(DeclarativeBase):
1008 1008
         return format_timedelta(delta_from_datetime - datetime_object,
1009 1009
                                 locale=tg.i18n.get_lang()[0])
1010 1010
 
1011
-
1012
-    def extract_links_from_content(self, other_content: str=None) -> [LinkItem]:
1013
-        """
1014
-        parse html content and extract links. By default, it works on the description property
1015
-        :param other_content: if not empty, then parse the given html content instead of description
1016
-        :return: a list of LinkItem
1017
-        """
1018
-        links = []
1019
-        return links
1020
-        soup = BeautifulSoup(
1021
-            self.description if not other_content else other_content,
1022
-            'html.parser'  # Fixes hanging bug - http://stackoverflow.com/questions/12618567/problems-running-beautifulsoup4-within-apache-mod-python-django
1023
-        )
1024
-
1025
-        for link in soup.findAll('a'):
1026
-            href = link.get('href')
1027
-            label = link.contents
1028
-            links.append(LinkItem(href, label))
1029
-        links.sort(key=lambda link: link.href if link.href else '')
1030
-
1031
-        sorted_links = sorted(links, key=lambda link: link.label if link.label else link.href, reverse=True)
1032
-        ## FIXME - Does this return a sorted list ???!
1033
-        return sorted_links
1034
-
1035 1011
     def get_child_nb(self, content_type: ContentType, content_status = ''):
1036 1012
         child_nb = 0
1037 1013
         for child in self.get_valid_children():

+ 2 - 2
tracim/tracim/model/serializers.py View File

@@ -382,7 +382,7 @@ def serialize_node_for_page(content: Content, context: Context):
382 382
             icon=ContentType.get_icon(content.type),
383 383
             owner=context.toDict(data_container.owner),
384 384
             status=context.toDict(data_container.get_status()),
385
-            links=context.toDict(content.extract_links_from_content(data_container.description)),
385
+            links=[],
386 386
             revisions=context.toDict(sorted(content.revisions, key=lambda v: v.created, reverse=True)),
387 387
             selected_revision='latest' if content.revision_to_serialize<=0 else content.revision_to_serialize,
388 388
             history=Context(CTX.CONTENT_HISTORY).toDict(content.get_history()),
@@ -445,7 +445,7 @@ def serialize_node_for_page(item: Content, context: Context):
445 445
             icon = ContentType.get_icon(item.type),
446 446
             id = item.content_id,
447 447
             label = item.label,
448
-            links = context.toDict(item.extract_links_from_content(item.description)),
448
+            links=[],
449 449
             owner = context.toDict(item.owner),
450 450
             parent = context.toDict(item.parent),
451 451
             selected_revision = 'latest',