Пример #1
0
def on_subscription_created(sender, event, **kwargs):
    user = event.customer.user

    data = event.message['data']
    started = data['object']['start']
    time = format(datetime.datetime.fromtimestamp(int(started)), 'c')

    analytics = AtticusFinch()
    analytics.event('subscription.created', time=time, user=user)
Пример #2
0
def on_subscription_deleted(sender, event, **kwargs):
    user = event.customer.user

    data = event.message['data']
    canceled_at = data['object']['canceled_at']
    time = format(datetime.datetime.fromtimestamp(int(canceled_at)), 'c')

    analytics = AtticusFinch()
    analytics.event('subscription.cancelled', time=time, user=user)
Пример #3
0
def on_charge_failed(sender, event, **kwargs):
    user = event.customer.user

    data = event.message['data']
    amount = float(data['object']['amount']) / 100
    created = data['object']['created']
    time = format(datetime.datetime.fromtimestamp(int(created)), 'c')

    analytics = AtticusFinch()
    analytics.event('subscription.failed', amount='${0:.2f}'.format(amount), time=time, user=user)
Пример #4
0
    def save(self, **kwargs):
        # delete their subscription
        try:
            customer = self.user.customer
        except ObjectDoesNotExist:
            pass
        else:
            customer.cancel(at_period_end=False)

        # set the account to be inactive
        self.user.is_active = False
        self.user.save(update_fields=['is_active'])

        analytics = AtticusFinch()
        analytics.event('user.cancel', reason=self.cleaned_data.get('reason'), user=self.user)
Пример #5
0
    def form_valid(self, form):
        # user a valid form log them in

        form.save()  # save the user
        self.authenticate(form=form)  # log them in

        mailer = ValidateEmailMailer(((self.request.user.get_full_name(), self.request.user.email,),))
        mailer.process(user=self.request.user)

        messages.info(self.request, 'Your account has been created. Please verify your email address. Check your email and click on the link that we\'ve sent you.')

        analytics = AtticusFinch()
        analytics.event('user.signup', user=self.request.user, ip_address=self.request.META.get('HTTP_X_FORWARDED_FOR', self.request.META.get('REMOTE_ADDR')))

        return super(SignUpView, self).form_valid(form)
Пример #6
0
    def form_valid(self, form):
        try:
            self.login(user=self.authenticated_user)

        except (UserNotFoundException, UserInactiveException):
            return self.form_invalid(form=form)

        analytics = AtticusFinch()

        ip_address = self.request.META.get('HTTP_X_FORWARDED_FOR', self.request.META.get('REMOTE_ADDR'))
        analytics.event('user.login', user=self.authenticated_user, ip_address=ip_address)

        logger.info('Logged-in IP_ADDRESS: %s' % ip_address)

        return super(VerifyTwoFactorView, self).form_valid(form)
Пример #7
0
    def save(self):
        user = User.objects.create_user(self.cleaned_data.get('username'),
                                        self.cleaned_data.get('email'),
                                        self.cleaned_data.get('password'),
                                        first_name=self.cleaned_data.get('first_name'),
                                        last_name=self.cleaned_data.get('last_name'))

        # save the lawyer profile
        profile = user.profile
        profile.data['firm_name'] = self.cleaned_data.get('firm_name')
        profile.data['user_class'] = profile.LAWYER
        profile.save(update_fields=['data'])

        mpid = self.cleaned_data.get('mpid', None)

        analytics = AtticusFinch()
        if mpid not in ['', None]:
            analytics.mixpanel_alias(user.pk, mpid)
        analytics.event('user.signup', user=user)

        self.create_demonstration_matter(user=user)

        return user
Пример #8
0
    def form_valid(self, form):
        # user a valid form log them in
        try:

            logger.info('authenticating user: %s' % form.cleaned_data.get('email'))
            self.authenticated_user = self.get_auth(form=form)

        except (UserNotFoundException, UserInactiveException):

            return self.form_invalid(form=form)

        if self.authenticated_user.profile.data.get('two_factor_enabled', False):
            self.request.session['user'] = self.authenticated_user.username
        else:
            self.login(user=self.authenticated_user)

            analytics = AtticusFinch()

            ip_address = self.request.META.get('HTTP_X_FORWARDED_FOR', self.request.META.get('REMOTE_ADDR'))
            analytics.event('user.login', user=self.authenticated_user, ip_address=ip_address)

            logger.info('Signed-up IP_ADDRESS List: %s' % ip_address)

        return super(StartView, self).form_valid(form)
Пример #9
0
 def form_invalid(self, form):
     analytics = AtticusFinch()
     ip_address = self.request.META.get('HTTP_X_FORWARDED_FOR', self.request.META.get('REMOTE_ADDR'))
     analytics.anon_event('user.login.invalid', distinct_id=form.data.get('email'), ip_address=ip_address)
     return super(StartView, self).form_invalid(form=form)