forked from ubccr/coldfront
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables gsheet Integration for condo procurement
- Implement fetching and caching for "Savio" and "LRC" tabs in gsheets.py - Parse decommission dates and flag alerts based on DECOMMISSION_WARNING_DAYS - Display decommission alerts in a vertical card layout - Add decommission_details view and URL route - Update README with Google Sheets setup and configuration instructions closes #546
- Loading branch information
1 parent
99d70f3
commit 81b8f0f
Showing
10 changed files
with
342 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## Google Sheets Integration | ||
|
||
This project uses Google Sheets to track acitivites such as: | ||
- HPC hardware procurement and decommission information. | ||
- TBD | ||
|
||
|
||
|
||
### Setup | ||
|
||
1. **Service Account & Credentials:** | ||
- Create a Google Cloud service account with Sheets API (readonly) access. | ||
- Set the environment variable `GOOGLE_SERVICE_ACCOUNT_JSON_PATH` to the path of your JSON credentials. | ||
- Set `DECOMISSION_SHEET_ID` to your target spreadsheet's ID. | ||
|
||
2. **Django Settings:** | ||
- **`DECOMMISSION_WARNING_DAYS`**: Days before the decommission date to trigger a warning (default: `30`). | ||
- **`GSHEETS_CACHE_TIMEOUT`**: Cache duration in seconds (default: `86400` for 24 hours). | ||
- **`GSHEETS_DISABLE_CACHE`**: Set to `True` during development/testing to disable caching. | ||
|
||
3. ** Docker-compose environment:** | ||
- Add the following to your `docker-compose.yml` file: | ||
```yaml | ||
services: | ||
web: | ||
environment: | ||
- GOOGLE_SERVICE_ACCOUNT_JSON_PATH=/path/to/your/credentials.json | ||
- DECOMISSION_SHEET_ID=your-spreadsheet-id | ||
- GSHEETS_DISABLE_CACHE=True | ||
# ... | ||
``` | ||
|
||
### Google Sheets Format | ||
|
||
- **Tabs:** The spreadsheet must include two tabs: **Savio** and **LRC**. | ||
- **Header:** The header is on row 3 and must include at least: | ||
- `PI Email` | ||
- `Expected Decomission Date` (in MM/DD/YYYY format) | ||
- **Data Rows:** Data starts from row 4. | ||
|
||
### HPCS Hardware Procurement Tracking | ||
|
||
Upon user login, the application: | ||
- Checks both the **Savio** and **LRC** tabs for a record where `PI Email` matches the logged-in user's email. | ||
- Parses the `Expected Decomission Date` and, if the current date is within `DECOMMISSION_WARNING_DAYS` of that date, flags the record. | ||
- Displays decommission alerts using a card layout that lists each field vertically for clear, readable details. | ||
|
||
--- | ||
|
||
This summary should help users and developers quickly understand and set up the Google Sheets integration and the HPCS Hardware Procurement Tracking functionality. |
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
39 changes: 39 additions & 0 deletions
39
coldfront/core/portal/templates/portal/decommission_details.html
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,39 @@ | ||
{% extends "common/base.html" %} | ||
{% load static %} | ||
|
||
{% block title %} | ||
Condo Decommission Details | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container my-4"> | ||
<h1>Allocated Condos</h1> | ||
<hr> | ||
{% if decommission_alerts %} | ||
{% for alert in decommission_alerts %} | ||
<div class="card mb-4"> | ||
<div class="card-header"> | ||
<strong>Cluster:</strong> {{ alert.sheet }} | ||
</div> | ||
<div class="card-body"> | ||
{# Iterate over the record dictionary to display each field #} | ||
{% for key, value in alert.record.items %} | ||
<div class="row mb-2"> | ||
<div class="col-sm-4 font-weight-bold"> | ||
{{ key }}: | ||
</div> | ||
<div class="col-sm-8"> | ||
{{ value }} | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
{% endfor %} | ||
{% else %} | ||
<div class="alert alert-info"> | ||
No decommission alerts found! | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock %} |
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.