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
97 changed files
with
2,696 additions
and
793 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,5 +32,6 @@ | |
StockAdmin, | ||
StockRequestAdmin, | ||
StockRequestItemAdmin, | ||
StockTransferAdmin, | ||
SupplierAdmin, | ||
) |
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
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
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,18 @@ | ||
from uuid import uuid4 | ||
|
||
from django.contrib import admin | ||
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
|
||
|
||
@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) |
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,9 +1,30 @@ | ||
from __future__ import annotations | ||
|
||
from django.contrib import admin, messages | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
from django.utils.translation import gettext | ||
|
||
from ...utils import process_repack_request | ||
|
||
|
||
@admin.action(description="Process repack request") | ||
def process_repack_request_action(modeladmin, request, queryset): | ||
for repackage_obj in queryset: | ||
for i in range(0, int(repackage_obj.qty)): | ||
process_repack_request(repackage_obj) | ||
if queryset.count() > 1 or queryset.count() == 0: | ||
messages.add_message( | ||
request, | ||
messages.ERROR, | ||
gettext("Select one and only one item"), | ||
) | ||
else: | ||
repack_obj = queryset.first() | ||
if repack_obj.processed: | ||
messages.add_message( | ||
request, messages.ERROR, "Nothing to do. Repack request already processed" | ||
) | ||
else: | ||
process_repack_request(repack_obj) | ||
url = reverse("edc_pharmacy_admin:edc_pharmacy_repackrequest_changelist") | ||
url = f"{url}?q={repack_obj.id}" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from __future__ import annotations | ||
|
||
from django.contrib import admin, messages | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
from django.utils.translation import gettext | ||
|
||
|
||
@admin.action(description="Transfer stock to site") | ||
def transfer_stock_action(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: | ||
url = reverse( | ||
"edc_pharmacy:transfer_stock_url", kwargs={"stock_transfer": queryset.first().pk} | ||
) | ||
return HttpResponseRedirect(url) | ||
return None |
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
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,14 @@ | ||
from django.core.handlers.wsgi import WSGIRequest | ||
from edc_randomization.blinding import user_is_blinded_from_request | ||
|
||
|
||
def remove_fields_for_blinded_users(request: WSGIRequest, fields: tuple) -> tuple: | ||
"""You need to secure custom SimpleListFilters yourself""" | ||
if user_is_blinded_from_request(request): | ||
fields = list(fields) | ||
for f in fields: | ||
if isinstance(f, str): | ||
if "assignment" in f or "lot_no" in f: | ||
fields.remove(f) | ||
fields = tuple(fields) | ||
return fields |
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
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.