From cbafd53101c487e0928d9b3deefaaad19c17dd3f Mon Sep 17 00:00:00 2001 From: goose-life <32566441+goose-life@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:45:57 +0200 Subject: [PATCH 01/28] add work_in_progress, approved_by_user, approved_at, migration --- .../migrations/0029_work_in_progress.py | 31 +++++++++++++++++++ indigo_api/models/works.py | 4 +++ 2 files changed, 35 insertions(+) create mode 100644 indigo_api/migrations/0029_work_in_progress.py diff --git a/indigo_api/migrations/0029_work_in_progress.py b/indigo_api/migrations/0029_work_in_progress.py new file mode 100644 index 000000000..c27bded92 --- /dev/null +++ b/indigo_api/migrations/0029_work_in_progress.py @@ -0,0 +1,31 @@ +# Generated by Django 3.2.13 on 2023-12-06 08:43 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('indigo_api', '0028_alter_taxonomytopic_slug'), + ] + + operations = [ + migrations.AddField( + model_name='work', + name='approved_at', + field=models.DateTimeField(auto_now=True), + ), + migrations.AddField( + model_name='work', + name='approved_by_user', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='work', + name='work_in_progress', + field=models.BooleanField(default=False, help_text='Work in progress, to be approved'), + ), + ] diff --git a/indigo_api/models/works.py b/indigo_api/models/works.py index 3db5e7ffe..6ccafd733 100644 --- a/indigo_api/models/works.py +++ b/indigo_api/models/works.py @@ -499,11 +499,15 @@ class Meta: consolidation_note_override = models.CharField(max_length=1024, null=True, blank=True, help_text='Consolidation note about this particular work, to override consolidation note for place') disclaimer = models.CharField(max_length=1024, null=True, blank=True, help_text='Disclaimer text about this work') + work_in_progress = models.BooleanField(default=False, help_text="Work in progress, to be approved") + created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) + approved_at = models.DateTimeField(auto_now=True) created_by_user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name='+') updated_by_user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name='+') + approved_by_user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name='+') objects = WorkManager.from_queryset(WorkQuerySet)() From 1018f2780a541f9e8351c357b69d0b877a56aed1 Mon Sep 17 00:00:00 2001 From: goose-life <32566441+goose-life@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:00:48 +0200 Subject: [PATCH 02/28] make approved_at nullable --- indigo_api/migrations/0029_work_in_progress.py | 4 ++-- indigo_api/models/works.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/indigo_api/migrations/0029_work_in_progress.py b/indigo_api/migrations/0029_work_in_progress.py index c27bded92..e2056fb1a 100644 --- a/indigo_api/migrations/0029_work_in_progress.py +++ b/indigo_api/migrations/0029_work_in_progress.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.13 on 2023-12-06 08:43 +# Generated by Django 3.2.13 on 2023-12-06 11:21 from django.conf import settings from django.db import migrations, models @@ -16,7 +16,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='work', name='approved_at', - field=models.DateTimeField(auto_now=True), + field=models.DateTimeField(null=True), ), migrations.AddField( model_name='work', diff --git a/indigo_api/models/works.py b/indigo_api/models/works.py index 6ccafd733..241ef6ca1 100644 --- a/indigo_api/models/works.py +++ b/indigo_api/models/works.py @@ -503,7 +503,7 @@ class Meta: created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) - approved_at = models.DateTimeField(auto_now=True) + approved_at = models.DateTimeField(null=True) created_by_user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name='+') updated_by_user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name='+') From 410616984a96ec2d2975c3e3714163e0dab2048c Mon Sep 17 00:00:00 2001 From: goose-life <32566441+goose-life@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:42:04 +0200 Subject: [PATCH 03/28] add 'Change status' to bulk operations --- indigo_app/forms.py | 22 ++++++++++++++++++- .../templates/indigo_app/place/_work.html | 2 +- .../indigo_app/place/_works_actions.html | 11 ++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/indigo_app/forms.py b/indigo_app/forms.py index ff17e63b7..463e6f60b 100644 --- a/indigo_app/forms.py +++ b/indigo_app/forms.py @@ -1,7 +1,7 @@ import json import re import urllib.parse -from datetime import date +from datetime import date, datetime from lxml import etree from django import forms @@ -767,12 +767,14 @@ class WorkBulkActionsForm(forms.Form): save = forms.BooleanField() all_work_pks = forms.CharField(required=False) works = forms.ModelMultipleChoiceField(queryset=Work.objects, required=True) + user = forms.ModelChoiceField(queryset=User.objects) add_taxonomy_topics = forms.ModelMultipleChoiceField( queryset=TaxonomyTopic.objects.all(), required=False) del_taxonomy_topics = forms.ModelMultipleChoiceField( queryset=TaxonomyTopic.objects.all(), required=False) + change_status = forms.ChoiceField(choices=[('', ''), ('approve', 'Approve'), ('un_approve', 'Un-approve')], required=False) def clean_all_work_pks(self): return self.cleaned_data.get('all_work_pks').split() or [] @@ -785,3 +787,21 @@ def save_changes(self): if self.cleaned_data.get('del_taxonomy_topics'): for work in self.cleaned_data['works']: work.taxonomy_topics.remove(*self.cleaned_data['del_taxonomy_topics']) + + if self.cleaned_data.get('change_status'): + change = self.cleaned_data['change_status'] + user = self.cleaned_data['user'] + + if change == 'approve': + for work in self.cleaned_data['works']: + work.work_in_progress = False + work.approved_by_user = user + work.approved_at = datetime.now() + work.save_with_revision(user) + + else: + for work in self.cleaned_data['works']: + work.work_in_progress = True + work.approved_by_user = None + work.approved_at = None + work.save_with_revision(user) diff --git a/indigo_app/templates/indigo_app/place/_work.html b/indigo_app/templates/indigo_app/place/_work.html index 3255a1ef1..65c5e162a 100644 --- a/indigo_app/templates/indigo_app/place/_work.html +++ b/indigo_app/templates/indigo_app/place/_work.html @@ -7,7 +7,7 @@ {% endif %}
-
+
+ {% for work in works %} {% endfor %} @@ -26,6 +27,16 @@