forked from botswana-harvard/edc-pharmacy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
100 changed files
with
7,401 additions
and
9,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
from .allocate_stock_to_subject import allocate_stock_to_subject | ||
from .confirm_stock import confirm_repacked_stock_action, confirm_stock_action | ||
from .create_stock_request_items import create_stock_request_items_action | ||
from .confirm_stock import ( | ||
confirm_received_stock_action, | ||
confirm_repacked_stock_action, | ||
confirm_stock_from_instance, | ||
confirm_stock_from_queryset, | ||
) | ||
from .delete_items_for_stock_request import delete_items_for_stock_request_action | ||
from .go_to_add_repack_request import go_to_add_repack_request_action | ||
from .go_to_allocations import go_to_allocations | ||
from .go_to_stock import go_to_stock | ||
from .print_labels import print_labels | ||
from .prepare_stock_request_items import prepare_stock_request_items_action | ||
from .print_labels import print_labels, print_labels_from_repack_request | ||
from .print_stock_labels import print_stock_labels | ||
from .process_repack_request import process_repack_request_action | ||
from .transfer_stock import transfer_stock_action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from django.contrib import admin, messages | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
from django.utils.translation import gettext | ||
|
||
if TYPE_CHECKING: | ||
|
||
from ...models import StockRequest | ||
|
||
|
||
@admin.display(description="Prepare stock request items") | ||
def prepare_stock_request_items_action(modeladmin, request, queryset): | ||
""" | ||
1. is there an open unprocess stock request? | ||
2. what stock is available at the site? | ||
3. what stock is available at central? | ||
""" | ||
if queryset.count() > 1 or queryset.count() == 0: | ||
messages.add_message( | ||
request, | ||
messages.ERROR, | ||
gettext("Select one and only one item"), | ||
) | ||
else: | ||
stock_request: StockRequest = queryset.first() | ||
url = reverse( | ||
"edc_pharmacy:review_stock_request_url", | ||
kwargs={"stock_request": stock_request.pk}, | ||
) | ||
return HttpResponseRedirect(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,46 @@ | ||
from uuid import uuid4 | ||
|
||
from django.contrib import admin | ||
from django.contrib import admin, messages | ||
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
from django.utils.translation import gettext | ||
|
||
from edc_pharmacy.models import Stock | ||
|
||
|
||
@admin.action(description="Print labels") | ||
def print_labels(modeladmin, request, queryset): | ||
selected = request.POST.getlist(ACTION_CHECKBOX_NAME) | ||
session_uuid = str(uuid4()) | ||
request.session[session_uuid] = selected | ||
url = reverse( | ||
"edc_pharmacy:print_labels_url", | ||
kwargs={"session_uuid": session_uuid, "model": "stock"}, | ||
) | ||
return HttpResponseRedirect(url) | ||
if len(selected) > 0: | ||
session_uuid = str(uuid4()) | ||
request.session[session_uuid] = selected | ||
url = reverse( | ||
"edc_pharmacy:print_labels_url", | ||
kwargs={"session_uuid": session_uuid, "model": "stock"}, | ||
) | ||
return HttpResponseRedirect(url) | ||
return None | ||
|
||
|
||
@admin.action(description="Print labels") | ||
def print_labels_from_repack_request(modeladmin, request, queryset): | ||
if queryset.count() > 1 or queryset.count() == 0: | ||
messages.add_message( | ||
request, | ||
messages.ERROR, | ||
gettext("Select one and only one item"), | ||
) | ||
else: | ||
session_uuid = str(uuid4()) | ||
stock_qs = Stock.objects.values_list("pk", flat=True).filter( | ||
repack_request=queryset.first() | ||
) | ||
if stock_qs.exists(): | ||
request.session[session_uuid] = [o for o in stock_qs] | ||
url = reverse( | ||
"edc_pharmacy:print_labels_url", | ||
kwargs={"session_uuid": session_uuid, "model": "stock"}, | ||
) | ||
return HttpResponseRedirect(url) | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.