def get(self, request, user):
        """
        Retrieve Account Subscriptions
        `````````````````````````````````````

        Return list of subscriptions for an account

        :auth: required
        """

        # This returns a dict with `subscriber` and `subscriptions`
        # Returns `None` if no subscriptions for user
        sub = newsletter.get_subscriptions(user)
        if sub is None or not newsletter.is_enabled():
            return self.respond([])

        return self.respond([{
            'listId': x.get('list_id'),
            'listDescription': x.get('list_description'),
            'listName': x.get('list_name'),
            'email': x.get('email'),
            'subscribed': x.get('subscribed'),
            'subscribedDate': x.get('subscribed_date'),
            'unsubscribedDate': x.get('unsubscribed_date'),
        } for x in sub['subscriptions']])
    def get(self, request, user):
        """
        Retrieve Account Subscriptions
        `````````````````````````````````````

        Return list of subscriptions for an account

        :auth: required
        """

        # This returns a dict with `subscriber` and `subscriptions`
        # Returns `None` if no subscriptions for user
        sub = newsletter.get_subscriptions(user)
        if sub is None or not newsletter.is_enabled():
            return self.respond([])

        return self.respond([{
            'listId': x.get('list_id'),
            'listDescription': x.get('list_description'),
            'listName': x.get('list_name'),
            'email': x.get('email'),
            'subscribed': x.get('subscribed'),
            'subscribedDate': x.get('subscribed_date'),
            'unsubscribedDate': x.get('unsubscribed_date'),
        } for x in sub['subscriptions']])
Exemple #3
0
    def get(self, request, user):
        """
        Retrieve Account Subscriptions
        `````````````````````````````````````

        Return list of subscriptions for an account

        :auth: required
        """

        # This returns a dict with `subscriber` and `subscriptions`
        # Returns `None` if no subscriptions for user
        sub = newsletter.get_subscriptions(user)
        if sub is None or not newsletter.is_enabled():
            return self.respond([])

        return self.respond([{
            "listId": x.get("list_id"),
            "listDescription": x.get("list_description"),
            "listName": x.get("list_name"),
            "email": x.get("email"),
            "subscribed": x.get("subscribed"),
            "subscribedDate": x.get("subscribed_date"),
            "unsubscribedDate": x.get("unsubscribed_date"),
        } for x in sub["subscriptions"]])
Exemple #4
0
 def __init__(self, *args, **kwargs):
     super(RegistrationForm, self).__init__(*args, **kwargs)
     if not newsletter.is_enabled():
         del self.fields['subscribe']
     else:
         self.fields['subscribe'].help_text = mark_safe(
             "We'd love to keep you updated via email with product and feature announcements, promotions, educational materials, and events. Our updates focus on relevant information and never sell your data to marketing companies. See our <a href=\"%(privacy_link)s\">Privacy Policy</a> for more details."
             .format(privacy_link=settings.PRIVACY_URL, ))
Exemple #5
0
 def handle(self, request):
     return self.respond(
         'sentry/account/security.html', {
             'page': 'security',
             'has_2fa': Authenticator.objects.user_has_2fa(request.user),
             'AUTH_PROVIDERS': get_auth_providers(),
             'has_newsletters': newsletter.is_enabled(),
         })
Exemple #6
0
 def handle(self, request):
     return self.respond(
         'sentry/account/security.html', {
             'page': 'security',
             'has_2fa': Authenticator.objects.user_has_2fa(request.user),
             'AUTH_PROVIDERS': get_auth_providers(),
             'has_newsletters': newsletter.is_enabled(),
         }
     )
Exemple #7
0
 def __init__(self, *args, **kwargs):
     super(RegistrationForm, self).__init__(*args, **kwargs)
     if not newsletter.is_enabled():
         del self.fields['subscribe']
     else:
         # NOTE: the text here is duplicated within the ``NewsletterConsent`` component
         # in the UI
         self.fields['subscribe'].help_text = mark_safe("We'd love to keep you updated via email with product and feature announcements, promotions, educational materials, and events. Our updates focus on relevant information and never sell your data to marketing companies. See our <a href=\"%(privacy_link)s\">Privacy Policy</a> for more details.".format(
             privacy_link=settings.PRIVACY_URL,
         ))
Exemple #8
0
def verify_newsletter_subscription(sender, **kwargs):
    from sentry import newsletter

    if not newsletter.is_enabled():
        return

    if not sender.is_primary():
        return

    newsletter.update_subscription(
        sender.user,
        verified=True,
        verified_date=timezone.now(),
    )
Exemple #9
0
    def prepare_login_context(self, request, *args, **kwargs):
        can_register = bool(has_user_registration() or request.session.get("can_register"))

        context = {
            "serverHostname": get_server_hostname(),
            "canRegister": can_register,
            "hasNewsletter": newsletter.is_enabled(),
        }

        if "session_expired" in request.COOKIES:
            context["warning"] = WARN_SESSION_EXPIRED

        context.update(additional_context.run_callbacks(request))

        return context
Exemple #10
0
 def __init__(self, *args, **kwargs):
     super(PasswordlessRegistrationForm, self).__init__(*args, **kwargs)
     if not newsletter.is_enabled():
         del self.fields['subscribe']
     else:
         # NOTE: the text here is duplicated within the ``NewsletterConsent`` component
         # in the UI
         notice = (
             "We'd love to keep you updated via email with product and feature "
             "announcements, promotions, educational materials, and events. "
             "Our updates focus on relevant information, and we'll never sell "
             "your data to third parties. See our "
             "<a href=\"{privacy_link}\">Privacy Policy</a> for more details."
         )
         self.fields['subscribe'].help_text = mark_safe(
             notice.format(privacy_link=settings.PRIVACY_URL))
Exemple #11
0
 def __init__(self, *args, **kwargs):
     super(PasswordlessRegistrationForm, self).__init__(*args, **kwargs)
     if not newsletter.is_enabled():
         del self.fields['subscribe']
     else:
         # NOTE: the text here is duplicated within the ``NewsletterConsent`` component
         # in the UI
         notice = (
             "We'd love to keep you updated via email with product and feature "
             "announcements, promotions, educational materials, and events. "
             "Our updates focus on relevant information, and we'll never sell "
             "your data to third parties. See our "
             "<a href=\"{privacy_link}\">Privacy Policy</a> for more details."
         )
         self.fields['subscribe'].help_text = mark_safe(
             notice.format(privacy_link=settings.PRIVACY_URL))
Exemple #12
0
    def prepare_login_context(self, request, *args, **kwargs):
        can_register = bool(auth.has_user_registration()
                            or request.session.get('can_register'))

        context = {
            'serverHostname': get_server_hostname(),
            'canRegister': can_register,
            'hasNewsletter': newsletter.is_enabled(),
        }

        if 'session_expired' in request.COOKIES:
            context['warning'] = WARN_SESSION_EXPIRED

        context.update(additional_context.run_callbacks(request))

        return context