Skip to content

Commit

Permalink
- lms/ping
Browse files Browse the repository at this point in the history
- add laptop version to laptop logs
  • Loading branch information
frankyrumple committed Jun 16, 2020
1 parent efc11cd commit 70a9514
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
13 changes: 11 additions & 2 deletions web2py/applications/smc/controllers/lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import urllib
import json
from gluon import current
from datetime import datetime

import paramiko

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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'
Expand Down
17 changes: 17 additions & 0 deletions web2py/applications/smc/controllers/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():

Expand Down
2 changes: 1 addition & 1 deletion web2py/applications/smc/models/x_app_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions web2py/applications/smc/models/x_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 70a9514

Please sign in to comment.