def handle(self, *args, **options): """ Check out all checked in users """ checkedout_user = 0 users = HiveUser.objects.all() for user in users: if user.is_checked_in(): check = Check(user=user, check_type='ou') check.save() checkedout_user += 1 self.stdout.write('Successfully checked out %d user(s).\n' % checkedout_user)
def UserCheckInOutView(request): #try: user = HiveUser.objects.get(username=request.POST['pin']) if user.is_checked_in(): # We check out check = Check(user=user, check_type='ou') check.save() # check if user still has credit # if not send him an email if user.get_credit_minutes() <= 0: subject = "The HiVE - You're out of credit" message = "Hi %s, \n" % user.first_name message += "You don't have anymore credit \n" message += "- The HiVE\n" send_user_email(subject, message, user.email) else: # We check in check = Check(user=user, check_type='in') if 'use_daypass' in request.POST: check.using_daypass = True check.save() context = {'user': user, 'check': check} return render(request, 'beelogger/user-checked-in-out.html', context)
def UserCheckInOutView(request): user_set = HiveUser.objects.filter(user__username=request.POST['pin']) if user_set: user = user_set[0] if user.is_checked_in(): # We check out check = Check(user=user, check_type='ou') check.save() else: # We check in check = Check(user=user, check_type='in') if 'use_daypass' in request.POST: check.using_daypass = True check.save() extra_context = {'user': user, 'check': check} return render(request, 'beelogger/user-checked-in-out.html', extra_context)