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

[story/gh-30] Added button to admin interface to initiate tracking nu… #61

Merged
merged 1 commit into from
Feb 7, 2025
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
2 changes: 1 addition & 1 deletion edrop/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

logger = logging.getLogger(__name__)
LOGLEVEL = os.environ.get('LOGLEVEL', 'INFO').upper()
logging.basicConfig(format="%(levelname)s: %(name)s: %(message)s", level=LOGLEVEL)
logging.basicConfig(format="%(asctime)s - %(levelname)s: %(name)s: %(message)s", level=LOGLEVEL)


# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand Down
21 changes: 21 additions & 0 deletions track/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
from django.contrib import admin
from track.models import *
from django.http import HttpResponseRedirect
from django.urls import path
import logging
from track import orders

logger = logging.getLogger(__name__)


# Register your models here.
class OrderAdmin(admin.ModelAdmin):
change_list_template = "track/check_orders.html"

list_display = ["record_id", "order_number", "tracking_nrs", "return_tracking_nrs", "tube_serials", "order_status", "ship_date"]

def get_urls(self):
urls = super().get_urls()
my_urls = [
path('check_order_status/', self.call_check_order_status),
]
return my_urls + urls

def call_check_order_status(self, request):
logger.info("Initiatied check for tracking info")
orders.check_orders_shipping_info()
logger.info("Tracking info check completed.")
return HttpResponseRedirect("../")

admin.site.register(Order, OrderAdmin)
33 changes: 33 additions & 0 deletions track/templates/track/check_orders.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends 'admin/change_list.html' %}

{% block object-tools %}

<style>
button.btn {
background-repeat: no-repeat;
background-position: right 7px center;
padding: 6px 12px;
display: block;
float: left;
background: var(--object-tools-bg);
color: var(--object-tools-fg);
font-weight: 400;
font-size: 0.6875rem;
text-transform: uppercase;
letter-spacing: 0.5px;
border-radius: 15px;
border-width: 0;
cursor: pointer;
}


</style>
<form action="check_order_status" method="POST">
{% csrf_token %}
<button class="btn" type="submit">Check Order Status</button>
</form>

</div>
<br />
{{ block.super }}
{% endblock %}