def whitelist_edit(request): variables = {} whitelist_id = int(request.POST.get("data[id]", "0")) phoneuser_id = int(request.POST.get("data[phoneuser_id]", "0")) if whitelist_id: try: whitelist = Whitelist.objects.get(pk=whitelist_id) whitelist.duration = int(whitelist.duration / 60) whitelist.frequency = int(whitelist.frequency) except: raise Http404 else: whitelist = Whitelist() whitelist.duration = int(Pref.get("threshold")) / 60 if phoneuser_id: try: whitelist.phoneuser = PhoneUser.objects.get(pk=phoneuser_id) except: raise Http404 variables['whitelist'] = whitelist variables['enable_first_in'] = Pref.get("enable_first_in") variables['change_threshold'] = Pref.get("change_threshold") return render_to_response('phoneusers/whitelists/whitelist.html', variables)
def archive_credit_export(request, archived_phoneuser_id=0): """Stampa bilancio""" import datetime archived_phoneuser_id = int(archived_phoneuser_id) if archived_phoneuser_id: try: archived_phoneuser = ArchivedPhoneUser.objects.get(pk=archived_phoneuser_id) except: raise Http404 recharges = ArchivedCredit.objects.filter(archived_phoneuser_id=archived_phoneuser_id) tot_recharges = ArchivedCredit.get_total(archived_phoneuser_id) tot_cost = ArchivedDetail.get_cost(archived_phoneuser_id) variables = { 'header': Pref.header(), 'phoneuser': archived_phoneuser, 'today': datetime.date.today().strftime("%d-%m-%Y"), 'recharges': recharges, 'tot_recharges': tot_recharges, 'tot_cost': tot_cost, } return render_to_response('phoneusers/credits/report.html', variables) else: raise Http404
def archive_credit_print_recharge(request, archived_credit_id): """Stampa Singola Ricarica""" import datetime archived_credit_id = int(archived_credit_id) if archived_credit_id: try: archived_credit = ArchivedCredit.objects.get(pk=archived_credit_id) archived_phoneuser = ArchivedPhoneUser.objects.get(pk=archived_credit.archived_phoneuser_id) except: raise Http404 variables = { 'header': Pref.header(), 'phoneuser': archived_phoneuser, 'today': datetime.date.today().strftime("%d-%m-%Y"), 'credit': archived_credit, } return render_to_response('phoneusers/credits/print_receipt.html', variables) else: raise Http404
def prefs_edit(request): # recuperiamo le preferenze e le tariffe min_duration = Pref.get("min_duration") alert_before_end = Pref.get("alert_before_end") enable_first_in = Pref.get("enable_first_in") change_threshold = Pref.get("change_threshold") threshold = int(Pref.get("threshold")) / 60 header = Pref.get("header") fares = Fare.objects.filter(position__gt=0).order_by("position") variables = { "min_duration": min_duration, "alert_before_end": alert_before_end, "enable_first_in": enable_first_in, "change_threshold": change_threshold, "threshold": threshold, "fares": fares, "header": header, } variables.update(Acl.get_permissions_for_user(request.user.id, request.user.is_staff)) return render_to_response("prefs.html", RequestContext(request, variables))