From e812a7a4c680304a5007ac8031e975d6598b262a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 25 Apr 2020 18:37:48 +0200 Subject: [PATCH] Introduce pagination --- static/bootstrap | 1 + ubookmark/admin.py | 4 +- .../0003_bookmarkmodel_posted_at.py | 20 +++++ ubookmark/models.py | 5 ++ ubookmark/settings.py | 1 + .../ubookmark/bookmarkmodel_list.html | 83 ++++++++++++++++++- ubookmark/views.py | 11 ++- 7 files changed, 122 insertions(+), 3 deletions(-) create mode 120000 static/bootstrap create mode 100644 ubookmark/migrations/0003_bookmarkmodel_posted_at.py diff --git a/static/bootstrap b/static/bootstrap new file mode 120000 index 0000000..ce721c8 --- /dev/null +++ b/static/bootstrap @@ -0,0 +1 @@ +bootstrap-4.4.1-dist \ No newline at end of file diff --git a/ubookmark/admin.py b/ubookmark/admin.py index f91be8f..8198666 100644 --- a/ubookmark/admin.py +++ b/ubookmark/admin.py @@ -1,5 +1,7 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin -from .models import User + +from .models import * admin.site.register(User, UserAdmin) +admin.site.register(BookmarkModel) diff --git a/ubookmark/migrations/0003_bookmarkmodel_posted_at.py b/ubookmark/migrations/0003_bookmarkmodel_posted_at.py new file mode 100644 index 0000000..7404b67 --- /dev/null +++ b/ubookmark/migrations/0003_bookmarkmodel_posted_at.py @@ -0,0 +1,20 @@ +# Generated by Django 3.0.5 on 2020-04-25 15:57 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('ubookmark', '0002_bookmarkmodel'), + ] + + operations = [ + migrations.AddField( + model_name='bookmarkmodel', + name='posted_at', + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + ] diff --git a/ubookmark/models.py b/ubookmark/models.py index 8215a43..31cb8a8 100644 --- a/ubookmark/models.py +++ b/ubookmark/models.py @@ -14,3 +14,8 @@ class BookmarkModel(models.Model): url = models.URLField(primary_key=True) comment = models.CharField(max_length=2048) + posted_at = models.DateTimeField(auto_now_add=True) + + + def __str__(self): + return "{} posted by {}".format(self.url, self.owner) diff --git a/ubookmark/settings.py b/ubookmark/settings.py index 77a9443..2dddbfa 100644 --- a/ubookmark/settings.py +++ b/ubookmark/settings.py @@ -99,6 +99,7 @@ except (ModuleNotFoundError, ImportError): AUTH_LDAP_BIND_PASSWORD = "" AUTH_LDAP_USER_SEARCH = "" + SITE_NAME = "an unconfigured site" # Password validation diff --git a/ubookmark/templates/ubookmark/bookmarkmodel_list.html b/ubookmark/templates/ubookmark/bookmarkmodel_list.html index 97c503c..513a706 100644 --- a/ubookmark/templates/ubookmark/bookmarkmodel_list.html +++ b/ubookmark/templates/ubookmark/bookmarkmodel_list.html @@ -1 +1,82 @@ -Something in here! +{% load static %} + + + + + + + + + + + + + {{ site_name }} powered by ubookmark + + +

{{ site_name }}

+
+ {% autoescape off %} +

{{ site_description }}

+ {% endautoescape %} +
+ + +
+ +
+ + + +