djaodjin / djaodjin-saas

Django application for software-as-service and subscription businesses
Other
564 stars 124 forks source link

command to re-send invites #126

Closed smirolo closed 5 years ago

smirolo commented 6 years ago

Add a manage.py command that can resend invites (Role.grant_key/request_key is not null, Subscription.grant_key/request_key is not null) either in bulk or a specific one with command line argument --email.

knivets commented 6 years ago

Could you provide more details on this one? What does this mean: "Role.grant_key/request_key is not null, Subscription.grant_key/request_key is not null"? What exactly should I do with data once I filter Role/Subscription by grant_key (and/or request_key) != null ? Is there a functionality to send an invite already?

smirolo commented 6 years ago

See Roles, Subscriptions and Opt-ins for how invites and double opt-ins work.

The current invite e-mail is triggered through a signals in Organization.add_role:

        signals.user_relation_added.send(sender=__name__,
            role=m2m, reason=reason, request_user=request_user)

The API end point that calls self.organization.add_role is in RoleFilteredListAPIView.create.

The actual e-mail is sent through the signal handler.

In the Role model there is a grant_key field that is set to a random value, indicating the invite was sent but not accepted yet.

My guess is that the manage.py command only needs to iterate through Role.objects.filter(grant_key__isnull=True) and trigger the signals.user_relation_added.send signal.