Exemplo n.º 1
0
def signin_user_guest(request, username, paid_by):
    user = get_object_or_404(User, username=username)
    day = CoworkingDay()
    day.user = user
    day.visit_date = timezone.localtime(timezone.now()).date()
    # Only proceed if they haven't signed in already
    if CoworkingDay.objects.filter(user=user, visit_date=day.visit_date).count() == 0:
        if paid_by:
            host = get_object_or_404(User, username=paid_by)
            day.paid_by = host
        if CoworkingDay.objects.filter(user=user).count() == 0:
            day.payment = 'Trial'
        else:
            day.payment = 'Bill'
        day.save()

        if day.payment == 'Trial':
            try:
                email.announce_free_trial(user)
                email.send_introduction(user)
                email.subscribe_to_newsletter(user)
                #SlackAPI().invite_user(user)
            except:
                logger.error("Could not send introduction email to %s" % user.email)
        else:
            if len(user.profile.open_alerts()) > 0:
                mailgun.send_manage_member(user)
    return HttpResponseRedirect(reverse('tablet_welcome', kwargs={'username': username}))
Exemplo n.º 2
0
def signin_user_guest(request, username, paid_by):
    user = get_object_or_404(User, username=username)
    day = CoworkingDay()
    day.user = user
    day.visit_date = timezone.localtime(timezone.now()).date()
    # Only proceed if they haven't signed in already
    if CoworkingDay.objects.filter(user=user, visit_date=day.visit_date).count() == 0:
        if paid_by:
            host = get_object_or_404(User, username=paid_by)
            day.paid_by = host
        if CoworkingDay.objects.filter(user=user).count() == 0:
            day.payment = 'Trial'
        else:
            day.payment = 'Bill'
        day.save()

        if day.payment == 'Trial':
            try:
                email.announce_free_trial(user)
                email.send_introduction(user)
                email.subscribe_to_newsletter(user)
                #SlackAPI().invite_user(user)
            except:
                logger.error("Could not send introduction email to %s" % user.email)
        else:
            if len(user.profile.open_alerts()) > 0:
                mailgun.send_manage_member(user)
    return HttpResponseRedirect(reverse('tablet:welcome', kwargs={'username': username}))
Exemplo n.º 3
0
    def trigger_sign_in(self, user):
        logger.debug("trigger_sign_in: %s" % user)

        # If they have signed in, they are not stale anymore
        user.profile.resolve_alerts(MemberAlert.STALE_MEMBER)

        # Send out a bunch of things the first time they sign in
        if CoworkingDay.objects.filter(user=user).count() == 1:
            try:
                email.announce_free_trial(user)
                email.send_introduction(user)
                email.subscribe_to_newsletter(user)
            except:
                logger.error("Could not send introduction email to %s" %
                             user.email)
        else:
            # If it's not their first day and they still have open alerts, message the team
            if len(user.profile.open_alerts()) > 0:
                email.send_manage_member(user)
Exemplo n.º 4
0
def notify_sign_in(sender, **kwargs):
    user = kwargs['user']
    # Send out a bunch of things the first time they sign in
    if CoworkingDay.objects.filter(user=user).count() == 1:
        try:
            email.announce_free_trial(user)
        except:
            logger.error("Could not announce free trial for %s" % user.email)
        try:
            email.send_introduction(user)
        except:
            logger.error("Could not send introduction email to %s" %
                         user.email)
        try:
            email.subscribe_to_newsletter(user)
        except:
            logger.error("Could not subscribe user to email: %s" % user.email)
    else:
        # If it's not their first day and they still have open alerts, message the team
        if len(user.profile.open_alerts()) > 0:
            email.send_manage_member(user)