From 680d7786cf51a3743b6c74061ac58e0a3c62e1f7 Mon Sep 17 00:00:00 2001
From: Rushil Umaretiya <2023rumareti@tjhsst.edu>
Date: Wed, 21 Oct 2020 22:41:48 -0400
Subject: [PATCH 1/5] fixed indexing
---
pages/templates/pages/index.html | 6 +++---
pages/views.py | 14 +++++---------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/pages/templates/pages/index.html b/pages/templates/pages/index.html
index 915c3fc..1fe8c34 100644
--- a/pages/templates/pages/index.html
+++ b/pages/templates/pages/index.html
@@ -11,7 +11,7 @@
+
2023 News
@@ -27,7 +27,7 @@
-{% if bar %}
+{% for bar in bars %}
{{ bar.name }}!
@@ -55,5 +55,5 @@
});
-{% endif %}
+{% endfor %}
{% endblock content %}
\ No newline at end of file
diff --git a/pages/views.py b/pages/views.py
index 14abd61..2cb90e3 100644
--- a/pages/views.py
+++ b/pages/views.py
@@ -4,21 +4,17 @@ from .models import Story, Bar
# Create your views here.
def index(request):
- try:
- stories = Story.objects.all().order_by('-created')
- bar = Bar.objects.all()[0]
- stories = stories[:3]
- except Exception:
- stories = []
- bar = None
+ stories = Story.objects.all().order_by('-created')[:3]
+ bar = Bar.objects.all()[:1]
context = {
'stories': stories,
'animate': True,
- 'bar': bar
+ 'bars': bar
}
+ print(stories)
- return render(request, 'pages/index.html', context)
+ return render(request, 'pages/index.html', context=context)
def council(request):
From b7e8c66c028577e7504e5be656645bc6be7c30f7 Mon Sep 17 00:00:00 2001
From: Rushil Umaretiya <2023rumareti@tjhsst.edu>
Date: Wed, 21 Oct 2020 23:00:53 -0400
Subject: [PATCH 2/5] removed need for models
---
notes/models.py | 16 ----------------
notes/views.py | 7 +++++--
2 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/notes/models.py b/notes/models.py
index 97a1f04..71a8362 100644
--- a/notes/models.py
+++ b/notes/models.py
@@ -1,19 +1,3 @@
from django.db import models
-from django.conf import settings
-from notion.client import NotionClient
-
-client = NotionClient(token_v2=settings.NOTION_COOKIE)
-
# Create your models here.
-class NotionPage(models.Model):
- url = models.URLField(max_length=300)
- page = None
-
- def __init__(self, *args, **kwargs):
- super(NotionPage, self).__init__(*args, **kwargs)
- if self.url:
- self.page = client.get_block(self.url)
-
- def __str__(self):
- return str(self.page and self.page.title)
diff --git a/notes/views.py b/notes/views.py
index b0c0770..b6cdcfe 100644
--- a/notes/views.py
+++ b/notes/views.py
@@ -1,6 +1,7 @@
from django.shortcuts import render
from .models import NotionPage
from django.conf import settings
+from notion.client import NotionClient
import time
@@ -9,7 +10,8 @@ import time
def meeting_overview(request):
html = ''
- page = NotionPage.objects.get(url=settings.NOTION_URL).page
+ client = NotionClient(token_v2=settings.NOTION_COOKIE)
+ page = client.get_block(settings.NOTION_URL)
meeting_block = None
for block in page.children:
@@ -65,7 +67,8 @@ def show_meeting(request, meeting_id):
now = time.time()
- page = NotionPage.objects.get(url=settings.NOTION_URL).page
+ client = NotionClient(token_v2=settings.NOTION_COOKIE)
+ page = client.get_block(settings.NOTION_URL)
meeting = None
for block in page.children:
From c1708e7dac031d501720001c17096e4bc6ced461 Mon Sep 17 00:00:00 2001
From: Rushil Umaretiya <2023rumareti@tjhsst.edu>
Date: Wed, 21 Oct 2020 23:02:22 -0400
Subject: [PATCH 3/5] completely removed need for model
---
notes/admin.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/notes/admin.py b/notes/admin.py
index 0ce7c5c..8c38f3f 100644
--- a/notes/admin.py
+++ b/notes/admin.py
@@ -1,5 +1,3 @@
from django.contrib import admin
-from .models import NotionPage
# Register your models here.
-admin.site.register(NotionPage)
\ No newline at end of file
From 3aad89c9e2bd5d34f2eed649d3efc3fc1702aa31 Mon Sep 17 00:00:00 2001
From: Rushil Umaretiya <2023rumareti@tjhsst.edu>
Date: Wed, 21 Oct 2020 23:04:23 -0400
Subject: [PATCH 4/5] FINALLY fixed dependecy on model
---
notes/views.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/notes/views.py b/notes/views.py
index b6cdcfe..d024977 100644
--- a/notes/views.py
+++ b/notes/views.py
@@ -1,5 +1,4 @@
from django.shortcuts import render
-from .models import NotionPage
from django.conf import settings
from notion.client import NotionClient
From 9a59d5157b3d1288afd3702b3b7f83a5b2195ef3 Mon Sep 17 00:00:00 2001
From: Rushil Umaretiya <2023rumareti@tjhsst.edu>
Date: Thu, 22 Oct 2020 19:42:52 -0400
Subject: [PATCH 5/5] retracking migrations
---
.gitignore | 1 -
notes/migrations/0001_initial.py | 21 ----------------
pages/migrations/0001_initial.py | 32 +++++++++++++++++++++++++
{notes => pages}/migrations/__init__.py | 0
4 files changed, 32 insertions(+), 22 deletions(-)
delete mode 100644 notes/migrations/0001_initial.py
create mode 100644 pages/migrations/0001_initial.py
rename {notes => pages}/migrations/__init__.py (100%)
diff --git a/.gitignore b/.gitignore
index b3a76d0..b8cfaab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,6 @@ static_files
.idea/
.vscode/
/static
-migrations/
# C extensions
*.so
diff --git a/notes/migrations/0001_initial.py b/notes/migrations/0001_initial.py
deleted file mode 100644
index 3064601..0000000
--- a/notes/migrations/0001_initial.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Generated by Django 3.1.2 on 2020-10-20 13:48
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- initial = True
-
- dependencies = [
- ]
-
- operations = [
- migrations.CreateModel(
- name='NotionPage',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('url', models.URLField(max_length=300)),
- ],
- ),
- ]
diff --git a/pages/migrations/0001_initial.py b/pages/migrations/0001_initial.py
new file mode 100644
index 0000000..ee3e689
--- /dev/null
+++ b/pages/migrations/0001_initial.py
@@ -0,0 +1,32 @@
+# Generated by Django 3.1.2 on 2020-10-22 23:42
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Bar',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=70)),
+ ('money_raised', models.FloatField()),
+ ],
+ ),
+ migrations.CreateModel(
+ name='Story',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('header', models.CharField(max_length=50)),
+ ('img_name', models.CharField(default=None, max_length=50, null=True)),
+ ('body', models.TextField(max_length=200)),
+ ('created', models.DateTimeField(auto_now=True)),
+ ],
+ ),
+ ]
diff --git a/notes/migrations/__init__.py b/pages/migrations/__init__.py
similarity index 100%
rename from notes/migrations/__init__.py
rename to pages/migrations/__init__.py