diff --git a/core/admin.py b/core/admin.py index 0fdd381..9c1c987 100644 --- a/core/admin.py +++ b/core/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .forms import CustomUserCreationForm -from .models import Plan, Session, User +from .models import ContentBlock, Plan, Session, User # Register your models here. @@ -31,3 +31,4 @@ class CustomUserAdmin(UserAdmin): admin.site.register(User, CustomUserAdmin) admin.site.register(Plan) admin.site.register(Session) +admin.site.register(ContentBlock) diff --git a/core/migrations/0003_contentblock.py b/core/migrations/0003_contentblock.py new file mode 100644 index 0000000..c30ec38 --- /dev/null +++ b/core/migrations/0003_contentblock.py @@ -0,0 +1,26 @@ +# Generated by Django 4.0.6 on 2022-07-13 13:55 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0002_session_session'), + ] + + operations = [ + migrations.CreateModel( + name='ContentBlock', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('position', models.IntegerField()), + ('column1', models.TextField()), + ('column2', models.TextField(blank=True, null=True)), + ('column3', models.TextField(blank=True, null=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/core/migrations/0004_contentblock_title.py b/core/migrations/0004_contentblock_title.py new file mode 100644 index 0000000..783914e --- /dev/null +++ b/core/migrations/0004_contentblock_title.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.6 on 2022-07-13 14:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0003_contentblock'), + ] + + operations = [ + migrations.AddField( + model_name='contentblock', + name='title', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/core/migrations/0005_contentblock_image1_contentblock_image2_and_more.py b/core/migrations/0005_contentblock_image1_contentblock_image2_and_more.py new file mode 100644 index 0000000..ca305ae --- /dev/null +++ b/core/migrations/0005_contentblock_image1_contentblock_image2_and_more.py @@ -0,0 +1,38 @@ +# Generated by Django 4.0.6 on 2022-07-13 14:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0004_contentblock_title'), + ] + + operations = [ + migrations.AddField( + model_name='contentblock', + name='image1', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='contentblock', + name='image2', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='contentblock', + name='image3', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AlterField( + model_name='contentblock', + name='column1', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='contentblock', + name='title', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/core/models.py b/core/models.py index 99a51a8..1d4ad20 100644 --- a/core/models.py +++ b/core/models.py @@ -67,3 +67,28 @@ class Session(models.Model): session = models.CharField(max_length=255, null=True, blank=True) subscription_id = models.CharField(max_length=255, null=True, blank=True) plan = models.ForeignKey(Plan, null=True, blank=True, on_delete=models.CASCADE) + + +class ContentBlock(models.Model): + user = models.ForeignKey(User, on_delete=models.PROTECT) + position = models.IntegerField() + title = models.CharField(max_length=255, null=True, blank=True) + column1 = models.TextField(null=True, blank=True) + column2 = models.TextField(null=True, blank=True) + column3 = models.TextField(null=True, blank=True) + image1 = models.CharField(max_length=255, null=True, blank=True) + image2 = models.CharField(max_length=255, null=True, blank=True) + image3 = models.CharField(max_length=255, null=True, blank=True) + + def save(self, *args, **kwargs): + """ + Override the save function to blank fields. + """ + if self.column1 == "NONE": + self.column1 = None + if self.column2 == "NONE": + self.column2 = None + if self.column3 == "NONE": + self.column3 = None + + super().save(*args, **kwargs) diff --git a/core/static/bitcoin-sentiment.png b/core/static/bitcoin-sentiment.png new file mode 100644 index 0000000..4081445 Binary files /dev/null and b/core/static/bitcoin-sentiment.png differ diff --git a/core/static/chart-bitcoin.png b/core/static/chart-bitcoin.png new file mode 100644 index 0000000..7d42b27 Binary files /dev/null and b/core/static/chart-bitcoin.png differ diff --git a/core/templates/index.html b/core/templates/index.html index 7f43b98..2c34759 100644 --- a/core/templates/index.html +++ b/core/templates/index.html @@ -1,12 +1,58 @@ {% extends "base.html" %} +{% load static %} + {% block content %} -
-

Pathogen Data Insights

-
-

Welcome to the Neptune system

-
-

Hello!

+
+ {% for block in blocks %} + {% if block.title is not None %} +

{{ block.title }}

+ {% endif %} +
+ {% if block.column1 is not None %} +
+
+ {{ block.column1 }} +
+
+ {% endif %} + {% if block.column2 is not None %} +
+
+ {{ block.column2 }} +
+
+ {% endif %} + {% if block.column3 is not None %} +
+
+ {{ block.column3 }} +
+
+ {% endif %}
-
-
+
+ {% if block.image1 is not None %} +
+
+ +
+
+ {% endif %} + {% if block.image2 is not None %} +
+
+ {{ block.image2 }} +
+
+ {% endif %} + {% if block.image3 is not None %} +
+
+ {{ block.image3 }} +
+
+ {% endif %} +
+ {% endfor %} +
{% endblock %} diff --git a/core/views/__init__.py b/core/views/__init__.py index 85b592b..5391f57 100644 --- a/core/views/__init__.py +++ b/core/views/__init__.py @@ -11,7 +11,7 @@ from django.views.generic.edit import CreateView from core.forms import NewUserForm from core.lib.products import assemble_plan_map -from core.models import Plan, Session +from core.models import ContentBlock, Plan, Session pp = pprint.PrettyPrinter(indent=4) @@ -22,7 +22,11 @@ class Home(View): template_name = "index.html" def get(self, request): - return render(request, self.template_name) + blocks = ContentBlock.objects.all().order_by("position") + print("BLOCKS", blocks) + print("ITER", [x.position for x in blocks]) + context = {"blocks": blocks} + return render(request, self.template_name, context) class Billing(LoginRequiredMixin, View):