Skip to content
Open
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
15 changes: 11 additions & 4 deletions bootstrap/ansible/main.copyme
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ plugin_hardware_procurements_enabled: false

# A mapping from short names of data sources to associated module paths.
plugin_hardware_procurements_data_source_modules_by_short_name:
brc_google_sheets: 'coldfront.plugins.hardware_procurements.utils.data_sources.backends.google_sheets.BRCGoogleSheetsDataSourceBackend'
cached: 'coldfront.plugins.hardware_procurements.utils.data_sources.backends.cached.CachedDataSourceBackend'
dummy: 'coldfront.plugins.hardware_procurements.utils.data_sources.backends.dummy.DummyDataSourceBackend'
google_sheets: 'coldfront.plugins.hardware_procurements.utils.data_sources.backends.google_sheets.GoogleSheetsDataSourceBackend'
lrc_google_sheets: 'coldfront.plugins.hardware_procurements.utils.data_sources.backends.google_sheets.LRCGoogleSheetsDataSourceBackend'

# # TODO: Uncomment only the section relevant to the specified data source.

Expand All @@ -177,13 +178,13 @@ plugin_hardware_procurements_data_source_modules_by_short_name:
# data_source: 'cached'
# data_source_options:
# cache_key: 'hardware_procurements_data'
# cached_data_source: 'google_sheets'
# cached_data_source: 'brc_google_sheets'
# cached_data_source_options:
# config_file_path: '/path/to/data-source-options-file.json'

# # Settings: 'google_sheets' backend.
# # Settings: 'brc_google_sheets' backend.
# plugin_hardware_procurements:
# data_source: 'google_sheets'
# data_source: 'brc_google_sheets'
# data_source_options:
# config_file_path: '/path/to/data-source-options-file.json'

Expand All @@ -192,6 +193,12 @@ plugin_hardware_procurements_data_source_modules_by_short_name:
# data_source: 'dummy'
# data_source_options:

# # Settings: 'lrc_google_sheets' backend.
# plugin_hardware_procurements:
# data_source: 'lrc_google_sheets'
# data_source_options:
# config_file_path: '/path/to/data-source-options-file.json'

#------------------------------------------------------------------------------
# User-facing strings
#------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "common/base.html" %}
{% load static %}
{% load common_tags %}
{% load feature_flags %}


{% block title %}
Expand Down Expand Up @@ -141,12 +142,36 @@ <h2><i class="fas fa-list"></i> Hardware Procurement Information</h2>
{% endif %}
</td>
</tr>
{% flag_enabled 'BRC_ONLY' as brc_only %}
{% if brc_only %}
<tr>
<th scope="row" class="text-nowrap">
JIRA Ticket
</th>
<td>{{ procurement|get_value_from_dict:"jira_ticket" }}</td>
</tr>
{% endif %}
{% flag_enabled 'LRC_ONLY' as lrc_only %}
{% if lrc_only %}
<tr>
<th scope="row" class="text-nowrap">
Project ID
</th>
<td>{{ procurement|get_value_from_dict:"project_id" }}</td>
</tr>
<tr>
<th scope="row" class="text-nowrap">
Requisition ID
</th>
<td>{{ procurement|get_value_from_dict:"requisition_id" }}</td>
</tr>
<tr>
<th scope="row" class="text-nowrap">
PO / PCard
</th>
<td>{{ procurement|get_value_from_dict:"po_pcard" }}</td>
</tr>
{% endif %}
{% endwith %}
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,49 @@
import csv
import json
import os
import pytest

from .utils import get_resource_absolute_file_path
from .utils import get_tsv_data
from .utils import MockUser


@pytest.fixture
def expected_hardware_procurements_data():
def brc_expected_hardware_procurements_data():
"""Return a list of dicts representing the expected output of the
backend's fetch method, given the test data file as input, read from
a JSON file."""
test_dir_path = os.path.dirname(__file__)
data_file_path = os.path.join(
test_dir_path,
'resources',
'test_google_sheets_data_source_backend_expected_output_data.json')
backend's fetch method, given the BRC test data file as input, read
from a JSON file."""
data_file_path = get_resource_absolute_file_path(
'test_brc_google_sheets_data_source_backend_expected_output_data.json')
with open(data_file_path, 'r') as f:
return json.load(f)


@pytest.fixture
def google_sheet_data():
"""Return a list of lists containing test data, read from a TSV
def brc_google_sheet_data():
"""Return a list of lists containing BRC test data, read from a TSV
file, excluding the header."""
test_dir_path = os.path.dirname(__file__)
data_file_path = os.path.join(
test_dir_path,
'resources',
'test_google_sheets_data_source_backend_data.tsv')
data_file_path = get_resource_absolute_file_path(
'test_brc_google_sheets_data_source_backend_data.tsv')
return get_tsv_data(data_file_path)


@pytest.fixture
def lrc_expected_hardware_procurements_data():
"""Return a list of dicts representing the expected output of the
backend's fetch method, given the LRC test data file as input, read
from a JSON file."""
data_file_path = get_resource_absolute_file_path(
'test_lrc_google_sheets_data_source_backend_expected_output_data.json')
with open(data_file_path, 'r') as f:
reader = csv.reader(f, delimiter='\t')
data = [row for row in reader]
return data[1:]
return json.load(f)


@pytest.fixture
def lrc_google_sheet_data():
"""Return a list of lists containing LRC test data, read from a TSV
file, excluding the header."""
data_file_path = get_resource_absolute_file_path(
'test_lrc_google_sheets_data_source_backend_data.tsv')
return get_tsv_data(data_file_path)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Status Initial Inquiry Date PI Name (first last) PI Email POC Name (optional) POC Email (optional) Hardware Type Hardware Specification Details Procurement Start Date Project ID Requisition ID PO/PCard Order Received Date Installed Date Expected Retirement Date Buyer
Active 01/01/1970 PI One pi1@email.com POC One poc1@email.com CPU CPU Details 1 01/02/1970 000000-001 00001 00001 01/03/1970 PI
Complete 01/01/1970 PI Two pi2@email.com Storage Storage Details 1 01/02/1970 000000-002 00002 00002 01/03/1970 01/04/1970 01/04/1975 PI
Active 01/01/1970 PI One pi1@email.com POC Two poc2@email.com CPU CPU Details 2 000000-003 00003 00003 PI
Inactive 01/01/1970 PI One, PI Two pi1@email.com, pi2@email.com GPU GPU Details 1 PI
Retired 01/01/1970 PI Two pi2@email.com POC One, POC Two poc1@email.com, poc2@email.com Storage Storage Details 2 01/02/1970 000000-004 00004 00004 01/03/1970 01/04/1970 01/04/1972 PI
Retired 01/01/1970 Non PI One non_pi1@email.com Storage Storage Details 2 01/02/1970 000000-005 00005 00005 01/03/1970 01/04/1970 01/04/1972 Non-PI
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[
{
"id": "9b8aaee5",
"data": {
"status": "Pending",
"initial_inquiry_date": "1970-01-01",
"pi_names": "PI One",
"pi_emails": ["pi1@email.com"],
"poc_names": "POC One",
"poc_emails": ["poc1@email.com"],
"hardware_type": "CPU",
"hardware_specification_details": "CPU Details 1",
"procurement_start_date": "1970-01-02",
"project_id": "000000-001",
"requisition_id": "00001",
"po_pcard": "00001",
"order_received_date": "1970-01-03",
"installed_date": null,
"expected_retirement_date": null,
"buyer": "PI"
}
},
{
"id": "a4eecf6e",
"data": {
"status": "Complete",
"initial_inquiry_date": "1970-01-01",
"pi_names": "PI Two",
"pi_emails": ["pi2@email.com"],
"poc_names": "",
"poc_emails": [],
"hardware_type": "Storage",
"hardware_specification_details": "Storage Details 1",
"procurement_start_date": "1970-01-02",
"project_id": "000000-002",
"requisition_id": "00002",
"po_pcard": "00002",
"order_received_date": "1970-01-03",
"installed_date": "1970-01-04",
"expected_retirement_date": "1975-01-04",
"buyer": "PI"
}
},
{
"id": "7b79f48f",
"data": {
"status": "Pending",
"initial_inquiry_date": "1970-01-01",
"pi_names": "PI One",
"pi_emails": ["pi1@email.com"],
"poc_names": "POC Two",
"poc_emails": ["poc2@email.com"],
"hardware_type": "CPU",
"hardware_specification_details": "CPU Details 2",
"procurement_start_date": null,
"project_id": "000000-003",
"requisition_id": "00003",
"po_pcard": "00003",
"order_received_date": null,
"installed_date": null,
"expected_retirement_date": null,
"buyer": "PI"
}
},
{
"id": "160d5698",
"data": {
"status": "Inactive",
"initial_inquiry_date": "1970-01-01",
"pi_names": "PI One, PI Two",
"pi_emails": ["pi1@email.com", "pi2@email.com"],
"poc_names": "",
"poc_emails": [],
"hardware_type": "GPU",
"hardware_specification_details": "GPU Details 1",
"procurement_start_date": null,
"project_id": "",
"requisition_id": "",
"po_pcard": "",
"order_received_date": null,
"installed_date": null,
"expected_retirement_date": null,
"buyer": "PI"
}
},
{
"id": "cc32e9da",
"data": {
"status": "Retired",
"initial_inquiry_date": "1970-01-01",
"pi_names": "PI Two",
"pi_emails": ["pi2@email.com"],
"poc_names": "POC One, POC Two",
"poc_emails": ["poc1@email.com", "poc2@email.com"],
"hardware_type": "Storage",
"hardware_specification_details": "Storage Details 2",
"procurement_start_date": "1970-01-02",
"project_id": "000000-004",
"requisition_id": "00004",
"po_pcard": "00004",
"order_received_date": "1970-01-03",
"installed_date": "1970-01-04",
"expected_retirement_date": "1972-01-04",
"buyer": "PI"
}
}
]
Loading