From 70a9514b53d23bf5c0eb49213ea0852e37bf95c0 Mon Sep 17 00:00:00 2001 From: Ray Pulsipher Date: Mon, 15 Jun 2020 23:33:55 -0700 Subject: [PATCH] - lms/ping - add laptop version to laptop logs --- web2py/applications/smc/controllers/lms.py | 13 +++++++++++-- web2py/applications/smc/controllers/test.py | 17 +++++++++++++++++ web2py/applications/smc/models/x_app_models.py | 2 +- web2py/applications/smc/models/x_fixtures.py | 7 +++++-- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/web2py/applications/smc/controllers/lms.py b/web2py/applications/smc/controllers/lms.py index 700db2f3..791bbd8d 100644 --- a/web2py/applications/smc/controllers/lms.py +++ b/web2py/applications/smc/controllers/lms.py @@ -6,6 +6,7 @@ import urllib import json from gluon import current +from datetime import datetime import paramiko @@ -32,7 +33,8 @@ def test(): #@auth.requires_membership("Administrators") -@auth.requires(auth.has_membership('Faculty') or auth.has_membership('Administrators')) +#@auth.requires(auth.has_membership('Faculty') or auth.has_membership('Administrators')) +@auth.requires_permission("credential") def verify_ope_account_in_smc(): response.view = 'generic.json' db = current.db @@ -77,8 +79,10 @@ def verify_ope_account_in_smc(): smc_version=smc_version) +# TODO - Setup permission and add facult/admins to credential permission #@auth.requires_membership("Administrators") -@auth.requires(auth.has_membership('Faculty') or auth.has_membership('Administrators')) +#@auth.requires(auth.has_membership('Faculty') or auth.has_membership('Administrators')) +@auth.requires_permission("credential") def credential_student(): response.view = 'generic.json' db = current.db @@ -143,6 +147,7 @@ def credential_student(): bios_manufacturer=info["bios_manufacturer"], admin_password_status=info["cs_admin_password_status"], extra_info=json.dumps(info), + laptop_version=info["mgmt_version"], ) else: # Update existing record @@ -158,6 +163,7 @@ def credential_student(): bios_manufacturer=info["bios_manufacturer"], admin_password_status=info["cs_admin_password_status"], extra_info=json.dumps(info), + laptop_version=info["mgmt_version"], ) db.commit() except Exception as ex: @@ -169,6 +175,9 @@ def credential_student(): return dict(key=key, msg=msg, hash=hash, full_name=full_name, canvas_url=canvas_url, admin_hash=admin_hash) +def ping(): + server_time = datetime.now() + return dict(server_time=server_time) def get_firewall_list(): response.view = 'default/index.json' diff --git a/web2py/applications/smc/controllers/test.py b/web2py/applications/smc/controllers/test.py index aa8452dc..4287d2e6 100644 --- a/web2py/applications/smc/controllers/test.py +++ b/web2py/applications/smc/controllers/test.py @@ -30,6 +30,23 @@ import module_reload ret = module_reload.ReloadModules() + +@auth.requires_permission("credential") +def credential(): + return dict(message="It Worked!") + +@auth.requires_membership("Administrators") +def test_credential(): + auth.add_group("Laptop Logs", "test...") + a_id = auth.id_group("Administrators") + f_id = auth.id_group("Faculty") + + auth.add_permission(name='credential', group_id=a_id) + auth.add_permission(name='credential', group_id=f_id) + + + return locals() + @auth.requires_membership("Administrators") def dev_key_test(): diff --git a/web2py/applications/smc/models/x_app_models.py b/web2py/applications/smc/models/x_app_models.py index e66e1429..ab48c7db 100644 --- a/web2py/applications/smc/models/x_app_models.py +++ b/web2py/applications/smc/models/x_app_models.py @@ -565,10 +565,10 @@ Field('bios_version', 'string', default=""), Field('bios_manufacturer', 'string', default=""), Field('admin_password_status', 'string', default=""), - Field('archived', 'boolean', default=False), Field('extra_info', 'json'), auth.signature, + Field('laptop_version', 'string', default='') ) db.define_table("ope_laptop_logs", diff --git a/web2py/applications/smc/models/x_fixtures.py b/web2py/applications/smc/models/x_fixtures.py index 1f429dfa..9aebf3eb 100644 --- a/web2py/applications/smc/models/x_fixtures.py +++ b/web2py/applications/smc/models/x_fixtures.py @@ -19,11 +19,14 @@ g = db(db.auth_group.role=='Media Upload').select().first() if (g == None): db.auth_group.insert(role='Media Upload', description='Users with permission to upload media files') - db.commit() g = db(db.auth_group.role=='Laptop Logs').select().first() if (g == None): db.auth_group.insert(role='Laptop Logs', description='Users with permission to view laptop log files') - db.commit() + + # Make sure permissions are setup for each group + auth.add_permission(name='credential', group_id=auth.id_group(role='Administrators')) + auth.add_permission(name='credential', group_id=auth.id_group(role='Faculty')) + db.commit() new_admin = False # Starting Users