From 173737e4592928f9c0a7923beb7784ff8aadbc38 Mon Sep 17 00:00:00 2001 From: csae8092 Date: Fri, 22 Nov 2024 09:20:49 +0100 Subject: [PATCH] after zotero synch, all releated Belege are updated --- bib/templates/bib/synczotero.html | 5 +- bib/templates/bib/synczotero_action.html | 69 +++++++++++++++--------- bib/views.py | 12 ++++- export_env_variables.sh | 1 - 4 files changed, 56 insertions(+), 31 deletions(-) delete mode 100644 export_env_variables.sh diff --git a/bib/templates/bib/synczotero.html b/bib/templates/bib/synczotero.html index 083b4e0..951e3e6 100644 --- a/bib/templates/bib/synczotero.html +++ b/bib/templates/bib/synczotero.html @@ -2,8 +2,9 @@ {% load bib_extras %} {% block content %} -
- Synchronize +
+

Synchronize Zotero Items

+
{% endblock %} diff --git a/bib/templates/bib/synczotero_action.html b/bib/templates/bib/synczotero_action.html index f910260..c1c1694 100644 --- a/bib/templates/bib/synczotero_action.html +++ b/bib/templates/bib/synczotero_action.html @@ -2,32 +2,49 @@ {% load bib_extras %} {% block content %}
-

Results

- - - - - - - - - - - - -
books in db before update operation:{{ books_before }} -
books in db after update operation:{{ books_after }} -
updated - {% if saved %} - {% for x in saved %} -
  • - {% bib_quote x %} -
  • - {% endfor %} - {% else %} - no updates - {% endif %} -
    +

    Results

    +
    +
    +

    Update Status Zotero Items

    + + + + + + + + + + + +
    books in db before update operation:{{ books_before }} +
    books in db after update operation:{{ books_after }} +
    updated + {% if saved %} + {% for x in saved %} +
  • + {% bib_quote x %} +
  • + {% endfor %} + {% else %} + no updates + {% endif %} +
    +
    +
    +

    Update Status Hapa Belege

    + {% if updated_belege %} +
      + {% for x in updated_belege %} +
    • {{ x }}
    • + {% endfor %} +
    + {% else %} +

    no Hapa Belege were affected by this Zotero Update

    + {% endif %} +
    +
    +
    {% endblock %} diff --git a/bib/views.py b/bib/views.py index be20776..2f5d9d0 100644 --- a/bib/views.py +++ b/bib/views.py @@ -1,9 +1,12 @@ from django.conf import settings from django.contrib.auth.decorators import login_required from django.shortcuts import render +from tqdm import tqdm -from .models import ZotItem -from .zot_utils import create_zotitem, items_to_dict +from archiv.models import HapaBeleg + +from bib.models import ZotItem +from bib.zot_utils import create_zotitem, items_to_dict library_id = settings.Z_ID library_type = settings.Z_LIBRARY_TYPE @@ -32,5 +35,10 @@ def update_zotitems(request): for x in items["bibs"]: temp_item = create_zotitem(x) context["saved"].append(temp_item) + belege_to_update = HapaBeleg.objects.filter(zotero_id__in=context["saved"]) + for x in tqdm(belege_to_update, total=belege_to_update.count()): + x.save() + context["updated_belege"] = belege_to_update context["books_after"] = ZotItem.objects.all().count() + return render(request, "bib/synczotero_action.html", context) diff --git a/export_env_variables.sh b/export_env_variables.sh deleted file mode 100644 index 28913a5..0000000 --- a/export_env_variables.sh +++ /dev/null @@ -1 +0,0 @@ -export $(grep -v '^#' secret.env | xargs)