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.
restrict perms/codenames between site and central pharmacist
- Loading branch information
Showing
25 changed files
with
234 additions
and
122 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
23 changes: 23 additions & 0 deletions
23
edc_pharmacy/migrations/0054_historicalreceiveitem_task_id_receiveitem_task_id.py
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,23 @@ | ||
# Generated by Django 5.1.2 on 2024-11-27 16:33 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("edc_pharmacy", "0053_alter_location_managers_alter_historicalstock_lot_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="historicalreceiveitem", | ||
name="task_id", | ||
field=models.UUIDField(null=True), | ||
), | ||
migrations.AddField( | ||
model_name="receiveitem", | ||
name="task_id", | ||
field=models.UUIDField(null=True), | ||
), | ||
] |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -68,3 +68,6 @@ def allocate_stock( | |
obj.save() | ||
allocated += 1 | ||
return allocated, unallocated | ||
|
||
|
||
__all__ = ["allocate_stock"] |
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 |
---|---|---|
|
@@ -11,3 +11,6 @@ def blinded_user(request) -> bool: | |
return True | ||
# user is not blinded | ||
return False | ||
|
||
|
||
__all__ = ["blinded_user"] |
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,21 @@ | ||
from uuid import UUID | ||
|
||
from django.apps import apps as django_apps | ||
|
||
|
||
def create_new_stock_on_receive(receive_item_pk: UUID = None): | ||
receive_item_model_cls = django_apps.get_model("edc_pharmacy.receiveitem") | ||
stock_model_cls = django_apps.get_model("edc_pharmacy.stock") | ||
receive_item = receive_item_model_cls.objects.get(pk=receive_item_pk) | ||
for i in range(0, int(receive_item.qty)): | ||
stock_model_cls.objects.create( | ||
receive_item_id=receive_item.id, | ||
qty_in=1, | ||
qty_out=0, | ||
qty=1, | ||
product_id=receive_item.order_item.product.id, | ||
container_id=receive_item.container.id, | ||
location_id=receive_item.receive.location.id, | ||
confirmed=False, | ||
lot_id=receive_item.lot.id, | ||
) |
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,27 @@ | ||
from django.apps import apps as django_apps | ||
|
||
|
||
def get_codenames( | ||
codenames: list[str], | ||
view_only_models: list[str] | None = None, | ||
exclude_models: list[str] | None = None, | ||
) -> list[str]: | ||
"""Return a list of all codenames for the role. | ||
See auths.py | ||
""" | ||
view_only_models = view_only_models or [] | ||
exclude_models = exclude_models or [] | ||
for app_config in django_apps.get_app_configs(): | ||
if app_config.name in ["edc_pharmacy"]: | ||
for model_cls in app_config.get_models(): | ||
label_lower = model_cls._meta.label_lower | ||
app_name, model_name = label_lower.split(".") | ||
if label_lower in exclude_models: | ||
continue | ||
elif label_lower in view_only_models: | ||
codenames.append(f"{app_name}.view_{model_name}") | ||
else: | ||
for prefix in ["view_", "add_", "change_", "delete_"]: | ||
codenames.append(f"{app_name}.{prefix}{model_name}") | ||
return codenames |
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.