Skip to content
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

Add a way to derive email addresses associated with active collections #1096

Open
kerchner opened this issue Nov 30, 2021 · 2 comments
Open

Comments

@kerchner
Copy link
Member

Via management command (or admin view?)

This would be useful so that we can notify all users with active collections that we will be purging collections.

@dolsysmith
Copy link
Contributor

I think something like the following would work. (I tested below in the management console on my dev environment.)

from ui.models import User, Collection

users = User.objects.all()
users_to_notify = []
for user in users:
    if not user.email:
        continue
    for collection in Collection.objects.filter(collection_set__group__in=user.groups.all(), is_active=True)]:
        row = {'email': user.email, 'collection': collection.name}
        users_to_notify.append(row)
# Then export users_to_notify as a CSV

Would there be other metadata about the collections we would like to include, in addition to the collection names?

@kerchner
Copy link
Member Author

kerchner commented Nov 30, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants