summaryrefslogtreecommitdiff
path: root/app/posts/management/commands/rss_updater.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-09-22 10:04:37 -0400
committerluxagraf <sng@luxagraf.net>2023-09-22 10:04:37 -0400
commitacf110f7379a2776ee917441f24fb9f6f07f0ac1 (patch)
treefcf524b91f3286776a04537658cfcaf794fb2ef7 /app/posts/management/commands/rss_updater.py
parent015bdab536631d522d7abd1c03c608c81de30924 (diff)
notes/guides: cleaned up some code and made it easier to see what I need
to do.
Diffstat (limited to 'app/posts/management/commands/rss_updater.py')
-rw-r--r--app/posts/management/commands/rss_updater.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/app/posts/management/commands/rss_updater.py b/app/posts/management/commands/rss_updater.py
index ad8551b..41ffa99 100644
--- a/app/posts/management/commands/rss_updater.py
+++ b/app/posts/management/commands/rss_updater.py
@@ -4,8 +4,10 @@ import datetime
import feedparser
from urllib.parse import urlparse
-from posts.models import PostStatus, Post
+from django.contrib.auth import get_user_model
+from posts.models import PostStatus, Post
+User = get_user_model()
"""
run from a cronscript that looks line this:
@@ -38,5 +40,28 @@ class Command(BaseCommand):
)
except:
continue
+ if story_type == "review":
+ """
+ TODO: add first and last names so I have everyone in the DB
+ Then parse and add reviews, but change views so we don't see them
+ in views where we just want a list of guides to update
+ """
+ user = User.objects.get(firstname=item.author.split(" ")[0],lastname=item.author.split(" ")[1])
+ dt = datetime.datetime.strptime(item.published, '%a, %d %b %Y %H:%M:%S %z').date()
+ post = Post.objects.get(url=item.link)
+ user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL)
+ title = models.CharField(max_length=512, blank=True, null=True)
+ body = models.TextField(blank=True, null=True)
+ url = models.CharField(max_length=512, blank=True, null=True)
+ date_last_pub = models.DateField()
+ guid = models.CharField(max_length=512, blank=True, null=True, db_index=True)
+ author = models.CharField(max_length=255, blank=True, null=True)
+ post_type = models.IntegerField(choices=PostType.choices, default=PostType.GUIDE)
+ template_type = models.IntegerField(choices=TemplateType.choices, default=TemplateType.STORY)
+ update_frequency = models.BigIntegerField(help_text="In days")
+ products = models.ManyToManyField(ProductLink, blank=True, null=True)
+ needs_update = models.BooleanField(default=False)
+ is_live = models.BooleanField(default=True)
+ post_status = models.IntegerField(choices=PostStatus.choices, default=PostStatus.PUBLISHED)