Skip to content

Commit

Permalink
Implemented calls from the model to the new functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-code committed Apr 11, 2020
1 parent 5d31765 commit d6883ad
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bootcamp/news/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from channels.layers import get_channel_layer

from bootcamp.notifications.models import Notification, notification_handler
from bootcamp.news.metadatareader import Metadata, Metadatareader
from bootcamp.helpers import fetch_metadata


class News(models.Model):
Expand Down Expand Up @@ -49,12 +49,12 @@ def __str__(self):

def save(self, *args, **kwargs):
# extract metada from content url
metadata = Metadatareader.get_metadata_from_url_in_text(self.content)
self.meta_url = metadata.url[0:2048]
self.meta_type = metadata.type[0:255]
self.meta_title = metadata.title[0:255]
self.meta_description = metadata.description[0:255]
self.meta_image = metadata.image[0:255]
data = fetch_metadata(self.content)
self.meta_url = data.get("url")
self.meta_type = data.get("type", "website")
self.meta_title = data.get("title")
self.meta_description = data.get("description")
self.meta_image = data.get("image")

super().save(*args, **kwargs)
if not self.reply:
Expand Down

0 comments on commit d6883ad

Please sign in to comment.