mirror of https://github.com/CIRCL/AIL-framework
chg: [update] create default org + update trackers/retro_hunts/investigations creator_org
parent
cbe09c87c4
commit
7bf609b0e8
|
@ -90,6 +90,12 @@ class Investigation(object):
|
||||||
def __init__(self, investigation_uuid):
|
def __init__(self, investigation_uuid):
|
||||||
self.uuid = investigation_uuid
|
self.uuid = investigation_uuid
|
||||||
|
|
||||||
|
def _get_field(self, field):
|
||||||
|
return r_tracking.hget(f'investigations:data:{self.uuid}', field)
|
||||||
|
|
||||||
|
def _set_field(self, field, value):
|
||||||
|
r_tracking.hset(f'investigations:data:{self.uuid}', field, value)
|
||||||
|
|
||||||
def exists(self):
|
def exists(self):
|
||||||
return r_tracking.exists(f'investigations:data:{self.uuid}')
|
return r_tracking.exists(f'investigations:data:{self.uuid}')
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ sys.path.append(os.environ['AIL_HOME'])
|
||||||
# Import Project packages
|
# Import Project packages
|
||||||
##################################
|
##################################
|
||||||
from update.bin.ail_updater import AIL_Updater
|
from update.bin.ail_updater import AIL_Updater
|
||||||
|
from lib import ail_orgs
|
||||||
from lib import ail_users
|
from lib import ail_users
|
||||||
from lib import Investigations
|
from lib import Investigations
|
||||||
from lib.ConfigLoader import ConfigLoader
|
from lib.ConfigLoader import ConfigLoader
|
||||||
|
@ -35,23 +36,35 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# USERS
|
# USERS
|
||||||
print('Updating Users ...')
|
print('Updating Users ...')
|
||||||
|
# Create Default Org
|
||||||
|
org = ail_orgs.create_default_org()
|
||||||
|
org_uuid = org.get_uuid()
|
||||||
|
|
||||||
for user_id in ail_users.get_users(): # TODO ORG
|
for user_id in ail_users.get_users(): # TODO ORG
|
||||||
|
ail_users.edit_user('admin@admin.test', user_id, org_uuid=org_uuid)
|
||||||
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'creator', 'admin@admin.test')
|
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'creator', 'admin@admin.test')
|
||||||
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'created_at', date)
|
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'created_at', date)
|
||||||
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'last_edit', date)
|
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'last_edit', date)
|
||||||
|
# ADD User to ORG
|
||||||
|
org.add_user(user_id)
|
||||||
|
|
||||||
# INVESTIGATIONS
|
# INVESTIGATIONS
|
||||||
print('Updating Investigations ...')
|
print('Updating Investigations ...')
|
||||||
for inv_uuid in Investigations.get_all_investigations(): # TODO Creator ORG
|
for inv_uuid in Investigations.get_all_investigations():
|
||||||
inv = Investigations.Investigation(inv_uuid)
|
inv = Investigations.Investigation(inv_uuid)
|
||||||
inv.set_level(1, None)
|
inv.set_level(1, None)
|
||||||
|
inv._set_field('creator_org', org_uuid)
|
||||||
|
|
||||||
# TODO Trackers
|
print('Updating Trackers ...')
|
||||||
|
for tracker_uuid in Tracker.get_trackers():
|
||||||
|
tracker = Tracker.Tracker(tracker_uuid)
|
||||||
|
tracker._set_field('creator_org', org_uuid)
|
||||||
|
|
||||||
print('Updating Retro Hunts ...')
|
print('Updating Retro Hunts ...')
|
||||||
for retro_hunt_uuid in Tracker.get_all_retro_hunt_tasks(): # TODO Creator ORG
|
for retro_hunt_uuid in Tracker.get_all_retro_hunt_tasks():
|
||||||
retro = Tracker.RetroHunt(retro_hunt_uuid)
|
retro = Tracker.RetroHunt(retro_hunt_uuid)
|
||||||
retro.set_level(1, None)
|
retro.set_level(1, None)
|
||||||
|
retro._set_field('creator_org', org_uuid)
|
||||||
|
|
||||||
chats_viewer.fix_chats_with_messages()
|
chats_viewer.fix_chats_with_messages()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue