def storeSettings(request): values = {} database_columns = ['app_id', 'lab_id', 'service_id', 'enabled', 'activity_probe', 'sms_probe', 'call_log_probe', 'bluetooth_probe', 'wifi_probe', 'simple_location_probe', 'screen_probe', 'running_applications_probe', 'hardware_info_probe', 'app_usage_probe'] if request.method == "POST": data = json.loads(request.raw_post_data) datastore_owner = data.get(u'datastore_owner') profile = Profile.objects.get(uuid = datastore_owner) for column in database_columns: if 'probe' in column or 'enabled' in column: values[column] = True if data.get(column) == 1 else False else: values[column] = data.get(column) #settings, created = Settings.objects.get_or_create(datastore_owner = profile, app_id = values['app_id'], lab_id = values['lab_id'], service_id = values['service_id'], enabled = values['enabled'], activity_probe = values['activity_probe'], sms_probe = values['sms_probe'], call_log_probe = values['call_log_probe'], bluetooth_probe = values['bluetooth_probe'], wifi_probe = values['wifi_probe'], simple_location_probe = values['simple_location_probe'], screen_probe = values['screen_probe'], running_applications_probe = values['running_applications_probe'], hardware_info_probe = values['hardware_info_probe'], app_usage_probe = values['app_usage_probe']) #settings.save() settings, created = Settings.objects.get_or_create(datastore_owner = profile, app_id = values['app_id'], lab_id = values['lab_id'], service_id = values['service_id']) settings.enabled = values['enabled'] settings.activity_probe = values['activity_probe'] settings.sms_probe = values['sms_probe'] settings.call_log_probe = values['call_log_probe'] settings.bluetooth_probe = values['bluetooth_probe'] settings.wifi_probe = values['wifi_probe'] settings.simple_location_probe = values['simple_location_probe'] settings.screen_probe = values['screen_probe'] settings.running_applications_probe = values['running_applications_probe'] settings.hardware_info_probe = values['hardware_info_probe'] settings.app_usage_probe = values['app_usage_probe'] settings.save() return HttpResponse(request.method)
def storeAccessControl(request): values = {} settings_database_columns = ['app_id', 'lab_id', 'activity_probe', 'sms_probe', 'call_log_probe', 'bluetooth_probe', 'wifi_probe', 'simple_location_probe', 'screen_probe', 'running_applications_probe', 'hardware_info_probe', 'app_usage_probe'] context_database_columns = ['context_label', 'context_duration_start', 'context_duration_end', 'context_duration_days', 'context_places'] if request.method == "POST": data = json.loads(request.raw_post_data) datastore_owner = data.get(u'datastore_owner') profile = Profile.objects.get(uuid = datastore_owner) if data.get('context_setting_flag') == 0: #context context, created = Context.objects.get_or_create(datastore_owner = profile, context_label = data.get('context_label')) context.context_duration_start = data.get('context_duration_start') context.context_duration_end = data.get('context_duration_end') context.context_duration_days = data.get('context_duration_days') context.context_places = data.get('context_places') context.save() elif data.get('context_setting_flag') == 1: #setting for column in settings_database_columns: if 'probe' in column: values[column] = True if data.get(column) == 1 else False else: values[column] = data.get(column) try: context = Context.objects.get(datastore_owner = profile, context_label = data.get('settings_context_label')) except Context.DoesNotExist: context = Context.objects.create(datastore_owner = profile, context_label = data.get('settings_context_label')) context.context_duration_start = '10 : 0' context.context_duration_end = '18 : 0' context.context_duration_days = '[0, 1, 1, 1, 1, 1, 0]' context.save() #settings, created = Settings.objects.get_or_create(datastore_owner = profile, app_id = values['app_id'], lab_id = values['lab_id'], context_label_id = context.id) try: settings = Settings.objects.get(datastore_owner = profile, app_id = values['app_id'], lab_id = values['lab_id']) except Settings.DoesNotExist: settings = Settings.objects.create(datastore_owner = profile, app_id = values['app_id'], lab_id = values['lab_id'], context_label_id = context.id) settings.context_label = context settings.activity_probe = values['activity_probe'] settings.sms_probe = values['sms_probe'] settings.call_log_probe = values['call_log_probe'] settings.bluetooth_probe = values['bluetooth_probe'] settings.wifi_probe = values['wifi_probe'] settings.simple_location_probe = values['simple_location_probe'] settings.screen_probe = values['screen_probe'] settings.running_applications_probe = values['running_applications_probe'] settings.hardware_info_probe = values['hardware_info_probe'] settings.app_usage_probe = values['app_usage_probe'] settings.save() return HttpResponse(request.method)
def storeAccessControl(request): values = {} settings_database_columns = [ 'app_id', 'lab_id', 'activity_probe', 'sms_probe', 'call_log_probe', 'bluetooth_probe', 'wifi_probe', 'simple_location_probe', 'screen_probe', 'running_applications_probe', 'hardware_info_probe', 'app_usage_probe' ] context_database_columns = [ 'context_label', 'context_duration_start', 'context_duration_end', 'context_duration_days', 'context_places' ] if request.method == "POST": data = json.loads(request.raw_post_data) datastore_owner = data.get(u'datastore_owner') profile = Profile.objects.get(uuid=datastore_owner) if data.get('context_setting_flag') == 0: #context context, created = Context.objects.get_or_create( datastore_owner=profile, context_label=data.get('context_label')) context.context_duration_start = data.get('context_duration_start') context.context_duration_end = data.get('context_duration_end') context.context_duration_days = data.get('context_duration_days') context.context_places = data.get('context_places') context.save() elif data.get('context_setting_flag') == 1: #setting for column in settings_database_columns: if 'probe' in column: values[column] = True if data.get(column) == 1 else False else: values[column] = data.get(column) try: context = Context.objects.get( datastore_owner=profile, context_label=data.get('settings_context_label')) except Context.DoesNotExist: context = Context.objects.create( datastore_owner=profile, context_label=data.get('settings_context_label')) context.context_duration_start = '10 : 0' context.context_duration_end = '18 : 0' context.context_duration_days = '[0, 1, 1, 1, 1, 1, 0]' context.save() #settings, created = Settings.objects.get_or_create(datastore_owner = profile, app_id = values['app_id'], lab_id = values['lab_id'], context_label_id = context.id) try: settings = Settings.objects.get(datastore_owner=profile, app_id=values['app_id'], lab_id=values['lab_id']) except Settings.DoesNotExist: settings = Settings.objects.create(datastore_owner=profile, app_id=values['app_id'], lab_id=values['lab_id'], context_label_id=context.id) settings.context_label = context settings.activity_probe = values['activity_probe'] settings.sms_probe = values['sms_probe'] settings.call_log_probe = values['call_log_probe'] settings.bluetooth_probe = values['bluetooth_probe'] settings.wifi_probe = values['wifi_probe'] settings.simple_location_probe = values['simple_location_probe'] settings.screen_probe = values['screen_probe'] settings.running_applications_probe = values[ 'running_applications_probe'] settings.hardware_info_probe = values['hardware_info_probe'] settings.app_usage_probe = values['app_usage_probe'] settings.save() return HttpResponse(request.method)
def storeAccessControl(request): values = {} settings_database_columns = ['app_id', 'lab_id', 'activity_probe', 'sms_probe', 'call_log_probe', 'bluetooth_probe', 'wifi_probe', 'simple_location_probe', 'screen_probe', 'running_applications_probe', 'hardware_info_probe', 'app_usage_probe'] context_database_columns = ['context_label', 'context_duration_start', 'context_duration_end', 'context_duration_days', 'context_places'] if request.method == "POST": data = json.loads(request.raw_post_data) datastore_owner = data.get(u'datastore_owner') data_aggregation = data.get(u'data_aggregation') app_id = data.get(u'app_id') lab_id = data.get(u'lab_id') profile = Profile.objects.get(uuid = datastore_owner) optin, created = Optin.objects.get_or_create(datastore_owner = profile, app_id = app_id, lab_id = lab_id) optin.app_id = app_id optin.lab_id = lab_id optin.data_aggregation = data_aggregation optin.save() context_object = data.get('context_object') if context_object: context, created = Context.objects.get_or_create(datastore_owner = profile, context_label = context_object['context_label']) print context_object.keys() context.context_duration_start = context_object['context_duration_start'] context.context_duration_end = context_object['context_duration_end'] context.context_duration_days = context_object['context_duration_days'] context.context_places = context_object['context_places'] context.save() setting_object = data.get('setting_object') print "setting object is:" print setting_object if setting_object: for column in settings_database_columns: if column in setting_object: if 'probe' in column: values[column] = True if setting_object[column] == 1 else False else: values[column] = setting_object[column] else: #extraneous probes values[column] = False print values try: context = Context.objects.get(datastore_owner = profile, context_label = setting_object['settings_context_label']) except Context.DoesNotExist: context = Context.objects.create(datastore_owner = profile, context_label = setting_object['settings_context_label']) context.context_duration_start = '10 : 0' context.context_duration_end = '18 : 0' context.context_duration_days = '[0, 1, 1, 1, 1, 1, 0]' context.save() try: settings = Settings.objects.get(datastore_owner = profile, app_id = values['app_id'], lab_id = values['lab_id']) except Settings.DoesNotExist: settings = Settings.objects.create(datastore_owner = profile, app_id = values['app_id'], lab_id = values['lab_id'], context_label_id = context.id) settings.context_label = context settings.activity_probe = values['activity_probe'] settings.sms_probe = values['sms_probe'] settings.call_log_probe = values['call_log_probe'] settings.bluetooth_probe = values['bluetooth_probe'] settings.wifi_probe = values['wifi_probe'] settings.simple_location_probe = values['simple_location_probe'] settings.screen_probe = values['screen_probe'] settings.running_applications_probe = values['running_applications_probe'] settings.hardware_info_probe = values['hardware_info_probe'] settings.app_usage_probe = values['app_usage_probe'] settings.save() return HttpResponse(request.method)