Skip to content

Commit

Permalink
subscription relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeseibel committed May 4, 2024
1 parent 23d6bdb commit ce4d1b8
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 26 deletions.
8 changes: 8 additions & 0 deletions endorsement/fixtures/test_data/itbill_provision.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@
"subscription": 2,
"current_quantity": 5
}
},
{
"model": "endorsement.itbillprovision",
"pk": 3,
"fields": {
"subscription": 3,
"current_quantity": 1
}
}
]
13 changes: 12 additions & 1 deletion endorsement/fixtures/test_data/itbill_quantity.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"provision": 1,
"quantity": 2,
"start_date": "2024-01-01",
"end_date": "2024-12-31",
"end_date": "2024-12-29",
"stage": null
}
},
Expand All @@ -20,5 +20,16 @@
"end_date": null,
"stage": null
}
},
{
"model": "endorsement.itbillquantity",
"pk": 3,
"fields": {
"provision": 3,
"quantity": 1,
"start_date": null,
"end_date": null,
"stage": null
}
}
]
10 changes: 10 additions & 0 deletions endorsement/fixtures/test_data/itbill_subscription.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@
"query_priority": 0,
"query_datetime": null
}
},
{
"model": "endorsement.itbillsubscription",
"pk": 3,
"fields": {
"key_remote": "spw48mh5yutht3431v4d8olsx04yi8dz",
"state": 1,
"query_priority": 0,
"query_datetime": null
}
}
]
11 changes: 11 additions & 0 deletions endorsement/fixtures/test_data/shared_drive.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,16 @@
"drive_quota": 4,
"members": [1, 2, 4, 5, 7, 8, 9, 10, 11]
}
},
{
"model": "endorsement.shareddrive",
"pk": 6,
"fields": {
"drive_id": "g2ns3fxmo2x8wo6j7e5gloet",
"drive_name": "UX Design Team Drive",
"drive_usage": 359,
"drive_quota": 3,
"members": [1, 4, 5, 7, 10, 11]
}
}
]
19 changes: 19 additions & 0 deletions endorsement/fixtures/test_data/shared_drive_record.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,24 @@
"datetime_expired": null,
"is_deleted": null
}
},
{
"model": "endorsement.shareddriverecord",
"pk": 6,
"fields": {
"shared_drive": 6,
"subscription": 3,
"acted_as": null,
"datetime_created": "2024-02-12T17:41:28+00:00",
"datetime_emailed": null,
"datetime_notice_1_emailed": null,
"datetime_notice_2_emailed": null,
"datetime_notice_3_emailed": null,
"datetime_notice_4_emailed": null,
"datetime_accepted": "2024-02-12T17:41:28+00:00",
"datetime_renewed": null,
"datetime_expired": null,
"is_deleted": null
}
}
]
5 changes: 4 additions & 1 deletion endorsement/management/commands/initialize_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

from django.core.management.base import BaseCommand
from django.core.management import call_command
from endorsement.models import SharedDriveRecord
from endorsement.models import SharedDriveRecord, ITBillQuantity
from datetime import datetime, timezone, timedelta


class Command(BaseCommand):

def handle(self, *args, **options):
# reset quantities
ITBillQuantity.objects.all().delete()

call_command('loaddata', 'test_data/accessright.json')
call_command('loaddata', 'test_data/accessee.json')
call_command('loaddata', 'test_data/accessor.json')
Expand Down
14 changes: 10 additions & 4 deletions endorsement/static/endorsement/css/critical.scss
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,17 @@ a {
}
.endorsed-netid, .access-mailbox { width: 12rem; white-space: nowrap; }
.endorsed-name, .access-mailbox-name { border-top: none; border-right: 1px solid #ddd; }
.endorsed-status-icon, { width: 20px; }
.shared-drive-status-icon { width: 24px; }
.endorsed-status, .shared-drive-status, .shared-drive-quota {
.endorsed-status-icon, .shared-drive-status-icon { width: 26px; }
.endorsed-status, .shared-drive-status {
padding-left: 6px;
width: 15rem;
p { font-size: smaller; width: 10rem; }
p { font-size: smaller; width: 10rem; margin-bottom: 0px; }
}
.shared-drive-quota { padding-left: 24px; width: 12rem;
div { position: relative; width: 14rem; left: -.85rem;
div:first-child { clear: left; float: left; width: 1.65rem; }
div:last-child { font-size: smaller; float: left; width: 10rem; }
}
}
.endorsed-reason { width: 13rem; }
.endorsed-action, .shared-drive-action { width: 12rem; white-space: nowrap; }
Expand Down
39 changes: 21 additions & 18 deletions endorsement/static/endorsement/js/tab/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,31 @@ var ManageSharedDrives = (function () {
drive.expiration_days = expiration.diff(now, 'days');
drive.expiration_from_now = expiration.from(now);
drive.in_flight = (drive.subscription && drive.subscription.query_priority === 'high');
drive.future_quotas = [];
drive.quota_notes = [{
is_capped: drive.drive.drive_usage > drive.drive.drive_quota.quota_limit
}];

if (drive.subscription) {
$.each(drive.subscription.provisions, function () {
$.each(this.quantities, function () {
var starting = moment(this.start_date),
ending = moment(this.end_date),
is_future = starting.diff(now) > 0,
is_ending = starting.diff(now) < 0 && ending.diff(now) > 0,
is_increasing = this.quota_limit > drive.drive.drive_quota.quota_limit,
is_decreasing = this.quota_limit < drive.drive.drive_quota.quota_limit,
is_changing = (is_future || is_ending);
var starting = this.start_date ? moment(this.start_date) : null,
ending = this.end_date ? moment(this.end_date): null,
is_future = starting && starting.diff(now) > 0,
is_ending = starting && ending && starting.diff(now) < 0 && ending.diff(now) > 0,
is_increasing = this.quota_limit > drive.drive.drive_quota.quota_limit,
is_decreasing = this.quota_limit < drive.drive.drive_quota.quota_limit,
is_changing = (is_future || is_ending);

drive.future_quotas.push({
is_future: is_future,
is_ending: is_ending,
quota_limit: this.quota_limit,
is_increasing: is_increasing,
is_decreasing: is_decreasing,
is_changing: is_changing,
start_date: moment(this.start_date).format('M/D/YYYY'),
end_date: moment(this.end_date).format('M/D/YYYY')
});
drive.quota_notes.push({
is_future: is_future,
is_ending: is_ending,
quota_limit: this.quota_limit,
is_increasing: is_increasing && is_future,
is_decreasing: is_decreasing && is_future,
is_changing: is_changing,
start_date: moment(this.start_date).format('M/D/YYYY'),
end_date: moment(this.end_date).format('M/D/YYYY')
});
});
});
}
Expand Down
17 changes: 16 additions & 1 deletion endorsement/templates/handlebars/tab/drives/google.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,22 @@
<p>{{#or drive.drive_quota.is_subsidized subscription}}Renew{{else}}Select quota{{/or}} by {{expiration_date}}{{#lte expiration_days 90}}<br />({{expiration_from_now}}){{/lte}}</p>
</td>
<td class="shared-drive-est-usage">{{drive.drive_usage}}GB</td>
<td class="shared-drive-quota">{{drive.drive_quota.quota_limit}}GB{{#each future_quotas}}{{#if is_changing}}<p>{{#if is_ending}}Ending on {{end_date}}{{else}}{{#if is_future}}{{#if is_increasing}}In{{else}}De{{/if}}creasing to {{quota_limit}}GB on {{start_date}}{{/if}}{{/if}}</p>{{/if}}{{/each}}</td>
</td>
<td class="shared-drive-quota">{{drive.drive_quota.quota_limit}}GB
{{#each quota_notes}}
{{#if is_capped}}
<div><div><i class="fa fa-exclamation-circle text-danger"></i></div><div class="text-danger">Drive capped: usage is greater than current quota. Delete data or increase quota to resolve.</div></div>
{{else}}
{{#if is_ending}}
<div><div>&nbsp;</div><div>Ending on {{end_date}}</div></div>
{{else}}
{{#or is_increasing is_decreasing}}
<div><div>&nbsp;</div><div>{{#if is_increasing}}In{{else}}De{{/if}}creasing to {{quota_limit}}GB on {{start_date}}</div></div>
{{/or}}
{{/if}}
{{/if}}
{{/each}}
</td>
<td class="shared-drive-members">
<ul class="comma-list">
{{#gt drive.members.length 5}}
Expand Down
2 changes: 1 addition & 1 deletion endorsement/test/api/test_shared_drives.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_shared_drives(self):
response = self.client.get(url)
self.assertEquals(response.status_code, 200)
data = json.loads(response.content)
self.assertEqual(len(data['drives']), 5)
self.assertEqual(len(data['drives']), 6)

def test_no_shared_drives(self):
self.set_user('jinter')
Expand Down

0 comments on commit ce4d1b8

Please sign in to comment.