Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

after zotero synch, all releated Belege are updated #80

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bib/templates/bib/synczotero.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
{% load bib_extras %}

{% block content %}
<div class="container" style="text-align:center;">
<a class ="btn btn-primary btn-lg" href="{% url 'bib:synczotero_update' %}">Synchronize</a>
<div class="container text-center">
<h1 class="text-center pt-3 pb-2">Synchronize Zotero Items</h1>
<div class="pt-3"><a class ="btn btn-primary btn-lg" href="{% url 'bib:synczotero_update' %}">Synchronize</a></div>
</div>

{% endblock %}
69 changes: 43 additions & 26 deletions bib/templates/bib/synczotero_action.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,49 @@
{% load bib_extras %}
{% block content %}
<div class="container">
<h1>Results</h1>
<table class="table table-hover">
<tr>
<th>books in db before update operation:</th>
<td>{{ books_before }}<td>
</tr>
<tr>
<th>books in db after update operation:</th>
<td>{{ books_after }}<td>
</tr>
<tr>
<th>updated</th>
<td>
{% if saved %}
{% for x in saved %}
<li>
{% bib_quote x %}
</li>
{% endfor %}
{% else %}
no updates
{% endif %}
</td>
</tr>

</table>
<h1 class="pt-3 text-center">Results</h1>
<div class="row">
<div class="col-md-6">
<h2 class="pt-2 pb-2 text-center">Update Status Zotero Items</h2>
<table class="table table-hover">
<tr>
<th>books in db before update operation:</th>
<td>{{ books_before }}<td>
</tr>
<tr>
<th>books in db after update operation:</th>
<td>{{ books_after }}<td>
</tr>
<tr>
<th>updated</th>
<td>
{% if saved %}
{% for x in saved %}
<li>
{% bib_quote x %}
</li>
{% endfor %}
{% else %}
no updates
{% endif %}
</td>
</tr>
</table>
</div>
<div class="col-md-6">
<h2 class="pt-2 pb-2 text-center">Update Status Hapa Belege</h2>
{% if updated_belege %}
<ul>
{% for x in updated_belege %}
<li><a href="{{ x.get_absolute_url }}">{{ x }}</a></li>
{% endfor %}
</ul>
{% else %}
<p class="text-center">no Hapa Belege were affected by this Zotero Update</p>
{% endif %}
</div>
</div>

</div>

{% endblock %}
12 changes: 10 additions & 2 deletions bib/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
1 change: 0 additions & 1 deletion export_env_variables.sh

This file was deleted.

Loading