-
Notifications
You must be signed in to change notification settings - Fork 655
Admin view to list uploaded assets #1960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Django does not allow to select related nested FK from generic fks, such as content_object. Because of that, a lot of collateral queries were being executed to display the sponsorship name because it depends on both its package and sponsor names. This commit changes this by filtering all the sponsorships and organizing it as a in-memory dict that is only load for this page.
Since assets are created automatically by the process to handle new sponsorship applications, having the possibility for users to manually add assets can lead to states that are unknown to the application. This commit prevents that from happening.
|
@ewdurbin this PR probably is now at a more stable state. It adds a admin view to list all the generic assets but a few smart filters to help PSF staff to work on top of them. This is a print screen of the view listing all the assets from my local DB: And this is a print screen of every filter being combined to reduce the number of listed assets: I tried to leave the interface with hyperlinks to sponsor/sponsorship and also, if the asset has a file, to the file itself. The next step now is the admin action to export the assets as a ZIP file. I though about using Django's admin actions as the user interface to enable the export. Thus, the UX would be something like: 1 - The user apply the filtering they want to use; A minor disclaimer. There's no action select in the attached screen shots because the delete operation is disabled for the assets. So, since there's no action to be performed, Django admin hides the select and the entries' checkbox by default. Anyway, @ewdurbin do you feel the process I describe above satisfies the needs to export the data? The only concern I have is with the memory consumption. I mean, if we process the whole zip within the lifecycle of the request, maybe we can run into issues if there are too many assets to be exported. An alternative to that would be to leave the export process to be async, using django-rq for example, and then send the zip file via email. But I don't know if this is big design upfront. How do you feel about this topic? |
|
@ewdurbin another question about the ZIP file is: how to organize the files? For example, let's imagine that there are 10 assets to be exported, 5 texts and 5 images, being a pair of each from a different sponsorship. Should the zip be organized using the sponsorships ids as directories? So, something like: Or just using the sponsorship as the file prefix would be enough? Something like: Although the first strategy is more complicated, I guess it's more powerful and easier for the PSF staff to use. It also gives us the benefits to add the "info.txt" file to contextualize the application within the ZIP file by listing their basic information. |
|
The process you note in the first question to select assets and use an action is 👍🏼 For the export... we probably want to use a temporary file/dir to assemble then zip files. Let's start doing it in the request cycle and see how it performs. For structure, a folder per "Sponsor Name" is probably best! |
|
@ewdurbin I pushed new commits implementing the export functionality. The sponsor name is used as the directory name, while the asset's Although the PR is missing tests for this new admin action (I'm planning to work on them tomorrow), I've generated a sample zip using my local database so you can review it. The sample zip contains examples of one text asset and one image assets, both from the same sponsor. Disclaimer: the data is very naive and are both placeholders I've input while testing the assets form. Feel free to merge this if you want to or if this feature is being missed by PSF staff. I can keep a personal note as the missing tests as a technical debt that I can address on an upcoming PR. |
c0177ae to
7e48eb4
Compare
|
@ewdurbin the tests are here. Now this branch can be reviewed and merged with more confidence =) |
|
Thanks @berinhard, I also added a small fix for the AssetsInline (which wasn't properly rendering status/values) and registered admin views for the new asset types. |


This PR adds a new admin view that's is accessible through a new button at sponsorship detail page's header. The view is very straightforward and, for now, it only details the uploaded assets within a table.
New button on Sponsorship detail

Uploaded assets table

@ewdurbin I know we've spoken about the functionality to download all assets as a single zip file. I thought about adding a button at the bottom of the table with that option. The button should trigger a request with
format=zipin the querystring and the backend will do the rest. But I thought about opening a new PR to address this exclusively. That way PSF staff would at least be able to see the data once we merge this PR.Let me know what you think about this.