summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/gtd/templates/gtd/wiredpost_table.html1
-rw-r--r--app/gtd/urls.py5
-rw-r--r--app/gtd/views.py27
3 files changed, 33 insertions, 0 deletions
diff --git a/app/gtd/templates/gtd/wiredpost_table.html b/app/gtd/templates/gtd/wiredpost_table.html
index ee56aa1..d6458bd 100644
--- a/app/gtd/templates/gtd/wiredpost_table.html
+++ b/app/gtd/templates/gtd/wiredpost_table.html
@@ -6,6 +6,7 @@
<main class="content">
<div class="results">
<div style="font-size:11px; text-align: right;"><a href="{% url 'gtd:wiredpost-update-overdue' %}">update overdue</a></div>
+ <div style="font-size:11px; text-align: right;"><a href="{% url 'gtd:wiredpost-update-pubdate' %}">update pubdate</a></div>
<table class="sortable" id="result_list">
<thead>
<tr>
diff --git a/app/gtd/urls.py b/app/gtd/urls.py
index 2d883c1..fb62846 100644
--- a/app/gtd/urls.py
+++ b/app/gtd/urls.py
@@ -109,6 +109,11 @@ urlpatterns = [
name="wiredpost-update-overdue"
),
path(
+ r'wiredposts/update-pub-date',
+ views.UpdateDateView.as_view(),
+ name="wiredpost-update-pubdate"
+ ),
+ path(
r'wiredpost/create',
views.WiredPostCreateView.as_view(),
name="wiredpost-create"
diff --git a/app/gtd/views.py b/app/gtd/views.py
index cb3cefd..e0381d2 100644
--- a/app/gtd/views.py
+++ b/app/gtd/views.py
@@ -332,3 +332,30 @@ class GTDOutcomeDeleteView(DeleteView):
model = GTDOutcome
success_url = "/gtd/outcomes"
template_name = "gtd/confirm_delete.html"
+
+
+
+
+from datetime import datetime
+from bs4 import BeautifulSoup
+import requests
+
+def scrape_date(url):
+ return time
+
+class UpdateDateView(RedirectView):
+ permanent = False
+ url = "/gtd/wiredposts"
+ query_string = True
+
+ def get_redirect_url(self, *args, **kwargs):
+ for post in WiredPost.objects.all():
+ if post.url:
+ content = requests.get(url)
+ soup = BeautifulSoup(content.text, 'html.parser')
+ time = datetime.strptime(soup.time['datetime'][:-6], "%Y-%m-%dT%H:%M:%S").date()
+ if time != post.date_last_pub:
+ post.date_last_pub = time
+ post.save()
+ return super().get_redirect_url(*args, **kwargs)
+