Open roald-teunissen opened 2 years ago
Take a look at this PR, which implemented the labels.
@fershad I'm reviewing and tidying up any obviously out of date issues relating to the platform today. I think release 1.4 delivered very similar changes to this so I think we can close this issue off? What do you think?
Is your feature request related to a problem? Please describe. We want to be informed when a user specifically edits their "supporting evidence", so we can evaluate it. Additionally in the overview, we want to see which items are yet to be evaluated by us.
Describe the solution you'd like A simple and fast solution is to use the tagging/labeling system that is already in place. We can add a label "to-be-validated" for example if a user alters or adds supporting evidence. After evaluation by us, we can remove this tag manually by the person that evaluated it.
Describe alternatives you've considered To add a status attribute to all supporting evidence pieces so we know which one are on "pending" or "validated". In the overview we can thereafter search for evidence that is not evaluated yet.
Additional context It's hard to keep track of which provider has updated their supporting evidence, so this is really an important feature.
Implementation details
To update this we would need to:
Hook into the request lifecycle when someone makes a form submission to check that a form submission has new data
There are methods we can override for this. See the
save_formset
method that you can override, or hook into for hosting providers.https://github.com/thegreenwebfoundation/admin-portal/blob/master/apps/accounts/admin.py#L348
This is going to be a bit complicated, the
save_formset
method is actually called multiple times - once for each sub form in an admin page, and in our case the supporting material has it's own form we need to listen for being updated, like we have existing code that looks for an existingHostingProviderNoteForm
object being updated.This might actually make sense to pair on to be honest, as making changes to the django admin is one of the more advanced bits you might work on in django land. @roald-teunissen - I'd suggest starting on the other parts first till we can work synchronously on this one.
Add the "to be validated" label if appropriate
Adding a label to a provider is idempotent - you can add them using the ORM like this example:
https://github.com/thegreenwebfoundation/admin-portal/blob/master/apps/greencheck/carbon_txt.py#L84
I think there are methods like
exists()
you can use to see if a label is already on the provider.This allows you check if you would be adding a label onto a provider where it wasn't there beforehand, and this is useful for deciding to send an update to support staff.
Send a notification to a given address when supporting evidence is changed.
You can see an example of sending an email to a user, and then making note of what was sent at the link below:
https://github.com/thegreenwebfoundation/admin-portal/blob/master/apps/accounts/admin.py#L292-L335
It looks a bit like this - we send an email with the normal django
send_mail
method, which accepts a plain text message, as well as an HTML message (see themessage_mkdn
) bit:making a note of the message sent
After this, we might want to make a note that we sent a message on the internal notes for the provider. You can also use this to track arbitrary events on a user. This gives you a way to timestamp updates to provided support info, for example.