From e2dd97f3ac4a160a3ca34482099b9ce49468837f Mon Sep 17 00:00:00 2001 From: carol Date: Wed, 28 Aug 2019 00:50:37 -0500 Subject: [PATCH 1/3] take out index with a migrations and in a new empty one create the new index with md5 --- .../migrations/0008_auto_20190828_0450.py | 17 +++++++++++++++++ .../migrations/0009_auto_20190828_0457.py | 15 +++++++++++++++ collection/models.py | 4 ++-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 collection/migrations/0008_auto_20190828_0450.py create mode 100644 collection/migrations/0009_auto_20190828_0457.py diff --git a/collection/migrations/0008_auto_20190828_0450.py b/collection/migrations/0008_auto_20190828_0450.py new file mode 100644 index 0000000..ad258b5 --- /dev/null +++ b/collection/migrations/0008_auto_20190828_0450.py @@ -0,0 +1,17 @@ +# Generated by Django 2.0.1 on 2019-08-28 04:50 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('collection', '0007_auto_20181008_2042'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='collection', + unique_together=set(), + ), + ] diff --git a/collection/migrations/0009_auto_20190828_0457.py b/collection/migrations/0009_auto_20190828_0457.py new file mode 100644 index 0000000..4685fa6 --- /dev/null +++ b/collection/migrations/0009_auto_20190828_0457.py @@ -0,0 +1,15 @@ +# Generated by Django 2.0.1 on 2019-08-28 04:57 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('collection', '0008_auto_20190828_0450'), + ] + + operations = [ + migrations.RunSQL( + "CREATE UNIQUE INDEX collection_collection_title_text_type_id_uniq ON collection_collection (title, md5(text), type_id)"), + ] diff --git a/collection/models.py b/collection/models.py index c794b15..4908d93 100644 --- a/collection/models.py +++ b/collection/models.py @@ -82,5 +82,5 @@ def repl(match): text = Sentence(text=self.text).html # convert words to links return re.sub(r"{{sentence:([0-9]+)}}", repl, text, flags=re.MULTILINE) - class Meta: - unique_together = ('title', 'text', 'type',) + # class Meta: + # unique_together = ('title', 'text', 'type',) From 990f79ae2302acf431f69ce507c8e2a31a6f75b8 Mon Sep 17 00:00:00 2001 From: carol Date: Fri, 30 Aug 2019 18:00:46 -0500 Subject: [PATCH 2/3] collection main site showing las three collections per type of collection --- collection/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/collection/views.py b/collection/views.py index 83346d8..34267e8 100644 --- a/collection/views.py +++ b/collection/views.py @@ -60,7 +60,11 @@ def keyword_filtered(request): # eg. poem collection_type = first_collection_obj.type # eg. all poems - collections = Collection.objects.filter(type=collection_type) + collections = [] + for collection_type in Collection.objects.all().distinct("type"): + collection_sample = Collection.objects.filter(type=collection_type.type).order_by("-id")[0:3] + collections.extend(list(collection_sample)) + # collections = Collection.objects.filter(type=collection_type) context["collections"] = collections context["active_collection"] = collection_type # to delete
from html text From a39b37cecabffdc8278091315da2ab6eeafd85d4 Mon Sep 17 00:00:00 2001 From: carol Date: Fri, 30 Aug 2019 18:29:02 -0500 Subject: [PATCH 3/3] deleted comments --- collection/models.py | 2 -- collection/views.py | 1 - 2 files changed, 3 deletions(-) diff --git a/collection/models.py b/collection/models.py index 4908d93..bc02d2a 100644 --- a/collection/models.py +++ b/collection/models.py @@ -82,5 +82,3 @@ def repl(match): text = Sentence(text=self.text).html # convert words to links return re.sub(r"{{sentence:([0-9]+)}}", repl, text, flags=re.MULTILINE) - # class Meta: - # unique_together = ('title', 'text', 'type',) diff --git a/collection/views.py b/collection/views.py index 34267e8..9bfd3e0 100644 --- a/collection/views.py +++ b/collection/views.py @@ -64,7 +64,6 @@ def keyword_filtered(request): for collection_type in Collection.objects.all().distinct("type"): collection_sample = Collection.objects.filter(type=collection_type.type).order_by("-id")[0:3] collections.extend(list(collection_sample)) - # collections = Collection.objects.filter(type=collection_type) context["collections"] = collections context["active_collection"] = collection_type # to delete
from html text