onadata.apps.logger.management.commands package

Subpackages

Submodules

onadata.apps.logger.management.commands.add_id module

Sync account with ‘_id’

class onadata.apps.logger.management.commands.add_id.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Sync account with ‘_id’

add_id(user)

Append _id in submissions for the specifing user.

args = '<username>'
handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = "Sync account with '_id'"

onadata.apps.logger.management.commands.change_s3_media_permissions module

change_s3_media_permissions - makes all s3 files private.

class onadata.apps.logger.management.commands.change_s3_media_permissions.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Makes all s3 files private

handle(*args, **kwargs)

Makes all s3 files private

help = 'Makes all s3 files private'

onadata.apps.logger.management.commands.create_backup module

create_backup - command to create zipped backup of a form and it’s submissions.

class onadata.apps.logger.management.commands.create_backup.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Create a zip backup of a form and all its submissions.

args = 'outfile username [id_string]'
handle(*args, **options)

Create a zip backup of a form and all its submissions.

help = 'Create a zip backup of a form and all its submissions'

onadata.apps.logger.management.commands.create_image_thumbnails module

create_image_thumbnails - creates thumbnails for all form images and stores them.

class onadata.apps.logger.management.commands.create_image_thumbnails.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Creates thumbnails for all form images and stores them

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = 'Creates thumbnails for all form images and stores them'

onadata.apps.logger.management.commands.export_gps_points module

Export all gps points with their timestamps

class onadata.apps.logger.management.commands.export_gps_points.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Export all gps points with their timestamps

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Export all gps points with their timestamps'

onadata.apps.logger.management.commands.export_xforms_and_instances module

export_xformx_and_instances - exports XForms and submission instances into JSON files.

class onadata.apps.logger.management.commands.export_xforms_and_instances.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Export ODK forms and instances to JSON.

handle(*args, **kwargs)

Export ODK forms and instances to JSON.

help = 'Export ODK forms and instances to JSON.'

onadata.apps.logger.management.commands.fix_attachments_counts module

Fix submission media count command.

class onadata.apps.logger.management.commands.fix_attachments_counts.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Fix attachments count command.

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

args = 'username'
handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = 'Fix attachments count.'
process_attachments(user)

Process attachments for submissions where media_all_received is False.

onadata.apps.logger.management.commands.fix_attachments_counts.update_attachments(instance)

Takes an Instance object and updates attachment tracking fields

onadata.apps.logger.management.commands.fix_duplicate_instances module

Fix duplicate instances by merging the attachments.

class onadata.apps.logger.management.commands.fix_duplicate_instances.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Fix duplicate instances by merging the attachments.

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Fix duplicate instances by merging the attachments.'
query_data(sql)

Return results of given sql query.

onadata.apps.logger.management.commands.fix_submission_count module

Fix num of submissions

class onadata.apps.logger.management.commands.fix_submission_count.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Fix num of submissions

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Fix num of submissions'

onadata.apps.logger.management.commands.generate_platform_stats module

Management command used to generate platform statistics containing information about the number of organizations, users, projects & submissions

class onadata.apps.logger.management.commands.generate_platform_stats.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Management command used to generate platform statistics containing information about the number of organizations, users, projects & submissions

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = 'Generates system statistics for the entire platform'

onadata.apps.logger.management.commands.import module

class onadata.apps.logger.management.commands.import.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Import ODK forms and instances.'

onadata.apps.logger.management.commands.import_briefcase module

import_briefcase command

  • imports XForm XML from a folder and publishes the XForm.

  • import XForm submissions XML from a folder and inserts into the table instances.

class onadata.apps.logger.management.commands.import_briefcase.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Insert all existing parsed instances into MongoDB

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

Insert all existing parsed instances into MongoDB

help = 'Insert all existing parsed instances into MongoDB'

onadata.apps.logger.management.commands.import_forms module

import_forms - loads XForms from a given path.

class onadata.apps.logger.management.commands.import_forms.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Import a folder of XForms for ODK.

handle(*args, **kwargs)

Import a folder of XForms for ODK.

help = 'Import a folder of XForms for ODK.'

onadata.apps.logger.management.commands.import_instances module

import_instances - import ODK instances from a zipped file.

class onadata.apps.logger.management.commands.import_instances.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

import_instances - import ODK instances from a zipped file.

args = 'username path'
handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Import a zip file, a directory containing zip files or a directory of ODK instances'

onadata.apps.logger.management.commands.import_tools module

import_tools - import ODK formms and instances.

class onadata.apps.logger.management.commands.import_tools.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Import ODK forms and instances.

handle(*args, **kwargs)

Import ODK forms and instances.

help = 'Import ODK forms and instances.'

onadata.apps.logger.management.commands.move_media_to_s3 module

move_media_to_s3 - Moves all XLSForm file from local storage to S3 storage.

class onadata.apps.logger.management.commands.move_media_to_s3.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Moves all XLSForm file from local storage to S3 storage.

handle(*args, **kwargs)

Moves all XLSForm file from local storage to S3 storage.

help = 'Moves all attachments and xls files to s3 from the local file system storage.'

onadata.apps.logger.management.commands.populate_osmdata_model module

populate_osmdata_model command - process OSM XML and save data in OsmData model/table.

class onadata.apps.logger.management.commands.populate_osmdata_model.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Populate OsmData model with osm info.

args = '<username>'
handle(*args, **kwargs)

Populate OsmData model with osm info.

help = 'Populate OsmData model with osm info.'

onadata.apps.logger.management.commands.publish_xls module

publish_xls - Publish an XLSForm command.

class onadata.apps.logger.management.commands.publish_xls.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Publish an XLSForm file.

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

args = 'xls_file username project'
handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = 'Publish an XLSForm file with the option of replacing an existing one'

onadata.apps.logger.management.commands.pull_from_aggregate module

pull_from_aggregate command

Uses the BriefcaseClient to download forms and submissions from a server that implements the Briefcase Aggregate API.

class onadata.apps.logger.management.commands.pull_from_aggregate.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Download forms and submissions from a server with Briefcase Aggregate API

add_arguments(parser)

Download forms and submissions from a server with Briefcase Aggregate API

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Download forms and submissions from a server with Briefcase Aggregate API'

onadata.apps.logger.management.commands.reapplyperms module

reapplyperms - reapplies XForm permissions for the given user.

class onadata.apps.logger.management.commands.reapplyperms.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Reapply permissions to XForms.

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = 'Reapply permissions to XForms.'

onadata.apps.logger.management.commands.recover_deleted_attachments module

Module containing the recover_deleted_attachments management command.

Used to recover attachments that were accidentally deleted within the system but are still required/present within the submission XML

Sample usage: python manage.py recover_deleted_attachments –form 1

class onadata.apps.logger.management.commands.recover_deleted_attachments.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Management command used to recover wrongfully deleted attachments.

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = 'Restore wrongly deleted attachments'
onadata.apps.logger.management.commands.recover_deleted_attachments.recover_deleted_attachments(form_id: str, stdout=None)

Recovers attachments that were accidentally soft-deleted

Param:

(str) form_id: Unique identifier for an XForm object

Param:

(sys.stdout) stdout: Python standard output. Default: None

onadata.apps.logger.management.commands.regenerate_instance_json module

Management command python manage.py regenerate_instance_json <form_ids>

Regenerates a form’s instances json asynchronously

class onadata.apps.logger.management.commands.regenerate_instance_json.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Regenerate a form’s instances json

Json data recreated afresh and any existing json data is overriden

Usage: python manage.py regenerate_instance_json <form_ids> e.g python manage.py regenerate_instance_json 689 567 453

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = "Regenerate a form's instances json"

onadata.apps.logger.management.commands.remove_columns_from_briefcase_data module

Delete specific columns from submission XMLs pulled by ODK Briefcase.

class onadata.apps.logger.management.commands.remove_columns_from_briefcase_data.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Delete specific columns from submission XMLs pulled by ODK Briefcase.

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = 'Delete specific columns from submission XMLs pulled by ODK Briefcase.'
onadata.apps.logger.management.commands.remove_columns_from_briefcase_data.remove_columns_from_xml(xml: str, columns: List[str]) str

Returns the xml with columns/tags removed.

onadata.apps.logger.management.commands.replace_form_id_root_node module

Management command used to replace the root node of an Instance when the root node is the XForm ID Example usage:

python manage.py replace_form_id_root_node -c -i 1,2,3

class onadata.apps.logger.management.commands.replace_form_id_root_node.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Replaces form ID String with ‘data’ for an instances root node

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = "Replaces form ID String with 'data' for an instances root node"
onadata.apps.logger.management.commands.replace_form_id_root_node.replace_form_id_with_correct_root_node(inst_id: int, root: str | None = None, commit: bool = False) str

Returns the submission XML with updated root node tag name.

onadata.apps.logger.management.commands.restore_backup module

restore_backup command - Restore a zip backup of a form and all its submissions

class onadata.apps.logger.management.commands.restore_backup.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

restore_backup command - Restore a zip backup of a form and all its submissions

args = 'username input_file'
handle(*args, **options)

The actual logic of the command. Subclasses must implement this method.

help = 'Restore a zip backup of a form and all its submissions'

onadata.apps.logger.management.commands.set_xform_surveys_with_geopoints module

Import a folder of XForms for ODK.

class onadata.apps.logger.management.commands.set_xform_surveys_with_geopoints.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Import a folder of XForms for ODK.

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Import a folder of XForms for ODK.'

onadata.apps.logger.management.commands.set_xform_surveys_with_osm module

Set xform.instances_with_osm

class onadata.apps.logger.management.commands.set_xform_surveys_with_osm.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Set xform.instances_with_osm

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Set xform.instances_with_osm'

onadata.apps.logger.management.commands.sync_deleted_instances_fix module

Fixes deleted instances by syncing deleted items from mongo.

class onadata.apps.logger.management.commands.sync_deleted_instances_fix.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Fixes deleted instances by syncing deleted items from mongo.

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Fixes deleted instances by syncing deleted items from mongo.'

onadata.apps.logger.management.commands.transferproject module

Functionality to transfer a project from one owner to another.

class onadata.apps.logger.management.commands.transferproject.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Command to transfer a project from one user to the other.

Usage: The mandatory arguments are –current-owner, –new-owner and either of –project-id or –all-projects. Depending on what is supplied for –project-id or –all-projects, the command will either transfer a single project or all the projects.

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

errors = []
get_user(username)

Return user object with the given username.

handle(*args, **options)

Transfer projects from one user to another.

help = 'A command to reassign a project(s) from one user to the other.'
static update_data_views(form)

Update DataView project for the XForm given.

static update_merged_xform(project, user)

Update ownership of MergedXforms.

update_xform_with_new_user(project, user)

Update XForm user update the DataViews and also set the permissions for the xForm and the project.

onadata.apps.logger.management.commands.update_moved_forms module

Ensures all the forms are owned by the project owner

class onadata.apps.logger.management.commands.update_moved_forms.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Ensures all the forms are owned by the project owner

handle(*args, **kwargs)

The actual logic of the command. Subclasses must implement this method.

help = 'Ensures all the forms are owned by the project owner'

onadata.apps.logger.management.commands.update_xform_uuids module

update_xform_uuids command - Set uuid from a CSV file

class onadata.apps.logger.management.commands.update_xform_uuids.Command(stdout=None, stderr=None, no_color=False, force_color=False)

Bases: BaseCommand

Use a csv file with username, id_string and new_uuid to set new uuids.

add_arguments(parser)

Entry point for subclassed commands to add custom arguments.

handle(*args, **kwargs)

Use a csv file with username, id_string and new_uuid to set new uuids.

help = 'Use a csv file with username, id_string and new_uuid to set new uuids'

Module contents