-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(accessLogExport)!: create new AccessLogExportTask to generate a …
…csv of access logs TASK-871 (#5258) ### 👀 Preview steps 1. Ensure that the `Export all data` button for `ProjectViews` still works as normal and that the email header has the appropriate title: "Project View Report Complete" 2. Ensure that exports for submission data works correctly: - make submissions to a project - navigate to the _Project < Data < Downloads_ - 🟢 ensure the `Export` button is exporting data correctly 3. Preview the AccessLogExportTask from the shell: - ℹ️ have a user - enter the Django shell: `./manage.py shell_plus` - get your user: `test_user = User.objects.get(username='test')` - create an AccessLogExportTask: ``` task = AccessLogExportTask.objects.create( user=test_user, get_all_logs=False, data={'type': 'access_logs_export'}, ) ``` - 🟢 print the task object and notice that an AccessLogExportTask object has been created: `print(task)` - run the task: `task.run()` - 🟢 print the result and notice that it generated a link to the csv export: `print(task.result)` ### 💭 Notes - Changed the field named `user` to `user_url` because naming it `user` conflicts with an existing field in the `AccessLog` model - Renamed the file titled `project_view_exports.py` to `data_exports.py` because it now generates exports for both project view and access log exports - Refactored the `ProjectViewExportTask` to have a base `CommonExportTask` which both the project view and access log export classes inherit from - Updated the email (in `kpi/tasks.py`) to have the correct subject title based on the type of export report it is sending - Alphabetized the functions in `data_exports.py`
- Loading branch information
1 parent
b5d51b3
commit 6992e8a
Showing
20 changed files
with
478 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
kpi/migrations/0060_rename_exporttask_submissionexporttask_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Generated by Django 4.2.15 on 2024-11-26 19:55 | ||
|
||
import django.db.models.deletion | ||
import private_storage.fields | ||
import private_storage.storage.files | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
import kpi.fields.file | ||
import kpi.fields.kpi_uid | ||
import kpi.models.asset_file | ||
import kpi.models.import_export_task | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('kpi', '0059_assetexportsettings_date_created_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name='ExportTask', | ||
new_name='SubmissionExportTask', | ||
), | ||
migrations.RenameModel( | ||
old_name='SynchronousExport', | ||
new_name='SubmissionSynchronousExport', | ||
), | ||
migrations.AlterField( | ||
model_name='assetfile', | ||
name='content', | ||
field=kpi.fields.file.PrivateExtendedFileField( | ||
max_length=380, null=True, upload_to=kpi.models.asset_file.upload_to | ||
), | ||
), | ||
migrations.CreateModel( | ||
name='AccessLogExportTask', | ||
fields=[ | ||
( | ||
'id', | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name='ID', | ||
), | ||
), | ||
('data', models.JSONField()), | ||
('messages', models.JSONField(default=dict)), | ||
( | ||
'status', | ||
models.CharField( | ||
choices=[ | ||
('created', 'created'), | ||
('processing', 'processing'), | ||
('error', 'error'), | ||
('complete', 'complete'), | ||
], | ||
default='created', | ||
max_length=32, | ||
), | ||
), | ||
('date_created', models.DateTimeField(auto_now_add=True)), | ||
('uid', kpi.fields.kpi_uid.KpiUidField(_null=False, uid_prefix='ale')), | ||
('get_all_logs', models.BooleanField(default=False)), | ||
( | ||
'result', | ||
private_storage.fields.PrivateFileField( | ||
max_length=380, | ||
storage=( | ||
private_storage.storage.files.PrivateFileSystemStorage() | ||
), | ||
upload_to=kpi.models.import_export_task.export_upload_to, | ||
), | ||
), | ||
( | ||
'user', | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=(kpi.models.import_export_task.ExportTaskMixin, models.Model), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.