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}))
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}))
def signin_user_guest(request, username, paid_by): user = get_object_or_404(User, username=username) day = CoworkingDay() day.user = user day.visit_date = localtime(now()).date() # Only proceed if they haven't signed in already if user.coworkingday_set.filter(visit_date=day.visit_date).count() == 0: if paid_by: host = get_object_or_404(User, username=paid_by) day.paid_by = host if user.coworkingday_set.count() == 0: day.payment = 'Trial' else: day.payment = 'Bill' day.save() return HttpResponseRedirect(reverse('tablet:welcome', kwargs={'username': username}))
def save(self): "Creates the Daily Log to track member activity" if not self.is_valid(): raise Exception('The form must be valid in order to save') # Make sure there isn't another log for this member on this day u = User.objects.get(username=self.cleaned_data['username']) v = self.cleaned_data['visit_date'] if CoworkingDay.objects.filter(user=u, visit_date=v).count() > 0: raise Exception('Member already signed in') day = CoworkingDay() day.user = u day.visit_date = v day.payment = self.cleaned_data['payment'] day.note = self.cleaned_data['note'] day.save() return day
def a_coworkingday(user, visit_date=today, payment="Bill"): return CoworkingDay(user=user, visit_date=visit_date, payment=payment)