Skip to content

Commit

Permalink
Merge branch 'main' into final_fetcing_and_pdfs
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarMAshour committed Oct 23, 2022
2 parents 80a3cef + 69790fd commit 2a777fb
Show file tree
Hide file tree
Showing 11 changed files with 11,341 additions and 25 deletions.
Binary file modified coop_challenge/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file modified coop_challenge/__pycache__/views.cpython-310.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions coop_challenge/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ def find_by_article_ids(self, article_ids: List[str], keys: List[str] = None) ->
if __name__ == "__main__":
fetcher = Fetcher()
print(fetcher.find_article_id_by_barcode("3760126362587"))
items = fetcher.find_for_labels(article_ids=["1007906010"])

print(items)

# def fetchData(article_id):
# fetcher = Fetcher()
# items = fetcher.find_for_labels(article_ids=[article_id])
# return items[0]
11,256 changes: 11,256 additions & 0 deletions coop_challenge/static/coop_challenge/js/html5-qrcode.js

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions coop_challenge/static/coop_challenge/js/html5-qrcode.min.js

This file was deleted.

11 changes: 5 additions & 6 deletions coop_challenge/templates/coop_challenge/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="author" content="">

<title>Wine Manager</title>

<script src="{% static 'coop_challenge/js/html5-qrcode.js' %}"></script>
<!-- Bootstrap core CSS -->
<link href="{% static 'coop_challenge/css/bootstrap.css' %}" rel="stylesheet">
<link href="{% static 'coop_challenge/css/bootstrap-reboot.min.css' %}" rel="stylesheet">
Expand Down Expand Up @@ -43,34 +43,33 @@
</li>
<li class="nav-item">
<div style="padding: 10px;"><div class="input-group mb-2">
<input type="text" class="form-control" style = "font-size: 20px; padding-bottom: 10px"placeholder="My cellar ..." aria-label="My cellar" aria-describedby="My cellar">
<input type="text" class="form-control" style = "font-size: 20px; padding-bottom: 10px"placeholder="Mein Weinkeller ..." aria-label="My cellar" aria-describedby="My cellar">
<button class="btn btn-outline-secondary" type="button" id="search-btn"><i data-feather="search"></i></button>
</div></div>
</li>
<li class="nav-item">
<a class="nav-link" style = "font-size: 20px ; padding-top: 10px; padding-bottom: 30px;" href="#">
<span data-feather="tag"></span>
Scan and label
Scannen und beschreiben
</a>
</li>
<li class="nav-item">
<a class="nav-link" style = "font-size: 20px; padding-bottom: 30px;" href="#">
<span data-feather="users"></span>
Recommend wine
Wein empfehlen
</a>
</li>
<li class="nav-item">
<a class="nav-link" style = "font-size: 20px" href="#">
<span data-feather="info"></span>
About
Über uns
</a>
</li>
</ul>
</div>
</nav>

<main id="mainscreen" role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
hiiiii
{% block body %}

{% endblock %}
Expand Down
24 changes: 24 additions & 0 deletions coop_challenge/templates/coop_challenge/scanner_1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends 'coop_challenge/base.html' %}

{% block body %}
<script src="js/html5-qrcode.js"></script>
<div class="d-flex justify-content-center">
<div style="width: 60%" id="reader"></div>
</div>

<div id="resultScan" class="d-flex justify-content-center">

</div>

<script>
function onScanSuccess(decodedText, decodedResult) {
html5QrcodeScanner.clear();
var decodedText_int = parseInt(decodedText);
$("#resultScan").html("<div class='row d-flex justify-content-center' style='width: 60%; margin-top: 100px;'><div class='col-12 d-flex justify-content-center' style=\"font-size:18px;\"><strong>Artikelnummer/Bar code gescannt:</strong><span style=\"color:#ffa500;\">&nbsp"+decodedText+"</span></div><br><br><br><br><div class='col-5 d-flex justify-content-center'><a href=\"printlabel/"+decodedText+"\"><button class='btn btn-primary btn-lg'>Label drucken</button></a></div><div class='col-5 d-flex justify-content-center'><a href=\"printpdf/"+decodedText+"\"><button class='btn btn-primary btn-lg'>Datenblatt drucken</button></a></div></div>".replace('decodedText_str', decodedText_int));
}

var html5QrcodeScanner = new Html5QrcodeScanner(
"reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess);
</script>
{% endblock %}
3 changes: 3 additions & 0 deletions coop_challenge/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@

urlpatterns = [
path('', views.viewIndex, name='index'),
path('printlabell/', views.printLabell, name='printlabell'),
path('printlabel/<int:article>/', views.printLabel, name='printlabel'),
path('printpdf/<int:article>/', views.printPdf, name='printpdf'),
]
24 changes: 24 additions & 0 deletions coop_challenge/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,27 @@ def viewIndex(request):
info_path = tryInfo(json[0].copy())

# return render(request, 'coop_challenge/base.html', {})
def printLabel(request, article):
# tryPDF()
# return FileResponse(open(tryPDF(), 'rb'), content_type='application/pdf')
print(article)
print(article)
print(article)
print(article)
print(article)
print(article)
print(article)
print(article)
return render(request, 'coop_challenge/scanner_1.html', {})

def printLabell(request):
# tryPDF()
# return FileResponse(open(tryPDF(), 'rb'), content_type='application/pdf')

return render(request, 'coop_challenge/scanner_1.html', {})

def printPdf(request, article):
# tryPDF()
# return FileResponse(open(tryPDF(), 'rb'), content_type='application/pdf')

return render(request, 'coop_challenge/scanner_1.html', {})
21 changes: 21 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="author" content="">

<title>TroVino</title>
<script src="js/html5-qrcode.js"></script>

<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
Expand Down Expand Up @@ -65,6 +66,26 @@

<main id="mainscreen" role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">

<div class="d-flex justify-content-center">
<div style="width: 60%" id="reader"></div>
</div>

<div id="resultScan" class="d-flex justify-content-center">

</div>

<script>
function onScanSuccess(decodedText, decodedResult) {
html5QrcodeScanner.clear();
$("#resultScan").html("<div class='row d-flex justify-content-center' style='width: 60%; margin-top: 100px;'><div class='col-5 d-flex justify-content-center'><button class='btn btn-primary btn-lg'>Print label</button></div><div class='col-5 d-flex justify-content-center'><button class='btn btn-primary btn-lg'>Print sheet</button></div></div>");
}

var html5QrcodeScanner = new Html5QrcodeScanner(
"reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess);
</script>


</main>
</div>
</div>
Expand Down
Binary file modified testPDF.pdf
Binary file not shown.

0 comments on commit 2a777fb

Please sign in to comment.